Fix pickers; Add new select option
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"github.com/charmbracelet/bubbles/key"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/huh"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
type ContextPickerPage struct {
|
||||
@ -40,18 +41,32 @@ func NewContextPickerPage(common *common.Common) *ContextPickerPage {
|
||||
Options(huh.NewOptions(options...)...).
|
||||
Title("Contexts").
|
||||
Description("Choose a context").
|
||||
Value(&selected),
|
||||
Value(&selected).
|
||||
WithTheme(common.Styles.Form),
|
||||
),
|
||||
).
|
||||
WithShowHelp(false).
|
||||
WithShowErrors(true).
|
||||
WithTheme(p.common.Styles.Form)
|
||||
WithShowErrors(true)
|
||||
|
||||
p.SetSize(common.Width(), common.Height())
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *ContextPickerPage) SetSize(width, height int) {
|
||||
p.common.SetSize(width, height)
|
||||
|
||||
if width >= 20 {
|
||||
p.form = p.form.WithWidth(20)
|
||||
} else {
|
||||
p.form = p.form.WithWidth(width)
|
||||
}
|
||||
|
||||
if height >= 30 {
|
||||
p.form = p.form.WithHeight(30)
|
||||
} else {
|
||||
p.form = p.form.WithHeight(height)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ContextPickerPage) Init() tea.Cmd {
|
||||
@ -96,7 +111,13 @@ func (p *ContextPickerPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
func (p *ContextPickerPage) View() string {
|
||||
return p.common.Styles.Base.Render(p.form.View())
|
||||
return lipgloss.Place(
|
||||
p.common.Width(),
|
||||
p.common.Height(),
|
||||
lipgloss.Center,
|
||||
lipgloss.Center,
|
||||
p.common.Styles.Base.Render(p.form.View()),
|
||||
)
|
||||
}
|
||||
|
||||
func (p *ContextPickerPage) updateContextCmd() tea.Msg {
|
||||
|
||||
Reference in New Issue
Block a user