dynamo-browse/internal/dynamo-browse/ui/teamodels/testmodel.go
Leon Mika b0909ffe4e Rebuilding the UI models
Rebuilding the UI model with brand new utility models for layout and dealing with model stuff.
2022-03-27 11:01:24 +11:00

34 lines
562 B
Go

package teamodels
import (
tea "github.com/charmbracelet/bubbletea"
)
// TestModel is a model used for testing
type TestModel struct {
Message string
OnKeyPressed func(k string) tea.Cmd
}
func (t TestModel) Init() tea.Cmd {
return nil
}
func (t TestModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "esc":
return t, tea.Quit
default:
return t, t.OnKeyPressed(msg.String())
}
}
return t, nil
}
func (t TestModel) View() string {
return t.Message
}