smutok/internal/tui/tui.go(view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
package tui
import tea "github.com/charmbracelet/bubbletea"
type Model struct {
isQutting bool
showErr bool
err error
}
func NewModel() *Model {
return &Model{}
}
func (m *Model) Init() tea.Cmd {
return nil
}
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case errMsg:
m.err = msg
m.showErr = true
return m, nil
case tea.WindowSizeMsg:
case tea.KeyMsg:
switch msg.String() {
case "q":
m.isQutting = true
return m, tea.Quit
}
}
return m, nil
}
func (m *Model) View() string {
if m.isQutting {
return ""
}
return "are you feeling smutok?"
}
|