Style forms; [WIP] Draw table

This commit is contained in:
Martin Pander
2024-05-21 16:52:18 +02:00
parent d960f1f113
commit fce35f0fc7
9 changed files with 517 additions and 45 deletions

View File

@ -35,9 +35,12 @@ func NewContextPickerPage(common *common.Common) *ContextPickerPage {
selected := common.TW.GetActiveContext().Name
options := make([]string, 0)
for _, c := range p.contexts {
options = append(options, c.Name)
if c.Name != "none" {
options = append(options, c.Name)
}
}
slices.Sort(options)
options = append([]string{"(none)"}, options...)
p.form = huh.NewForm(
huh.NewGroup(
@ -50,7 +53,8 @@ func NewContextPickerPage(common *common.Common) *ContextPickerPage {
),
).
WithShowHelp(false).
WithShowErrors(true)
WithShowErrors(true).
WithTheme(p.common.Styles.Form)
return p
}
@ -99,7 +103,11 @@ func (p *ContextPickerPage) View() string {
}
func (p *ContextPickerPage) updateContextCmd() tea.Msg {
return UpdateContextMsg(p.common.TW.GetContext(p.form.GetString("context")))
context := p.form.GetString("context")
if context == "(none)" {
context = "none"
}
return UpdateContextMsg(p.common.TW.GetContext(context))
}
type UpdateContextMsg *taskwarrior.Context