diff --git a/internal/tui/bubbles/git/bubble.go b/internal/tui/bubbles/git/bubble.go index 4a47467fe37ed64467ef4ac539f53dd9f0ab7b4a..d2c6bb0025e16c180d52f231f2a76ef4d978fa9f 100644 --- a/internal/tui/bubbles/git/bubble.go +++ b/internal/tui/bubbles/git/bubble.go @@ -16,17 +16,17 @@ const ( repoNameMaxWidth = 32 ) -type pageState int +type state int const ( - aboutPage pageState = iota - refsPage - logPage - treePage + aboutState state = iota + refsState + logState + treeState ) type Bubble struct { - state pageState + state state repo types.Repo height int heightMargin int @@ -40,7 +40,7 @@ type Bubble struct { func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble { b := &Bubble{ repo: repo, - state: aboutPage, + state: aboutState, width: width, widthMargin: wm, height: height, @@ -50,10 +50,10 @@ func NewBubble(repo types.Repo, styles *style.Styles, width, wm, height, hm int) ref: repo.GetHEAD(), } heightMargin := hm + lipgloss.Height(b.headerView()) - b.boxes[aboutPage] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin) - b.boxes[refsPage] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin) - b.boxes[logPage] = log.NewBubble(repo, b.style, width, wm, height, heightMargin) - b.boxes[treePage] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin) + b.boxes[aboutState] = about.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin) + b.boxes[refsState] = refs.NewBubble(repo, b.style, b.width, wm, b.height, heightMargin) + b.boxes[logState] = log.NewBubble(repo, b.style, width, wm, height, heightMargin) + b.boxes[treeState] = tree.NewBubble(repo, b.style, width, wm, height, heightMargin) return b } @@ -68,27 +68,20 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if b.repo.Name() != "config" { switch msg.String() { case "R": - b.state = aboutPage + b.state = aboutState case "B": - b.state = refsPage + b.state = refsState case "C": - b.state = logPage + b.state = logState case "F": - b.state = treePage + b.state = treeState } } case tea.WindowSizeMsg: b.width = msg.Width b.height = msg.Height - for i, bx := range b.boxes { - m, cmd := bx.Update(msg) - b.boxes[i] = m - if cmd != nil { - cmds = append(cmds, cmd) - } - } case refs.RefMsg: - b.state = treePage + b.state = treeState b.ref = msg for i, bx := range b.boxes { m, cmd := bx.Update(msg) diff --git a/internal/tui/bubbles/repo/bubble.go b/internal/tui/bubbles/repo/bubble.go index d96d3b10ca718fa5689fe5307fffd32c1bf7c8d7..5ba6f8fcacea26ea8af02c61007f1911802ab550 100644 --- a/internal/tui/bubbles/repo/bubble.go +++ b/internal/tui/bubbles/repo/bubble.go @@ -33,18 +33,18 @@ type Bubble struct { Active bool } -func NewBubble(name, host string, port int, repo gittypes.Repo, styles *style.Styles, width, wm, height, hm int) *Bubble { +func NewBubble(repo gittypes.Repo, host string, port int, styles *style.Styles, width, wm, height, hm int) *Bubble { b := &Bubble{ - name: name, + name: repo.Name(), host: host, port: port, - repo: repo, width: width, widthMargin: wm, height: height, heightMargin: hm, styles: styles, } + b.repo = repo b.box = gitui.NewBubble(repo, styles, width, wm+styles.RepoBody.GetHorizontalBorderSize(), height, hm+lipgloss.Height(b.headerView())-styles.RepoBody.GetVerticalBorderSize()) return b } diff --git a/internal/tui/commands.go b/internal/tui/commands.go index 7eef46ba64f531f04173c8bdb047dec0e69a17d7..20d3b16aaa4a541033f7af8c01d1f0d686d5907f 100644 --- a/internal/tui/commands.go +++ b/internal/tui/commands.go @@ -115,7 +115,7 @@ func (b *Bubble) newMenuEntry(name string, rn string) (MenuEntry, error) { lipgloss.Height(b.footerView()) + b.styles.RepoBody.GetVerticalFrameSize() + b.styles.App.GetVerticalMargins() - rb := repo.NewBubble(rn, b.config.Host, b.config.Port, r, b.styles, b.width, boxLeftWidth, b.height, heightMargin) + rb := repo.NewBubble(r, b.config.Host, b.config.Port, b.styles, b.width, boxLeftWidth, b.height, heightMargin) initCmd := rb.Init() msg := initCmd() switch msg := msg.(type) {