Start search UI

This commit is contained in:
The Magician 2024-06-10 14:15:10 +01:00
parent ecd3fe79d7
commit 2885ec32bc
2 changed files with 28 additions and 10 deletions

View File

@ -135,6 +135,7 @@ func (m MainModel) View() string {
func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var cmd tea.Cmd var cmd tea.Cmd
var cmds []tea.Cmd
switch msg := msg.(type) { switch msg := msg.(type) {
case tea.WindowSizeMsg: case tea.WindowSizeMsg:
@ -157,14 +158,10 @@ func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch { switch {
case key.Matches(msg, m.keyMappings.Update): case key.Matches(msg, m.keyMappings.Update):
m.state = updateView m.state = updateView
break
case key.Matches(msg, m.keyMappings.Search): case key.Matches(msg, m.keyMappings.Search):
m.state = searchView m.state = searchView
break
} }
break
} }
break
case updateView: case updateView:
newUpdate, newCmd := m.updateModel.Update(msg) newUpdate, newCmd := m.updateModel.Update(msg)
@ -175,7 +172,6 @@ func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.updateModel = newUpdateModel m.updateModel = newUpdateModel
cmd = newCmd cmd = newCmd
break
case searchView: case searchView:
newSearch, newCmd := m.searchModel.Update(msg) newSearch, newCmd := m.searchModel.Update(msg)
newSearchModel, ok := newSearch.(searchui.Model) newSearchModel, ok := newSearch.(searchui.Model)
@ -185,8 +181,8 @@ func (m MainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.searchModel = newSearchModel m.searchModel = newSearchModel
cmd = newCmd cmd = newCmd
break
} }
return m, cmd cmds = append(cmds, cmd)
return m, tea.Batch(cmds...)
} }

View File

@ -1,8 +1,16 @@
package searchui package searchui
import tea "github.com/charmbracelet/bubbletea" import (
"sevenkeys/figlet"
"sevenkeys/logic"
tea "github.com/charmbracelet/bubbletea"
)
type Model struct { type Model struct {
searchOptions logic.SearchOptions
selectedCardPrintingId int
selectedCardPrintingSearch string
} }
func NewSearchModel() Model { func NewSearchModel() Model {
@ -14,9 +22,23 @@ func (m Model) Init() tea.Cmd {
} }
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil /*
var cmd tea.Cmd
switch msg := msg.(type) {
case cardPrintingsLoadedMsg:
m.cardPrintingsLoaded = true
break
}
*/
return m, tea.Quit
} }
func (m Model) View() string { func (m Model) View() string {
return "Search" var ui string
ui += figlet.SprintMsgSlant("Insert Cards")
return ui
} }