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.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()
|
||||
|
||||
@@ -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 {
|
||||
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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user