Add basic tab bar
This commit is contained in:
parent
e95f3900ad
commit
4d2028cd01
51
bubbletea.go
51
bubbletea.go
@ -46,6 +46,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.tab++
|
||||
}
|
||||
|
||||
// new task
|
||||
case "n":
|
||||
m.addTask = true
|
||||
|
||||
case "esc":
|
||||
m.addTask = false
|
||||
|
||||
// The "enter" key and the spacebar (a literal space) toggle
|
||||
// the selected state for the item that the cursor is pointing at.
|
||||
case "enter", " ":
|
||||
@ -68,22 +75,22 @@ func (m model) View() string {
|
||||
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"
|
||||
}
|
||||
// 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"
|
||||
s += "GOTD\n\n"
|
||||
|
||||
// Iterate over our choices
|
||||
for i, choice := range currentList {
|
||||
@ -104,10 +111,22 @@ func (m model) View() string {
|
||||
s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)
|
||||
}
|
||||
|
||||
for i, v := range []string{"Inbox", "Today", "Tomorrow", "Scheduled", "Anytime"} {
|
||||
if i == m.tab {
|
||||
s += fmt.Sprintf("**%s** ", v)
|
||||
} else {
|
||||
s += fmt.Sprintf("%s ", v)
|
||||
}
|
||||
}
|
||||
|
||||
// The footer
|
||||
s += "n: new\n"
|
||||
s += "\nn: new\n"
|
||||
s += "q: quit.\n"
|
||||
|
||||
if m.addTask {
|
||||
|
||||
}
|
||||
|
||||
// Send the UI for rendering
|
||||
return s
|
||||
}
|
||||
|
2
model.go
2
model.go
@ -15,7 +15,7 @@ type model struct {
|
||||
cursor int // which to-do list item our cursor is pointing at
|
||||
selected map[int]struct{} // which to-do items are selected
|
||||
tab int // which tab is selected
|
||||
add bool // defines if the new task window is shown
|
||||
addTask bool // defines if the new task window is shown
|
||||
}
|
||||
|
||||
func initialModel() model {
|
||||
|
Loading…
x
Reference in New Issue
Block a user