From d6c5530b35743d1a2f153f942f508ca0768870af Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Thu, 24 Oct 2024 12:02:39 -0400 Subject: more than one slider WIP --- internal/slider/slider.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'internal/slider') diff --git a/internal/slider/slider.go b/internal/slider/slider.go index 0c0a89e..e882a29 100644 --- a/internal/slider/slider.go +++ b/internal/slider/slider.go @@ -51,8 +51,13 @@ func (s Slider) Dec(val int) (tea.Model, tea.Cmd) { return s.Set(s.val - val) } -func (s Slider) View() string { - return s.bar.View() + fmt.Sprintf(" (%d)", s.val) +func (s Slider) Val() int { + return s.val +} + +func New(name string, v int, maxV int, opt ...progress.Option) *Slider { + opt = append(opt, progress.WithoutPercentage()) + return &Slider{name: name, max: maxV, val: v, options: opt} } func (s Slider) Animate(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -66,9 +71,8 @@ func (s Slider) Init() tea.Cmd { return s.bar.Init() } -func New(name string, v int, maxV int, opt ...progress.Option) *Slider { - opt = append(opt, progress.WithoutPercentage()) - return &Slider{name: name, max: maxV, val: v, options: opt} +func (s Slider) View() string { + return s.bar.View() + fmt.Sprintf(" (%d)", s.val) } func (s Slider) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -103,3 +107,11 @@ func (s Slider) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } // }}} +// Implement the list.Item interface {{{ + +func (s Slider) FilterValue() string { + // Sliders shouldn't be filtered + return "" +} + +// }}} -- cgit v1.2.3