This commit is contained in:
@@ -30,7 +30,7 @@ type Msg struct {
|
||||
inner tea.Msg
|
||||
}
|
||||
|
||||
func New(cfg config.Data) (m Model) {
|
||||
func New(cfg config.Asset) (m Model) {
|
||||
m.math = moon.NewMath(
|
||||
cfg.Asset,
|
||||
cfg.Goals,
|
||||
@@ -89,10 +89,6 @@ func New(cfg config.Data) (m Model) {
|
||||
return
|
||||
}
|
||||
|
||||
func (m Model) Handles(a coindesk.Asset) bool {
|
||||
return m.math.Asset == a
|
||||
}
|
||||
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return tea.Batch(
|
||||
m.indicator.Tick,
|
||||
@@ -102,6 +98,10 @@ func (m Model) Init() tea.Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
func (m Model) Handles(a coindesk.Asset) bool {
|
||||
return m.math.Asset == a
|
||||
}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case Msg:
|
||||
@@ -195,14 +195,34 @@ func refillProperties(m *Model) {
|
||||
}
|
||||
|
||||
func refillProjections(m *Model) {
|
||||
rows := []table.Row{m.math.Labels}
|
||||
cols := []table.Row{m.math.Labels}
|
||||
for i := range m.math.Columns {
|
||||
rows = append(rows, m.math.Columns[i].Column())
|
||||
entries := renderEntries(m.math.Columns[i])
|
||||
cols = append(cols, entries)
|
||||
}
|
||||
rows = transpose(rows)
|
||||
rows := transpose(cols)
|
||||
m.projections.SetRows(rows)
|
||||
}
|
||||
|
||||
func renderEntries(c moon.Column) (entries []string) {
|
||||
entries = append(entries, fmt.Sprintf("$%.2f", c.StartingPrice))
|
||||
entries = append(entries, fmt.Sprintf("%.2f%%", (c.CDPR-1)*100))
|
||||
never := c.CDPR <= 1
|
||||
for i := range c.Projections.Dates {
|
||||
var cell string
|
||||
if never {
|
||||
cell = "NEVER!!!!!"
|
||||
} else {
|
||||
cell = c.
|
||||
Projections.
|
||||
Dates[i].
|
||||
Format("2006-01-02")
|
||||
}
|
||||
entries = append(entries, cell)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func transpose(slice []table.Row) []table.Row {
|
||||
xl := len(slice[0])
|
||||
yl := len(slice)
|
||||
|
Reference in New Issue
Block a user