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++
|
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 "enter" key and the spacebar (a literal space) toggle
|
||||||
// the selected state for the item that the cursor is pointing at.
|
// the selected state for the item that the cursor is pointing at.
|
||||||
case "enter", " ":
|
case "enter", " ":
|
||||||
@ -68,22 +75,22 @@ func (m model) View() string {
|
|||||||
s := ""
|
s := ""
|
||||||
currentList := []todo{}
|
currentList := []todo{}
|
||||||
|
|
||||||
switch m.tab {
|
// switch m.tab {
|
||||||
case 0:
|
// case 0:
|
||||||
s += "Inbox"
|
// s += "Inbox"
|
||||||
inboxFilter := func(t todo) bool { return t.isInbox }
|
// inboxFilter := func(t todo) bool { return t.isInbox }
|
||||||
currentList = filter(m.todos, inboxFilter)
|
// currentList = filter(m.todos, inboxFilter)
|
||||||
case 1:
|
// case 1:
|
||||||
s += "Today"
|
// s += "Today"
|
||||||
case 2:
|
// case 2:
|
||||||
s += "Tomorrow"
|
// s += "Tomorrow"
|
||||||
case 3:
|
// case 3:
|
||||||
s += "Scheduled"
|
// s += "Scheduled"
|
||||||
case 4:
|
// case 4:
|
||||||
s += "Anytime"
|
// s += "Anytime"
|
||||||
}
|
// }
|
||||||
|
|
||||||
s += "\n\n"
|
s += "GOTD\n\n"
|
||||||
|
|
||||||
// Iterate over our choices
|
// Iterate over our choices
|
||||||
for i, choice := range currentList {
|
for i, choice := range currentList {
|
||||||
@ -104,10 +111,22 @@ func (m model) View() string {
|
|||||||
s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice)
|
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
|
// The footer
|
||||||
s += "n: new\n"
|
s += "\nn: new\n"
|
||||||
s += "q: quit.\n"
|
s += "q: quit.\n"
|
||||||
|
|
||||||
|
if m.addTask {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Send the UI for rendering
|
// Send the UI for rendering
|
||||||
return s
|
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
|
cursor int // which to-do list item our cursor is pointing at
|
||||||
selected map[int]struct{} // which to-do items are selected
|
selected map[int]struct{} // which to-do items are selected
|
||||||
tab int // which tab is 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 {
|
func initialModel() model {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user