48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package gui
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/charmbracelet/bubbles/textinput"
|
|
)
|
|
|
|
type Card struct {
|
|
Front string
|
|
Back string
|
|
LastCorrect time.Time
|
|
}
|
|
|
|
type model struct {
|
|
deck []Card // items on the to-do list
|
|
selectCardIndex int // which to-do list item our selectCardIndex is pointing at
|
|
selected map[int]struct{} // which to-do items are selected
|
|
createInputs []textinput.Model
|
|
createdInputIndex int
|
|
mode Mode
|
|
err error
|
|
}
|
|
|
|
func initialModel() model {
|
|
front := textinput.New()
|
|
front.Placeholder = "Front..."
|
|
front.Focus()
|
|
front.CharLimit = 256
|
|
front.Width = 80
|
|
|
|
back := textinput.New()
|
|
back.Placeholder = "Back..."
|
|
back.CharLimit = 256
|
|
back.Width = 80
|
|
|
|
return model{
|
|
deck: []Card{
|
|
{Front: "Hello (JP)", Back: "Konnichi wa"},
|
|
{Front: "Hello (SP)", Back: "Hola"},
|
|
{Front: "Hello (DE)", Back: "Guten Tag"},
|
|
},
|
|
createInputs: []textinput.Model{front, back},
|
|
selected: make(map[int]struct{}),
|
|
mode: Select,
|
|
}
|
|
}
|