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