Skip to content

Commit 48a365c

Browse files
committed
feat: simple loading complete case
1 parent ae49c81 commit 48a365c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

utils/loading.go

+15-6
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@ import (
1111
)
1212

1313
type Spinner struct {
14-
Frames []string
15-
FPS time.Duration
14+
Frames []string
15+
Complete string
16+
FPS time.Duration
1617
}
1718

1819
var Dot = Spinner{
19-
Frames: []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
20-
FPS: time.Second / 10, //nolint:gomnd
20+
Frames: []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
21+
Complete: styles.CorrectMark,
22+
FPS: time.Second / 10, //nolint:gomnd
2123
}
2224

2325
type Loading struct {
2426
Spinner Spinner
2527
Style lipgloss.Style
2628
Text string
2729

28-
quitting bool
29-
frame int
30+
quitting bool
31+
completing bool
32+
frame int
3033
}
3134

3235
func NewLoading(text string) Loading {
@@ -48,6 +51,9 @@ func (m Loading) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4851
case "q", "esc", "ctrl+c":
4952
m.quitting = true
5053
return m, tea.Quit
54+
case "f":
55+
m.completing = true
56+
return m, tea.Quit
5157
default:
5258
return m, nil
5359
}
@@ -69,6 +75,9 @@ func (m Loading) View() string {
6975
}
7076
spinner := m.Style.Render(m.Spinner.Frames[m.frame])
7177

78+
if m.completing {
79+
return fmt.Sprintf("\n%s %s\n", m.Spinner.Complete, m.Text)
80+
}
7281
str := fmt.Sprintf("\n%s %s\n", spinner, m.Text)
7382
if m.quitting {
7483
return str + "\n"

0 commit comments

Comments
 (0)