standardize info message between lyrics viewer and radios page
This commit is contained in:
@@ -60,18 +60,10 @@ func newRadiosPage(contr *controller.Controller, rp mediaprovider.RadioProvider,
|
|||||||
a.searcher.OnSearched = a.onSearched
|
a.searcher.OnSearched = a.onSearched
|
||||||
a.searcher.Entry.Text = searchText
|
a.searcher.Entry.Text = searchText
|
||||||
|
|
||||||
a.noRadiosMsg = container.NewCenter(
|
a.noRadiosMsg = container.NewCenter(widgets.NewInfoMessage(
|
||||||
container.New(layout.NewCustomPaddedVBoxLayout(-10),
|
"No radio stations available",
|
||||||
container.NewCenter(
|
"Configure your music server to add radio stations",
|
||||||
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.Hide()
|
a.noRadiosMsg.Hide()
|
||||||
|
|
||||||
a.buildContainer()
|
a.buildContainer()
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
type LyricsViewer struct {
|
type LyricsViewer struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
noLyricsLabel widget.Label
|
noLyricsMsg fyne.CanvasObject
|
||||||
viewer *fynelyrics.LyricsViewer
|
viewer *fynelyrics.LyricsViewer
|
||||||
lyrics *mediaprovider.Lyrics
|
lyrics *mediaprovider.Lyrics
|
||||||
nextLyricLine int
|
nextLyricLine int
|
||||||
@@ -27,11 +27,13 @@ type LyricsViewer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewLyricsViewer() *LyricsViewer {
|
func NewLyricsViewer() *LyricsViewer {
|
||||||
l := &LyricsViewer{noLyricsLabel: widget.Label{
|
l := &LyricsViewer{
|
||||||
Text: "Lyrics not available",
|
noLyricsMsg: container.NewCenter(NewInfoMessage(
|
||||||
}, isEmpty: true}
|
"Lyrics not available", "")),
|
||||||
|
isEmpty: true,
|
||||||
|
}
|
||||||
l.ExtendBaseWidget(l)
|
l.ExtendBaseWidget(l)
|
||||||
l.container = container.NewStack(&l.noLyricsLabel)
|
l.container = container.NewStack(l.noLyricsMsg)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +43,7 @@ func (l *LyricsViewer) SetLyrics(lyrics *mediaprovider.Lyrics) {
|
|||||||
l.firstUpdate = true
|
l.firstUpdate = true
|
||||||
if lyrics == nil || len(lyrics.Lines) == 0 {
|
if lyrics == nil || len(lyrics.Lines) == 0 {
|
||||||
if !l.isEmpty {
|
if !l.isEmpty {
|
||||||
l.container.Objects[0] = &l.noLyricsLabel
|
l.container.Objects[0] = l.noLyricsMsg
|
||||||
l.isEmpty = true
|
l.isEmpty = true
|
||||||
l.Refresh()
|
l.Refresh()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user