Skip to content

Commit ea9468f

Browse files
committed
feat(ui): add install model
add install model Signed-off-by: mritd <[email protected]>
1 parent 813c53f commit ea9468f

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

apps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func commitApp() *cli.App {
7979
views: []tea.Model{
8080
newSelectorModel(),
8181
newInputsModel(),
82-
newSpinnerModel(),
82+
newCommitModel(),
8383
newResultModel(),
8484
},
8585
}

ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (m model) result() tea.Msg {
119119
// views: []tea.Model{
120120
// newSelectorModel(),
121121
// newInputsModel(),
122-
// newSpinnerModel(),
122+
// newCommitModel(),
123123
// newResultModel(),
124124
// },
125125
// }

ui_install.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
"github.com/charmbracelet/bubbles/spinner"
5+
tea "github.com/charmbracelet/bubbletea"
6+
)
7+
8+
type installModel struct {
9+
index int
10+
err error
11+
stages map[int]func() error
12+
spinner spinner.Model
13+
}
14+
15+
func (m installModel) Init() tea.Cmd {
16+
return nil
17+
}
18+
19+
func (m installModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
20+
switch msg.(type) {
21+
case done:
22+
default:
23+
24+
}
25+
26+
return m, nil
27+
}
28+
29+
func (m installModel) View() string {
30+
return ""
31+
}

ui_spinner.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
package main
22

33
import (
4+
"time"
5+
46
"github.com/charmbracelet/bubbles/spinner"
57
tea "github.com/charmbracelet/bubbletea"
68
"github.com/charmbracelet/lipgloss"
7-
"time"
89
)
910

1011
var (
11-
spinnerStyle = lipgloss.NewStyle().
12+
commitStyle = lipgloss.NewStyle().
1213
Padding(1, 1, 1, 2)
1314

14-
spinnerBorderStyle = lipgloss.NewStyle().
15+
commitTextStyle = lipgloss.NewStyle().
16+
Foreground(lipgloss.Color("#25A065"))
17+
18+
commitBorderStyle = commitTextStyle.Copy().
1519
Border(lipgloss.RoundedBorder()).
16-
BorderForeground(lipgloss.Color("#25A065")).
20+
BorderBottomBackground(lipgloss.Color("#25A065")).
1721
Padding(1, 2, 1, 2)
18-
19-
spinnerTextStyle = lipgloss.NewStyle().
20-
Foreground(lipgloss.Color("#25A065"))
2122
)
2223

23-
type spinnerModel struct {
24+
type commitModel struct {
2425
err error
2526
spinner spinner.Model
2627
}
2728

28-
func newSpinnerModel() spinnerModel {
29+
func newCommitModel() commitModel {
2930
s := spinner.NewModel()
3031
s.Spinner = spinner.Dot
3132
s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
32-
return spinnerModel{spinner: s}
33+
return commitModel{spinner: s}
3334
}
3435

35-
func (m spinnerModel) Init() tea.Cmd {
36+
func (m commitModel) Init() tea.Cmd {
3637
return nil
3738
}
3839

39-
func (m spinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
40+
func (m commitModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4041
switch msg := msg.(type) {
4142
case tea.KeyMsg:
4243
switch msg.String() {
@@ -59,7 +60,7 @@ func (m spinnerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
5960
}
6061
}
6162

62-
func (m spinnerModel) View() string {
63-
spinnerView := m.spinner.View() + spinnerTextStyle.Render("Committing... Please wait...")
64-
return spinnerStyle.Render(spinnerBorderStyle.Render(spinnerView))
63+
func (m commitModel) View() string {
64+
spinnerView := m.spinner.View() + commitTextStyle.Render("Committing... Please wait...")
65+
return commitStyle.Render(commitBorderStyle.Render(spinnerView))
6566
}

0 commit comments

Comments
 (0)