diff --git a/main.go b/main.go index da7751d..f938547 100644 --- a/main.go +++ b/main.go @@ -49,7 +49,8 @@ type model struct { } func initialModel(fullscreen bool, colorLeft string, colorRight string) model { - inputs := make([]textinput.Model, 3) + numInputs := 3 + inputs := make([]textinput.Model, numInputs) // Set up text input models for interval length, break length, and total intervals for i := range inputs { @@ -120,12 +121,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Move to the next input field m.focusIndex = (m.focusIndex + 1) % len(m.inputs) m.updateFocus() + return m, nil case "shift+tab": // Move to the previous input field m.focusIndex = (m.focusIndex - 1 + len(m.inputs)) % len(m.inputs) m.updateFocus() + return m, nil case "enter": @@ -188,10 +191,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.isFocus = true m.intervalNum++ m.runCommands(m.onIntervalEnd) + if m.intervalNum > m.intervals { // All intervals completed return m, tea.Quit } + m.remaining = m.remaining + m.focusTime m.totalTime = m.focusTime m.state = "Focus"