set state properly when reusing NowPlayingPage in constructor
This commit is contained in:
@@ -86,13 +86,15 @@ func NewNowPlayingPage(
|
|||||||
canShare bool,
|
canShare bool,
|
||||||
lrcLibEnabled bool,
|
lrcLibEnabled bool,
|
||||||
) *NowPlayingPage {
|
) *NowPlayingPage {
|
||||||
|
state := nowPlayingPageState{
|
||||||
|
conf: conf, contr: contr, pool: pool, sm: sm, im: im, pm: pm, mp: mp, canRate: canRate, canShare: canShare, lrcLib: lrcLibEnabled,
|
||||||
|
}
|
||||||
if page, ok := pool.Obtain(util.WidgetTypeNowPlayingPage).(*NowPlayingPage); ok && page != nil {
|
if page, ok := pool.Obtain(util.WidgetTypeNowPlayingPage).(*NowPlayingPage); ok && page != nil {
|
||||||
|
page.nowPlayingPageState = state
|
||||||
page.Reload()
|
page.Reload()
|
||||||
return page
|
return page
|
||||||
}
|
}
|
||||||
a := &NowPlayingPage{nowPlayingPageState: nowPlayingPageState{
|
a := &NowPlayingPage{nowPlayingPageState: state}
|
||||||
conf: conf, contr: contr, pool: pool, sm: sm, im: im, pm: pm, mp: mp, canRate: canRate, canShare: canShare, lrcLib: lrcLibEnabled,
|
|
||||||
}}
|
|
||||||
a.ExtendBaseWidget(a)
|
a.ExtendBaseWidget(a)
|
||||||
|
|
||||||
pm.OnPaused(a.formatStatusLine)
|
pm.OnPaused(a.formatStatusLine)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (l *LyricsViewer) SetLyrics(lyrics *mediaprovider.Lyrics) {
|
|||||||
|
|
||||||
if l.viewer == nil {
|
if l.viewer == nil {
|
||||||
l.viewer = fynelyrics.NewLyricsViewer()
|
l.viewer = fynelyrics.NewLyricsViewer()
|
||||||
l.viewer.ActiveLyricPosition = fynelyrics.ActiveLyricPositionMiddle
|
l.viewer.ActiveLyricPosition = fynelyrics.ActiveLyricPositionUpperMiddle
|
||||||
l.viewer.InactiveLyricColorName = theme.ColorNameInactiveLyric
|
l.viewer.InactiveLyricColorName = theme.ColorNameInactiveLyric
|
||||||
}
|
}
|
||||||
lines := make([]string, len(lyrics.Lines))
|
lines := make([]string, len(lyrics.Lines))
|
||||||
|
|||||||
Reference in New Issue
Block a user