diff --git a/ui/browsing/radiospage.go b/ui/browsing/radiospage.go index cdcbf7b..82b6f14 100644 --- a/ui/browsing/radiospage.go +++ b/ui/browsing/radiospage.go @@ -60,18 +60,10 @@ func newRadiosPage(contr *controller.Controller, rp mediaprovider.RadioProvider, a.searcher.OnSearched = a.onSearched a.searcher.Entry.Text = searchText - a.noRadiosMsg = container.NewCenter( - container.New(layout.NewCustomPaddedVBoxLayout(-10), - container.NewCenter( - container.NewBorder(nil, nil, - widget.NewIcon(theme.InfoIcon()), nil, - widget.NewRichText(&widget.TextSegment{ - Text: "No radio stations available", - Style: widget.RichTextStyleSubHeading, - }))), - widget.NewLabel("Configure your music server to add radio stations"), - ), - ) + a.noRadiosMsg = container.NewCenter(widgets.NewInfoMessage( + "No radio stations available", + "Configure your music server to add radio stations", + )) a.noRadiosMsg.Hide() a.buildContainer() diff --git a/ui/widgets/infomessage.go b/ui/widgets/infomessage.go new file mode 100644 index 0000000..b49803f --- /dev/null +++ b/ui/widgets/infomessage.go @@ -0,0 +1,25 @@ +package widgets + +import ( + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/layout" + "fyne.io/fyne/v2/theme" + "fyne.io/fyne/v2/widget" +) + +func NewInfoMessage(title, subtitle string) fyne.CanvasObject { + c := container.New(layout.NewCustomPaddedVBoxLayout(-10), + container.NewCenter( + container.NewBorder(nil, nil, + widget.NewIcon(theme.InfoIcon()), nil, + widget.NewRichText(&widget.TextSegment{ + Text: title, + Style: widget.RichTextStyleSubHeading, + }))), + ) + if subtitle != "" { + c.Add(container.NewCenter(widget.NewLabel(subtitle))) + } + return c +} diff --git a/ui/widgets/lyricsviewer.go b/ui/widgets/lyricsviewer.go index 90fb8a7..3c5d98c 100644 --- a/ui/widgets/lyricsviewer.go +++ b/ui/widgets/lyricsviewer.go @@ -12,7 +12,7 @@ import ( type LyricsViewer struct { widget.BaseWidget - noLyricsLabel widget.Label + noLyricsMsg fyne.CanvasObject viewer *fynelyrics.LyricsViewer lyrics *mediaprovider.Lyrics nextLyricLine int @@ -27,11 +27,13 @@ type LyricsViewer struct { } func NewLyricsViewer() *LyricsViewer { - l := &LyricsViewer{noLyricsLabel: widget.Label{ - Text: "Lyrics not available", - }, isEmpty: true} + l := &LyricsViewer{ + noLyricsMsg: container.NewCenter(NewInfoMessage( + "Lyrics not available", "")), + isEmpty: true, + } l.ExtendBaseWidget(l) - l.container = container.NewStack(&l.noLyricsLabel) + l.container = container.NewStack(l.noLyricsMsg) return l } @@ -41,7 +43,7 @@ func (l *LyricsViewer) SetLyrics(lyrics *mediaprovider.Lyrics) { l.firstUpdate = true if lyrics == nil || len(lyrics.Lines) == 0 { if !l.isEmpty { - l.container.Objects[0] = &l.noLyricsLabel + l.container.Objects[0] = l.noLyricsMsg l.isEmpty = true l.Refresh() }