@@ -8,6 +8,9 @@ import (
"github.com/charmbracelet/soft-serve/ui/common"
)
+// ToggleFooterMsg is a message sent to show/hide the footer.
+type ToggleFooterMsg struct{}
+
// Footer is a Bubble Tea model that displays help and other info.
type Footer struct {
common common.Common
@@ -83,3 +86,8 @@ func (f *Footer) SetShowAll(show bool) {
func (f *Footer) Height() int {
return lipgloss.Height(f.View())
}
+
+// ToggleFooterCmd sends a ToggleFooterMsg to show/hide the help footer.
+func ToggleFooterCmd() tea.Msg {
+ return ToggleFooterMsg{}
+}
@@ -184,11 +184,7 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Always show the footer on error.
ui.showFooter = ui.footer.ShowAll()
case key.Matches(msg, ui.common.KeyMap.Help):
- ui.footer.SetShowAll(!ui.footer.ShowAll())- // Show the footer when on repo page and shot all help.- if ui.error == nil && ui.activePage == repoPage {- ui.showFooter = !ui.showFooter- }
+ cmds = append(cmds, footer.ToggleFooterCmd)
case key.Matches(msg, ui.common.KeyMap.Quit):
return ui, tea.Quit
case ui.activePage == repoPage && key.Matches(msg, ui.common.KeyMap.Back):
@@ -197,6 +193,12 @@ func (ui *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
ui.showFooter = true
}
}
+ case footer.ToggleFooterMsg:
+ ui.footer.SetShowAll(!ui.footer.ShowAll())
+ // Show the footer when on repo page and shot all help.
+ if ui.error == nil && ui.activePage == repoPage {
+ ui.showFooter = !ui.showFooter
+ }
case repo.RepoMsg:
ui.activePage = repoPage
// Show the footer on repo page if show all is set.