* refactor(tui): port to charm v2 bumped bubbletea, lipgloss, bubbles, wish, and huh to v2. Mostly mechanical chur, new import paths, vewport getter/setter api, view() returns tea.view now, huh.theme became an interface so the theme package needed a small reshape. Render plumbing is gone (no more lipgloss.Render field on the Model or MakeRenderer in main.go). All pages still work over ssh. setting up for the refund composer next * style(tui): gofmt main.go and menu.go
60 lines
1.0 KiB
Go
60 lines
1.0 KiB
Go
package tui
|
|
|
|
import (
|
|
"fmt"
|
|
"terminalShop/pkg/api"
|
|
"terminalShop/pkg/models"
|
|
|
|
tea "charm.land/bubbletea/v2"
|
|
|
|
"charm.land/lipgloss/v2"
|
|
)
|
|
|
|
type DelayCompleteMsg struct{}
|
|
type splashCursorTickMsg struct{}
|
|
|
|
type SplashAuthMsg struct {
|
|
Token string
|
|
User models.PublicUser
|
|
Err error
|
|
}
|
|
|
|
type ViewInitMsg struct {
|
|
Data api.ViewInitData
|
|
Err error
|
|
}
|
|
|
|
func (m Model) splashViewInitCmd() tea.Msg {
|
|
data, err := m.APIClient.GetViewInit()
|
|
if err != nil {
|
|
return ViewInitMsg{Err: fmt.Errorf("failed to load data: %w", err)}
|
|
}
|
|
return ViewInitMsg{Data: data}
|
|
}
|
|
|
|
func (m Model) SplashView() string {
|
|
accent := m.theme.TextBody().Bold(true)
|
|
|
|
var cursor string
|
|
if m.splash.cursor {
|
|
cursor = lipgloss.NewStyle().Background(m.theme.Highlight()).Render(" ")
|
|
} else {
|
|
cursor = " "
|
|
}
|
|
|
|
logo := accent.Render("terminal coffee") + cursor
|
|
|
|
content := lipgloss.JoinVertical(
|
|
lipgloss.Center,
|
|
logo,
|
|
)
|
|
|
|
return lipgloss.Place(
|
|
m.viewportWidth,
|
|
m.viewportHeight,
|
|
lipgloss.Center,
|
|
lipgloss.Center,
|
|
content,
|
|
)
|
|
}
|