1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Convert the bulk of modules over to RedrawFunc

This commit is contained in:
Sean Smith
2019-08-26 23:07:02 -04:00
parent 51e4325f0b
commit 3a716bcf9a
25 changed files with 214 additions and 224 deletions

View File

@@ -51,28 +51,23 @@ func (w *Widget) refreshSpotifyInfos() error {
}
func (w *Widget) Refresh() {
w.render()
w.RedrawFunc(w.createOutput)
}
func (widget *Widget) HelpText() string {
return widget.KeyboardWidget.HelpText()
}
func (w *Widget) render() {
err := w.refreshSpotifyInfos()
func (w *Widget) createOutput() (string, string, bool) {
var content string
err := w.refreshSpotifyInfos()
if err != nil {
content = err.Error()
} else {
content = w.createOutput()
content = utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]Title:[white] %v\n ", w.Info.Title), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]Artist:[white] %v\n", w.Info.Artist), w.CommonSettings().Width)
content += utils.CenterText(fmt.Sprintf("[green]%v:[white] %v\n", w.Info.TrackNumber, w.Info.Album), w.CommonSettings().Width)
}
w.Redraw(w.CommonSettings().Title, content, true)
}
func (w *Widget) createOutput() string {
output := utils.CenterText(fmt.Sprintf("[green]Now %v [white]\n", w.Info.Status), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Title:[white] %v\n ", w.Info.Title), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]Artist:[white] %v\n", w.Info.Artist), w.CommonSettings().Width)
output += utils.CenterText(fmt.Sprintf("[green]%v:[white] %v\n", w.Info.TrackNumber, w.Info.Album), w.CommonSettings().Width)
return output
return w.CommonSettings().Title, content, true
}