repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / tui / pages
Eric Bower · 05 Oct 24

pages.go

 1package pages
 2
 3import tea "github.com/charmbracelet/bubbletea"
 4
 5type Page int
 6
 7const (
 8	MenuPage Page = iota
 9	CreateAccountPage
10	CreatePubkeyPage
11	CreateTokenPage
12	PubkeysPage
13	TokensPage
14	NotificationsPage
15	PlusPage
16	SettingsPage
17	LogsPage
18)
19
20type NavigateMsg struct{ Page }
21
22func Navigate(page Page) tea.Cmd {
23	return func() tea.Msg {
24		return NavigateMsg{page}
25	}
26}
27
28func ToTitle(page Page) string {
29	switch page {
30	case CreateAccountPage:
31		return "create account"
32	case CreatePubkeyPage:
33		return "add pubkey"
34	case CreateTokenPage:
35		return "new api token"
36	case MenuPage:
37		return "menu"
38	case NotificationsPage:
39		return "notifications"
40	case PlusPage:
41		return "pico+"
42	case TokensPage:
43		return "api tokens"
44	case PubkeysPage:
45		return "pubkeys"
46	case SettingsPage:
47		return "settings"
48	case LogsPage:
49		return "logs"
50	}
51
52	return ""
53}