Compare commits
No commits in common. "4d9482f36363bcb93d287fce5b37ad6ca64b82b6" and "254d74bdb43a50285018a8f914935c653f7b9955" have entirely different histories.
4d9482f363
...
254d74bdb4
30
bubbletea.go
30
bubbletea.go
@ -68,7 +68,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
|
|
||||||
case "enter":
|
case "enter":
|
||||||
if m.addTask {
|
if m.addTask {
|
||||||
AddNewTask(&m)
|
AddNewTask(m)
|
||||||
m.addTask = false
|
m.addTask = false
|
||||||
m.textinput.Reset()
|
m.textinput.Reset()
|
||||||
}
|
}
|
||||||
@ -76,15 +76,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
// 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 " ":
|
case " ":
|
||||||
|
_, ok := m.selected[m.cursor]
|
||||||
if !m.addTask {
|
if ok {
|
||||||
if m.todos[m.cursor].done {
|
delete(m.selected, m.cursor)
|
||||||
m.todos[m.cursor].done = false
|
} else {
|
||||||
} else {
|
m.selected[m.cursor] = struct{}{}
|
||||||
m.todos[m.cursor].done = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +91,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
return m, cmd
|
return m, cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddNewTask(m *model) {
|
func AddNewTask(m model) {
|
||||||
t := todo{
|
t := todo{
|
||||||
name: m.textinput.Value(),
|
name: m.textinput.Value(),
|
||||||
done: false,
|
done: false,
|
||||||
@ -109,15 +106,15 @@ func AddNewTask(m *model) {
|
|||||||
func (m model) View() string {
|
func (m model) View() string {
|
||||||
// The header
|
// The header
|
||||||
s := ""
|
s := ""
|
||||||
currentList := m.todos
|
currentList := []todo{}
|
||||||
|
|
||||||
s += "GOTD\n"
|
s += "GOTD\n"
|
||||||
|
|
||||||
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:
|
||||||
@ -141,11 +138,8 @@ func (m model) View() string {
|
|||||||
|
|
||||||
// Is this choice selected?
|
// Is this choice selected?
|
||||||
checked := " " // not selected
|
checked := " " // not selected
|
||||||
// if _, ok := m.selected[i]; ok {
|
if _, ok := m.selected[i]; ok {
|
||||||
// checked = "x" // selected!
|
checked = "x" // selected!
|
||||||
// }
|
|
||||||
if value.done {
|
|
||||||
checked = "x"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the row
|
// Render the row
|
||||||
|
Loading…
x
Reference in New Issue
Block a user