format time and difficulty better
use m
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"charm.land/lipgloss/v2"
|
"charm.land/lipgloss/v2"
|
||||||
"github.com/charmbracelet/bubbles/help"
|
"github.com/charmbracelet/bubbles/help"
|
||||||
"github.com/charmbracelet/bubbles/key"
|
"github.com/charmbracelet/bubbles/key"
|
||||||
@@ -19,19 +21,19 @@ func (m TaskModel) Init() tea.Cmd {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TaskModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
func (m TaskModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.WindowSizeMsg:
|
case tea.WindowSizeMsg:
|
||||||
t.SetSize(msg.Width, msg.Height)
|
m.SetSize(msg.Width, msg.Height)
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch {
|
switch {
|
||||||
case key.Matches(msg, t.keys.Quit):
|
case key.Matches(msg, m.keys.Quit):
|
||||||
return t, tea.Quit
|
return m, tea.Quit
|
||||||
case key.Matches(msg, t.keys.Continue):
|
case key.Matches(msg, m.keys.Continue):
|
||||||
return t, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m TaskModel) View() string {
|
func (m TaskModel) View() string {
|
||||||
@@ -50,8 +52,9 @@ func (m TaskModel) View() string {
|
|||||||
|
|
||||||
helpHeigh := lipgloss.Height(helpView)
|
helpHeigh := lipgloss.Height(helpView)
|
||||||
|
|
||||||
|
detailsText := fmt.Sprintf("Time to complete: %s | Difficulty: %s", m.TimeToComplete, m.Difficulty)
|
||||||
details := lipgloss.NewStyle().Align(lipgloss.Center).
|
details := lipgloss.NewStyle().Align(lipgloss.Center).
|
||||||
Width(m.width).PaddingBottom(1).Render("Time to complete:", m.TimeToComplete, "Difficulty:", m.Difficulty)
|
Width(m.width).PaddingBottom(1).Render(detailsText)
|
||||||
|
|
||||||
detailsHeight := lipgloss.Height(details)
|
detailsHeight := lipgloss.Height(details)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user