make tracks page show now playing + tracklist now playing refactor
This commit is contained in:
@@ -3,6 +3,7 @@ package browsing
|
||||
import (
|
||||
"supersonic/backend"
|
||||
"supersonic/res"
|
||||
"supersonic/sharedutil"
|
||||
"supersonic/ui/controller"
|
||||
"supersonic/ui/layouts"
|
||||
"supersonic/ui/widgets"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/dweymouth/go-subsonic/subsonic"
|
||||
)
|
||||
|
||||
type TracksPage struct {
|
||||
@@ -18,6 +20,8 @@ type TracksPage struct {
|
||||
|
||||
tracksPageState
|
||||
|
||||
nowPlayingID string
|
||||
|
||||
title *widget.RichText
|
||||
searcher *widgets.Searcher
|
||||
tracklist *widgets.Tracklist
|
||||
@@ -71,6 +75,19 @@ func (t *TracksPage) Reload() {
|
||||
t.loader = widgets.NewTracklistLoader(t.tracklist, iter)
|
||||
}
|
||||
|
||||
func (t *TracksPage) OnSongChange(track *subsonic.Child, lastScrobbledIfAny *subsonic.Child) {
|
||||
t.nowPlayingID = sharedutil.TrackIDOrEmptyStr(track)
|
||||
t.tracklist.SetNowPlaying(t.nowPlayingID)
|
||||
if t.searchTracklist != nil {
|
||||
t.searchTracklist.SetNowPlaying(t.nowPlayingID)
|
||||
}
|
||||
playedID := sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny)
|
||||
t.tracklist.IncrementPlayCount(playedID)
|
||||
if t.searchTracklist != nil {
|
||||
t.searchTracklist.IncrementPlayCount(playedID)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TracksPage) OnSearched(query string) {
|
||||
t.searchText = query
|
||||
if query == "" {
|
||||
@@ -89,6 +106,7 @@ func (t *TracksPage) doSearch(query string) {
|
||||
t.searchTracklist = widgets.NewTracklist(nil)
|
||||
t.searchTracklist.AutoNumber = true
|
||||
t.searchTracklist.SetVisibleColumns(t.conf.TracklistColumns)
|
||||
t.searchTracklist.SetNowPlaying(t.nowPlayingID)
|
||||
t.contr.ConnectTracklistActions(t.searchTracklist)
|
||||
} else {
|
||||
t.searchTracklist.Clear()
|
||||
|
||||
Reference in New Issue
Block a user