itor/gui/draw.go

53 lines
1.1 KiB
Go
Raw Normal View History

2022-10-09 03:18:46 +00:00
package gui
2022-10-09 05:21:00 +00:00
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
const hotPink = lipgloss.Color("#FF06B7")
var hotPinkInput = lipgloss.NewStyle().Foreground(hotPink)
2022-10-09 03:18:46 +00:00
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
}
2022-10-09 05:21:00 +00:00
2022-10-09 03:18:46 +00:00
func (m *model) viewDraw() string {
2022-10-09 05:21:00 +00:00
s := fmt.Sprintf("Draw Mode (%d cards):\n\n", len(m.selected))
2022-10-09 03:18:46 +00:00
2022-10-09 05:21:00 +00:00
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"),
)
2022-10-09 03:18:46 +00:00
2022-10-09 03:46:15 +00:00
s += "\nPress [s] to go back to select\nPress [q] to quit."
2022-10-09 03:18:46 +00:00
return s
}
2022-10-09 05:21:00 +00:00
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
}