From 1fe92d197224ea8293631483a2053a46e701879b Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Mon, 16 Feb 2026 12:17:16 +0100 Subject: [PATCH] add basic survey intro --- cmd/survey/intro.go | 76 ++++++++++++++++++++++++++++++++++++++++++++ cmd/survey/survey.go | 4 +++ 2 files changed, 80 insertions(+) create mode 100644 cmd/survey/intro.go diff --git a/cmd/survey/intro.go b/cmd/survey/intro.go new file mode 100644 index 0000000..1efa2ae --- /dev/null +++ b/cmd/survey/intro.go @@ -0,0 +1,76 @@ +package main + +import ( + "github.com/LazyBachelor/LazyPM/internal/style" + tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/huh" +) + +const ( + IntroTitle = "Welcome to the Task Survey!" + + IntroductionText = `This survey is designed to gather feedback on task management interfaces. +Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes. +By participating, you consent to the collection and use of your data as described in this disclaimer. + +Press any key to continue...` + + Disclaimer = `This survey is designed to gather feedback on task management interfaces. +Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes. +By participating, you consent to the collection and use of your data as described in this disclaimer.` +) + +type introModel struct { + form *huh.Form + width, height int +} + +func newIntroModel() introModel { + return introModel{ + form: huh.NewForm( + huh.NewGroup( + huh.NewNote().Title(IntroTitle).Description(IntroductionText), + ), + huh.NewGroup( + huh.NewNote().Title("Disclaimer").Description(Disclaimer), + ), + ), + } +} + +func (m introModel) Init() tea.Cmd { + m.form.Init() + return nil +} + +func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.KeyMsg: + switch msg.Type { + case tea.KeyEsc, tea.KeyCtrlC: + return m, tea.Quit + } + case tea.WindowSizeMsg: + m.SetSize(msg.Width, msg.Height) + } + + form, cmd := m.form.Update(msg) + if f, ok := form.(*huh.Form); ok { + m.form = f + } + + return m, cmd +} + +func (m introModel) View() string { + return m.form.WithTheme(style.HuhCenterTheme()).View() +} + +func (m introModel) Run() error { + _, err := tea.NewProgram(m, tea.WithAltScreen()).Run() + return err +} + +func (m *introModel) SetSize(width, height int) { + m.width, m.height = width, height +} diff --git a/cmd/survey/survey.go b/cmd/survey/survey.go index 64e36e2..0d9629f 100644 --- a/cmd/survey/survey.go +++ b/cmd/survey/survey.go @@ -13,6 +13,10 @@ import ( func main() { ctx := context.Background() + if err := newIntroModel().Run(); err != nil { + log.Fatalf("Failed to run intro screen: %v\n", err) + } + svc, close, err := initializeServices(ctx) if err != nil { log.Fatalf("Failed to initialize services: %v\n", err)