diff --git a/progress/progress.go b/progress/progress.go index 3f581ea..ef24bf1 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -3,14 +3,10 @@ package progress import ( "strings" - tea "github.com/charmbracelet/bubbletea" "github.com/lucasb-eyer/go-colorful" "github.com/muesli/termenv" ) -// Value is explicit type of, you know, progression. Can be 0.0 < x < 1.0. -type Value float64 - type Model struct { // Left side color of progress bar. By default, it's #00dbde StartColor colorful.Color @@ -21,10 +17,6 @@ type Model struct { // Width of progress bar in symbols. Width int - // Which part of bar need to visualise. Can be 0.0 < Progress < 1.0, if value is bigger or smaller, it'll - // be mapped to this values - Progress float64 - // filament rune of done part of progress bar. it's █ by default FilamentSymbol rune @@ -49,28 +41,8 @@ func NewModel(size int) *Model { } } -func (m *Model) Init() tea.Cmd { - return nil -} - -func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - switch cmd := msg.(type) { - case Value: - if cmd > 1 { - cmd = 1 - } - if cmd < 0 { - cmd = 0 - } - - m.Progress = float64(cmd) - } - - return m, nil -} - -func (m *Model) View() string { - ramp := make([]string, int(float64(m.Width)*m.Progress)) +func (m *Model) View(percent float64) string { + ramp := make([]string, int(float64(m.Width)*percent)) for i := 0; i < len(ramp); i++ { gradientPart := float64(m.Width) if m.FullGradientMode {