mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add a global Redraw method for TextWidget
Partially addresses #429, by centralizing widget drawing
This commit is contained in:
@@ -21,7 +21,6 @@ type Widget struct {
|
||||
wtf.KeyboardWidget
|
||||
wtf.TextWidget
|
||||
|
||||
app *tview.Application
|
||||
settings *Settings
|
||||
spotigopher.Info
|
||||
spotigopher.SpotifyClient
|
||||
@@ -38,7 +37,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *
|
||||
Info: spotigopher.Info{},
|
||||
SpotifyClient: spotifyClient,
|
||||
|
||||
app: app,
|
||||
settings: settings,
|
||||
}
|
||||
|
||||
@@ -63,19 +61,18 @@ func (w *Widget) refreshSpotifyInfos() error {
|
||||
}
|
||||
|
||||
func (w *Widget) Refresh() {
|
||||
w.app.QueueUpdateDraw(func() {
|
||||
w.render()
|
||||
})
|
||||
w.render()
|
||||
}
|
||||
|
||||
func (w *Widget) render() {
|
||||
err := w.refreshSpotifyInfos()
|
||||
w.View.Clear()
|
||||
var content string
|
||||
if err != nil {
|
||||
w.TextWidget.View.SetText(err.Error())
|
||||
content = err.Error()
|
||||
} else {
|
||||
w.TextWidget.View.SetText(w.createOutput())
|
||||
content = w.createOutput()
|
||||
}
|
||||
w.Redraw(w.CommonSettings.Title, content, true)
|
||||
}
|
||||
|
||||
func (w *Widget) createOutput() string {
|
||||
|
||||
Reference in New Issue
Block a user