itor/gui/draw.go

53 lines
1.1 KiB
Go

package gui
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
const hotPink = lipgloss.Color("#FF06B7")
var hotPinkInput = lipgloss.NewStyle().Foreground(hotPink)
func (m *model) updateDraw(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
// Is it a key press?
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q":
return m, tea.Quit
case "s":
m.switchMode(Select)
}
}
return m, nil
}
func (m *model) viewDraw() string {
s := fmt.Sprintf("Draw Mode (%d cards):\n\n", len(m.selected))
s += fmt.Sprintf("[%s] [%s] [%s] [%s]\n",
hotPinkInput.Width(7).Render("1: View"),
hotPinkInput.Width(10).Render("2: Correct"),
hotPinkInput.Width(12).Render("3: Incorrect"),
hotPinkInput.Width(7).Render("4: Skip"),
)
s += "\nPress [s] to go back to select\nPress [q] to quit."
return s
}
func (m *model) cardListToString() string {
s := ""
for i, card := range m.deck {
if _, ok := m.selected[i]; ok {
s += fmt.Sprintf("%s [%s]\n", card.Front, card.Back)
}
}
return s
}