add exit mechanicm to each stage
remove types and moved struct to appropriate files
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package taskui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"charm.land/lipgloss/v2"
|
||||
@@ -9,6 +10,23 @@ import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
var ErrUserQuit = errors.New("user quit")
|
||||
|
||||
type TaskDetails struct {
|
||||
Title string
|
||||
Description string
|
||||
TimeToComplete string
|
||||
Difficulty string
|
||||
}
|
||||
|
||||
type TaskModel struct {
|
||||
TaskDetails
|
||||
keys TaskHelpKeys
|
||||
help help.Model
|
||||
width, height int
|
||||
userQuit bool
|
||||
}
|
||||
|
||||
func NewTaskModel(details TaskDetails) TaskModel {
|
||||
return TaskModel{
|
||||
TaskDetails: details,
|
||||
@@ -28,6 +46,7 @@ func (m TaskModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
case tea.KeyMsg:
|
||||
switch {
|
||||
case key.Matches(msg, m.keys.Quit):
|
||||
m.userQuit = true
|
||||
return m, tea.Quit
|
||||
case key.Matches(msg, m.keys.Continue):
|
||||
return m, tea.Quit
|
||||
@@ -70,3 +89,7 @@ func (m TaskModel) View() string {
|
||||
func (m *TaskModel) SetSize(width, height int) {
|
||||
m.width, m.height = width, height
|
||||
}
|
||||
|
||||
func (m TaskModel) GetUserQuit() bool {
|
||||
return m.userQuit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user