footer.go

 1package footer
 2
 3import (
 4	"github.com/charmbracelet/bubbles/help"
 5	tea "github.com/charmbracelet/bubbletea"
 6	"github.com/charmbracelet/soft-serve/ui/common"
 7)
 8
 9type Footer struct {
10	common common.Common
11	help   help.Model
12	keymap help.KeyMap
13}
14
15func New(c common.Common, keymap help.KeyMap) *Footer {
16	h := help.New()
17	h.Styles.ShortKey = c.Styles.HelpKey
18	h.Styles.FullKey = c.Styles.HelpKey
19	f := &Footer{
20		common: c,
21		help:   h,
22		keymap: keymap,
23	}
24	return f
25}
26
27func (f *Footer) SetSize(width, height int) {
28	f.common.Width = width
29	f.common.Height = height
30}
31
32func (f *Footer) Init() tea.Cmd {
33	return nil
34}
35
36func (f *Footer) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
37	return f, nil
38}
39
40func (f *Footer) View() string {
41	if f.keymap == nil {
42		return ""
43	}
44	s := f.common.Styles.Footer.Copy().Width(f.common.Width)
45	return s.Render(f.help.View(f.keymap))
46}