add feedback to tui
This commit is contained in:
@@ -4,13 +4,17 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/service"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/tui/views"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type TUIConfig = service.Config
|
||||
|
||||
type Tui struct{}
|
||||
type Tui struct {
|
||||
feedbackChan chan task.ValidationFeedback
|
||||
quitChan chan bool
|
||||
}
|
||||
|
||||
func NewTui() *Tui {
|
||||
return &Tui{}
|
||||
@@ -24,10 +28,24 @@ func (t *Tui) Run(ctx context.Context, config TUIConfig) error {
|
||||
|
||||
defer cleanup()
|
||||
|
||||
if _, err := tea.NewProgram(views.NewDashboardView(svc),
|
||||
tea.WithAltScreen(), tea.WithMouseAllMotion()).Run(); err != nil {
|
||||
p := tea.NewProgram(views.NewDashboardView(svc, t.feedbackChan, t.quitChan),
|
||||
tea.WithAltScreen(), tea.WithMouseAllMotion())
|
||||
|
||||
if t.quitChan != nil {
|
||||
go func() {
|
||||
<-t.quitChan
|
||||
p.Quit()
|
||||
}()
|
||||
}
|
||||
|
||||
if _, err := p.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Tui) SetChannels(feedbackChan chan task.ValidationFeedback, quitChan chan bool) {
|
||||
t.feedbackChan = feedbackChan
|
||||
t.quitChan = quitChan
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user