Minor reformatting.
All checks were successful
Build & Test / Main (push) Successful in 57s
Release / Release (push) Successful in 1m1s

This commit is contained in:
2024-03-21 00:17:29 -07:00
parent 19de412fc5
commit 80855a15a9
4 changed files with 353 additions and 343 deletions

View File

@@ -13,10 +13,6 @@ import (
"github.com/charmbracelet/lipgloss"
)
var baseStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))
type Model struct {
math moon.Math
@@ -48,10 +44,11 @@ func New(cfg config.Data) Model {
{Title: "Labels", Width: 8},
}
for i := range math.Columns {
projectionCols = append(projectionCols, table.Column{
Title: math.Columns[i].Base.Label(),
Width: 10,
})
projectionCols = append(projectionCols,
table.Column{
Title: math.Columns[i].Base.Label(),
Width: 10,
})
}
projections := table.New(
table.WithColumns(projectionCols),
@@ -61,7 +58,8 @@ func New(cfg config.Data) Model {
indicator := spinner.New()
indicator.Spinner = spinner.Points
indicator.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("69"))
indicator.Style = lipgloss.NewStyle().
Foreground(lipgloss.Color("69"))
return Model{
math: math,
@@ -88,18 +86,19 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
_ = m.math.Refresh(context.TODO())
return m.math
}
case spinner.TickMsg:
var cmd tea.Cmd
m.indicator, cmd = m.indicator.Update(msg)
return m, cmd
case moon.Math:
m.math = msg
m.reloading = false
refillPrice(&m)
refillProjections(&m)
return m, tea.Tick(time.Second*30, func(t time.Time) tea.Msg {
return refresh{}
})
return m, tea.Tick(time.Second*30,
func(t time.Time) tea.Msg {
return refresh{}
})
case spinner.TickMsg:
var cmd tea.Cmd
m.indicator, cmd = m.indicator.Update(msg)
return m, cmd
case tea.KeyMsg:
switch msg.String() {
case "ctrl+c", "q", "esc":
@@ -113,7 +112,10 @@ type refresh struct{}
func refillPrice(m *Model) {
rows := []table.Row{
[]string{string(m.math.Asset), fmt.Sprintf("$%0.2f", m.math.CurrentPrice)},
[]string{
string(m.math.Asset),
fmt.Sprintf("$%0.2f", m.math.CurrentPrice),
},
}
m.prices.SetRows(rows)
}
@@ -160,3 +162,7 @@ func (m Model) View() string {
)
return s + "\n"
}
var baseStyle = lipgloss.NewStyle().
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240"))