save last active tab in Now Playing page
This commit is contained in:
+22
-14
@@ -81,6 +81,10 @@ type TracksPageConfig struct {
|
||||
TracklistColumns []string
|
||||
}
|
||||
|
||||
type NowPlayingPageConfig struct {
|
||||
InitialView string
|
||||
}
|
||||
|
||||
type LocalPlaybackConfig struct {
|
||||
AudioDeviceName string
|
||||
AudioExclusive bool
|
||||
@@ -113,20 +117,21 @@ type TranscodingConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Application AppConfig
|
||||
Servers []*ServerConfig
|
||||
AlbumPage AlbumPageConfig
|
||||
AlbumsPage AlbumsPageConfig
|
||||
ArtistPage ArtistPageConfig
|
||||
FavoritesPage FavoritesPageConfig
|
||||
PlaylistPage PlaylistPageConfig
|
||||
PlaylistsPage PlaylistsPageConfig
|
||||
TracksPage TracksPageConfig
|
||||
LocalPlayback LocalPlaybackConfig
|
||||
Scrobbling ScrobbleConfig
|
||||
ReplayGain ReplayGainConfig
|
||||
Transcoding TranscodingConfig
|
||||
Theme ThemeConfig
|
||||
Application AppConfig
|
||||
Servers []*ServerConfig
|
||||
AlbumPage AlbumPageConfig
|
||||
AlbumsPage AlbumsPageConfig
|
||||
ArtistPage ArtistPageConfig
|
||||
FavoritesPage FavoritesPageConfig
|
||||
PlaylistPage PlaylistPageConfig
|
||||
PlaylistsPage PlaylistsPageConfig
|
||||
TracksPage TracksPageConfig
|
||||
NowPlayingConfig NowPlayingPageConfig
|
||||
LocalPlayback LocalPlaybackConfig
|
||||
Scrobbling ScrobbleConfig
|
||||
ReplayGain ReplayGainConfig
|
||||
Transcoding TranscodingConfig
|
||||
Theme ThemeConfig
|
||||
}
|
||||
|
||||
var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
|
||||
@@ -168,6 +173,9 @@ func DefaultConfig(appVersionTag string) *Config {
|
||||
PlaylistsPage: PlaylistsPageConfig{
|
||||
InitialView: "List",
|
||||
},
|
||||
NowPlayingConfig: NowPlayingPageConfig{
|
||||
InitialView: "Play Queue",
|
||||
},
|
||||
TracksPage: TracksPageConfig{
|
||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||
},
|
||||
|
||||
@@ -44,6 +44,7 @@ type NowPlayingPage struct {
|
||||
}
|
||||
|
||||
type nowPlayingPageState struct {
|
||||
conf *backend.NowPlayingPageConfig
|
||||
contr *controller.Controller
|
||||
pool *util.WidgetPool
|
||||
sm *backend.ServerManager
|
||||
@@ -54,6 +55,7 @@ type nowPlayingPageState struct {
|
||||
}
|
||||
|
||||
func NewNowPlayingPage(
|
||||
conf *backend.NowPlayingPageConfig,
|
||||
contr *controller.Controller,
|
||||
pool *util.WidgetPool,
|
||||
sm *backend.ServerManager,
|
||||
@@ -63,7 +65,7 @@ func NewNowPlayingPage(
|
||||
canShare bool,
|
||||
) *NowPlayingPage {
|
||||
a := &NowPlayingPage{nowPlayingPageState: nowPlayingPageState{
|
||||
contr: contr, pool: pool, sm: sm, im: im, pm: pm, canRate: canRate, canShare: canShare,
|
||||
conf: conf, contr: contr, pool: pool, sm: sm, im: im, pm: pm, canRate: canRate, canShare: canShare,
|
||||
}}
|
||||
a.ExtendBaseWidget(a)
|
||||
|
||||
@@ -129,19 +131,28 @@ func NewNowPlayingPage(
|
||||
|
||||
func (a *NowPlayingPage) CreateRenderer() fyne.WidgetRenderer {
|
||||
if a.container == nil {
|
||||
initialTab := 0
|
||||
if a.conf.InitialView == "Lyrics" {
|
||||
initialTab = 1
|
||||
}
|
||||
_ = initialTab
|
||||
paddedLayout := &layouts.PercentPadLayout{
|
||||
LeftRightObjectPercent: .8,
|
||||
TopBottomObjectPercent: .8,
|
||||
}
|
||||
tabs := container.NewAppTabs(
|
||||
container.NewTabItem("Play Queue",
|
||||
container.NewBorder(layout.NewSpacer(), nil, nil, nil, a.queueList)),
|
||||
container.NewTabItem("Lyrics", a.lyricsViewer),
|
||||
)
|
||||
tabs.SelectIndex(initialTab)
|
||||
tabs.OnSelected = func(*container.TabItem) {
|
||||
a.saveSelectedTab(tabs.SelectedIndex())
|
||||
}
|
||||
mainContent := container.NewGridWithColumns(2,
|
||||
container.New(paddedLayout, a.card),
|
||||
container.New(paddedLayout,
|
||||
util.AddHeaderBackground(
|
||||
container.NewAppTabs(
|
||||
container.NewTabItem("Play Queue",
|
||||
container.NewBorder(layout.NewSpacer(), nil, nil, nil, a.queueList)),
|
||||
container.NewTabItem("Lyrics", a.lyricsViewer),
|
||||
))))
|
||||
util.AddHeaderBackground(tabs)))
|
||||
a.container = container.NewStack(
|
||||
mainContent,
|
||||
container.NewVBox(
|
||||
@@ -224,7 +235,7 @@ func (s *nowPlayingPageState) Restore() Page {
|
||||
page.Reload()
|
||||
return page
|
||||
}
|
||||
return NewNowPlayingPage(s.contr, s.pool, s.sm, s.im, s.pm, s.canRate, s.canShare)
|
||||
return NewNowPlayingPage(s.conf, s.contr, s.pool, s.sm, s.im, s.pm, s.canRate, s.canShare)
|
||||
}
|
||||
|
||||
var _ CanShowPlayTime = (*NowPlayingPage)(nil)
|
||||
@@ -256,6 +267,17 @@ func (a *NowPlayingPage) doSetNewTrackOrder(trackIDs []string, op sharedutil.Tra
|
||||
a.pm.UpdatePlayQueue(newTracks)
|
||||
}
|
||||
|
||||
func (a *NowPlayingPage) saveSelectedTab(tabNum int) {
|
||||
var tabName string
|
||||
switch tabNum {
|
||||
case 0:
|
||||
tabName = "Play Queue"
|
||||
case 1:
|
||||
tabName = "Lyrics"
|
||||
}
|
||||
a.conf.InitialView = tabName
|
||||
}
|
||||
|
||||
func (a *NowPlayingPage) formatStatusLine() {
|
||||
curPlayer := a.pm.CurrentPlayer()
|
||||
playerStats := curPlayer.GetStatus()
|
||||
|
||||
@@ -48,7 +48,7 @@ func (r Router) CreatePage(rte controller.Route) Page {
|
||||
case controller.Genres:
|
||||
return NewGenresPage(r.Controller, r.App.ServerManager.Server)
|
||||
case controller.NowPlaying:
|
||||
return NewNowPlayingPage(r.Controller, r.widgetPool, r.App.ServerManager, r.App.ImageManager, r.App.PlaybackManager, canRate, canShare)
|
||||
return NewNowPlayingPage(&r.App.Config.NowPlayingConfig, r.Controller, r.widgetPool, r.App.ServerManager, r.App.ImageManager, r.App.PlaybackManager, canRate, canShare)
|
||||
case controller.Playlist:
|
||||
return NewPlaylistPage(rte.Arg, &r.App.Config.PlaylistPage, r.widgetPool, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.ImageManager)
|
||||
case controller.Playlists:
|
||||
|
||||
@@ -50,7 +50,7 @@ func NewNowPlayingCard() *NowPlayingCard {
|
||||
n.albumName.Truncation = fyne.TextTruncateEllipsis
|
||||
n.trackName.Truncation = fyne.TextTruncateEllipsis
|
||||
n.trackName.TextStyle.Bold = true
|
||||
n.cover.SetMinSize(fyne.NewSize(85, 85))
|
||||
n.cover.SetMinSize(fyne.NewSquareSize(85))
|
||||
n.cover.FillMode = canvas.ImageFillContain
|
||||
n.cover.ScaleMode = canvas.ImageScaleFastest
|
||||
n.cover.Hidden = true
|
||||
|
||||
Reference in New Issue
Block a user