use separate loading indicator for Lyrics and Related tabs
This commit is contained in:
@@ -58,7 +58,8 @@ type NowPlayingPage struct {
|
|||||||
card *widgets.LargeNowPlayingCard
|
card *widgets.LargeNowPlayingCard
|
||||||
statusLabel *widget.Label
|
statusLabel *widget.Label
|
||||||
tabs *container.AppTabs
|
tabs *container.AppTabs
|
||||||
tabLoading *widgets.LoadingDots
|
lyricsLoading *widgets.LoadingDots
|
||||||
|
relatedLoading *widgets.LoadingDots
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
|
|
||||||
// cancel funcs for background fetch tasks
|
// cancel funcs for background fetch tasks
|
||||||
@@ -190,11 +191,17 @@ func (a *NowPlayingPage) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
LeftRightObjectPercent: .8,
|
LeftRightObjectPercent: .8,
|
||||||
TopBottomObjectPercent: .8,
|
TopBottomObjectPercent: .8,
|
||||||
}
|
}
|
||||||
|
a.lyricsLoading = widgets.NewLoadingDots()
|
||||||
|
a.relatedLoading = widgets.NewLoadingDots()
|
||||||
a.tabs = container.NewAppTabs(
|
a.tabs = container.NewAppTabs(
|
||||||
container.NewTabItem("Play Queue",
|
container.NewTabItem("Play Queue",
|
||||||
container.NewBorder(layout.NewSpacer(), nil, nil, nil, a.queueList)),
|
container.NewBorder(layout.NewSpacer(), nil, nil, nil, a.queueList)),
|
||||||
container.NewTabItem("Lyrics", a.lyricsViewer),
|
container.NewTabItem("Lyrics", container.NewStack(
|
||||||
container.NewTabItem("Related", a.relatedList),
|
a.lyricsViewer,
|
||||||
|
container.NewCenter(a.lyricsLoading))),
|
||||||
|
container.NewTabItem("Related", container.NewStack(
|
||||||
|
a.relatedList,
|
||||||
|
container.NewCenter(a.relatedLoading))),
|
||||||
)
|
)
|
||||||
a.tabs.SelectIndex(initialTab)
|
a.tabs.SelectIndex(initialTab)
|
||||||
a.tabs.OnSelected = func(*container.TabItem) {
|
a.tabs.OnSelected = func(*container.TabItem) {
|
||||||
@@ -206,7 +213,6 @@ func (a *NowPlayingPage) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
a.updateRelatedList()
|
a.updateRelatedList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a.tabLoading = widgets.NewLoadingDots()
|
|
||||||
if initialTab == 1 /*lyrics*/ {
|
if initialTab == 1 /*lyrics*/ {
|
||||||
a.updateLyrics()
|
a.updateLyrics()
|
||||||
} else if initialTab == 2 /*related*/ {
|
} else if initialTab == 2 /*related*/ {
|
||||||
@@ -218,10 +224,8 @@ func (a *NowPlayingPage) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
mainContent := container.NewGridWithColumns(2,
|
mainContent := container.NewGridWithColumns(2,
|
||||||
container.New(paddedLayout, a.card),
|
container.New(paddedLayout, a.card),
|
||||||
container.New(paddedLayout,
|
container.New(paddedLayout,
|
||||||
container.NewStack(
|
|
||||||
util.AddHeaderBackgroundWithColorName(
|
util.AddHeaderBackgroundWithColorName(
|
||||||
a.tabs, myTheme.ColorNameNowPlayingPanel),
|
a.tabs, myTheme.ColorNameNowPlayingPanel)))
|
||||||
container.NewCenter(a.tabLoading))))
|
|
||||||
a.container = container.NewStack(
|
a.container = container.NewStack(
|
||||||
a.background,
|
a.background,
|
||||||
mainContent,
|
mainContent,
|
||||||
@@ -325,7 +329,7 @@ func (a *NowPlayingPage) updateLyrics() {
|
|||||||
a.curLyricsID = a.nowPlayingID
|
a.curLyricsID = a.nowPlayingID
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
a.lyricFetchCancel = cancel
|
a.lyricFetchCancel = cancel
|
||||||
a.tabLoading.Start()
|
a.lyricsLoading.Start()
|
||||||
// set the widget to an empty (not nil) lyric during fetch
|
// set the widget to an empty (not nil) lyric during fetch
|
||||||
// to keep it from showing "Lyrics not available"
|
// to keep it from showing "Lyrics not available"
|
||||||
a.lyricsViewer.SetLyrics(&mediaprovider.Lyrics{Synced: true,
|
a.lyricsViewer.SetLyrics(&mediaprovider.Lyrics{Synced: true,
|
||||||
@@ -353,7 +357,7 @@ func (a *NowPlayingPage) fetchLyrics(ctx context.Context, song *mediaprovider.Tr
|
|||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
a.lyricLock.Lock()
|
a.lyricLock.Lock()
|
||||||
a.tabLoading.Stop()
|
a.lyricsLoading.Stop()
|
||||||
a.lyricsViewer.SetLyrics(lyrics)
|
a.lyricsViewer.SetLyrics(lyrics)
|
||||||
if lyrics != nil {
|
if lyrics != nil {
|
||||||
a.lyricsViewer.OnSeeked(a.lastPlayPos)
|
a.lyricsViewer.OnSeeked(a.lastPlayPos)
|
||||||
@@ -379,7 +383,7 @@ func (a *NowPlayingPage) updateRelatedList() {
|
|||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
a.relatedFetchCancel = cancel
|
a.relatedFetchCancel = cancel
|
||||||
a.tabLoading.Start()
|
a.relatedLoading.Start()
|
||||||
a.relatedList.SetTracks(nil)
|
a.relatedList.SetTracks(nil)
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
related, err := a.mp.GetSongRadio(a.nowPlayingID, 30)
|
related, err := a.mp.GetSongRadio(a.nowPlayingID, 30)
|
||||||
@@ -393,7 +397,7 @@ func (a *NowPlayingPage) updateRelatedList() {
|
|||||||
a.relatedLock.Lock()
|
a.relatedLock.Lock()
|
||||||
a.related = related
|
a.related = related
|
||||||
a.relatedList.SetTracks(a.related)
|
a.relatedList.SetTracks(a.related)
|
||||||
a.tabLoading.Stop()
|
a.relatedLoading.Stop()
|
||||||
a.relatedLock.Unlock()
|
a.relatedLock.Unlock()
|
||||||
}
|
}
|
||||||
}(ctx)
|
}(ctx)
|
||||||
|
|||||||
Reference in New Issue
Block a user