From 5231fd8f6ae22bd96149419a8c7dd7713f140a8b Mon Sep 17 00:00:00 2001 From: june Date: Sat, 8 Mar 2025 11:56:56 +1300 Subject: [PATCH] doing some filtering and tabwork --- bubbletea.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/bubbletea.go b/bubbletea.go index c6133bd..505da7b 100644 --- a/bubbletea.go +++ b/bubbletea.go @@ -64,10 +64,29 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m model) View() string { // The header - s := "What should we buy at the market?\n\n" + s := "" + currentList := []todo{} + + switch m.tab { + case 0: + s += "Inbox" + inboxFilter := func(t todo) bool { return t.isInbox} + currentList = filter(m.todos, inboxFilter) + case 1: + s += "Today" + case 2: + s += "Tomorrow" + case 3: + s += "Scheduled" + case 4: + s += "Anytime" + } + + s += "\n\n" + // Iterate over our choices - for i, choice := range m.list { + for i, choice := range currentList { // Is the cursor pointing at this choice? cursor := " " // no cursor