more work on artist list page
This commit is contained in:
+22
-22
File diff suppressed because one or more lines are too long
+22
-22
@@ -1,24 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
fyne bundle -package res icons/disc.png > bundled.go
|
fyne bundle -package res -prefix Res icons/disc.png > bundled.go
|
||||||
fyne bundle -append icons/disc-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/disc-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/headphones.png >> bundled.go
|
fyne bundle -append -prefix Res icons/headphones.png >> bundled.go
|
||||||
fyne bundle -append icons/headphones-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/headphones-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/heart-filled.png >> bundled.go
|
fyne bundle -append -prefix Res icons/heart-filled.png >> bundled.go
|
||||||
fyne bundle -append icons/heart-filled-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/heart-filled-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/heart-outline.png >> bundled.go
|
fyne bundle -append -prefix Res icons/heart-outline.png >> bundled.go
|
||||||
fyne bundle -append icons/heart-outline-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/heart-outline-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/musicnotes.png >> bundled.go
|
fyne bundle -append -prefix Res icons/musicnotes.png >> bundled.go
|
||||||
fyne bundle -append icons/musicnotes-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/musicnotes-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/people.png >> bundled.go
|
fyne bundle -append -prefix Res icons/people.png >> bundled.go
|
||||||
fyne bundle -append icons/people-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/people-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/playlist.png >> bundled.go
|
fyne bundle -append -prefix Res icons/playlist.png >> bundled.go
|
||||||
fyne bundle -append icons/playlist-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/playlist-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/podcast.png >> bundled.go
|
fyne bundle -append -prefix Res icons/podcast.png >> bundled.go
|
||||||
fyne bundle -append icons/podcast-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/podcast-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/star-filled.png >> bundled.go
|
fyne bundle -append -prefix Res icons/star-filled.png >> bundled.go
|
||||||
fyne bundle -append icons/star-filled-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/star-filled-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/star-outline.png >> bundled.go
|
fyne bundle -append -prefix Res icons/star-outline.png >> bundled.go
|
||||||
fyne bundle -append icons/star-outline-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/star-outline-invert.png >> bundled.go
|
||||||
fyne bundle -append icons/theatermasks.png >> bundled.go
|
fyne bundle -append -prefix Res icons/theatermasks.png >> bundled.go
|
||||||
fyne bundle -append icons/theatermasks-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/theatermasks-invert.png >> bundled.go
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ func NewArtistsPage(sm *backend.ServerManager, nav func(Route)) *ArtistsPage {
|
|||||||
a.list.ShowAlbumCount = true
|
a.list.ShowAlbumCount = true
|
||||||
a.list.ShowTrackCount = false
|
a.list.ShowTrackCount = false
|
||||||
a.buildContainer()
|
a.buildContainer()
|
||||||
|
go a.loadAsync()
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +47,31 @@ func (a *ArtistsPage) loadAsync() {
|
|||||||
log.Printf("error loading artists: %v", err.Error())
|
log.Printf("error loading artists: %v", err.Error())
|
||||||
}
|
}
|
||||||
a.list.Items = a.buildListModel(artists)
|
a.list.Items = a.buildListModel(artists)
|
||||||
a.list.Refresh()
|
a.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ArtistsPage) Route() Route {
|
||||||
|
return ArtistsRoute()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ArtistsPage) Reload() {
|
||||||
|
go a.loadAsync()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ArtistsPage) Save() SavedPage {
|
||||||
|
return &savedArtistsPage{
|
||||||
|
sm: a.sm,
|
||||||
|
nav: a.nav,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type savedArtistsPage struct {
|
||||||
|
sm *backend.ServerManager
|
||||||
|
nav func(Route)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *savedArtistsPage) Restore() Page {
|
||||||
|
return NewArtistsPage(s.sm, s.nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistsPage) buildListModel(artists *subsonic.ArtistsID3) []widgets.ArtistGenrePlaylistItemModel {
|
func (a *ArtistsPage) buildListModel(artists *subsonic.ArtistsID3) []widgets.ArtistGenrePlaylistItemModel {
|
||||||
|
|||||||
@@ -38,26 +38,22 @@ type BrowsingPane struct {
|
|||||||
|
|
||||||
app *backend.App
|
app *backend.App
|
||||||
|
|
||||||
// Invoked when the home button is clicked
|
|
||||||
OnGoHome func()
|
|
||||||
|
|
||||||
curPage Page
|
curPage Page
|
||||||
|
|
||||||
home *widget.Button
|
|
||||||
forward *widget.Button
|
forward *widget.Button
|
||||||
back *widget.Button
|
back *widget.Button
|
||||||
reload *widget.Button
|
reload *widget.Button
|
||||||
history []SavedPage
|
history []SavedPage
|
||||||
historyIdx int
|
historyIdx int
|
||||||
|
|
||||||
pageContainer *fyne.Container
|
navBtnsContainer *fyne.Container
|
||||||
container *fyne.Container
|
pageContainer *fyne.Container
|
||||||
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
||||||
b := &BrowsingPane{app: app}
|
b := &BrowsingPane{app: app}
|
||||||
b.ExtendBaseWidget(b)
|
b.ExtendBaseWidget(b)
|
||||||
b.home = widget.NewButtonWithIcon("", theme.HomeIcon(), b.goHome)
|
|
||||||
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
|
b.back = widget.NewButtonWithIcon("", theme.NavigateBackIcon(), b.GoBack)
|
||||||
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
|
b.forward = widget.NewButtonWithIcon("", theme.NavigateNextIcon(), b.GoForward)
|
||||||
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
|
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
|
||||||
@@ -65,8 +61,9 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane {
|
|||||||
b.pageContainer = container.NewMax(
|
b.pageContainer = container.NewMax(
|
||||||
canvas.NewRectangle(color.RGBA{R: 24, G: 24, B: 24, A: 255}),
|
canvas.NewRectangle(color.RGBA{R: 24, G: 24, B: 24, A: 255}),
|
||||||
layout.NewSpacer())
|
layout.NewSpacer())
|
||||||
|
b.navBtnsContainer = container.NewHBox()
|
||||||
b.container = container.NewBorder(
|
b.container = container.NewBorder(
|
||||||
container.NewHBox(b.home, b.back, b.forward, b.reload),
|
container.NewHBox(b.back, b.forward, b.reload, layout.NewSpacer(), b.navBtnsContainer, layout.NewSpacer()),
|
||||||
nil, nil, nil, b.pageContainer)
|
nil, nil, nil, b.pageContainer)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@@ -78,6 +75,10 @@ func (b *BrowsingPane) SetPage(p Page) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *BrowsingPane) AddNavigationButton(iconRes fyne.Resource, action func()) {
|
||||||
|
b.navBtnsContainer.Add(widget.NewButtonWithIcon("", iconRes, action))
|
||||||
|
}
|
||||||
|
|
||||||
func (b *BrowsingPane) doSetPage(p Page) bool {
|
func (b *BrowsingPane) doSetPage(p Page) bool {
|
||||||
if b.curPage != nil && b.curPage.Route() == p.Route() {
|
if b.curPage != nil && b.curPage.Route() == p.Route() {
|
||||||
return false
|
return false
|
||||||
@@ -121,12 +122,6 @@ func (b *BrowsingPane) addPageToHistory(p Page, truncate bool) {
|
|||||||
b.historyIdx++
|
b.historyIdx++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BrowsingPane) goHome() {
|
|
||||||
if b.OnGoHome != nil {
|
|
||||||
b.OnGoHome()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BrowsingPane) GoBack() {
|
func (b *BrowsingPane) GoBack() {
|
||||||
if b.historyIdx > 0 {
|
if b.historyIdx > 0 {
|
||||||
b.addPageToHistory(b.curPage, false)
|
b.addPageToHistory(b.curPage, false)
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ func GenreRoute(genre string) Route {
|
|||||||
return Route{Page: Genre, Arg: genre}
|
return Route{Page: Genre, Arg: genre}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ArtistsRoute() Route {
|
||||||
|
return Route{Page: Artists}
|
||||||
|
}
|
||||||
|
|
||||||
type NavigationHandler interface {
|
type NavigationHandler interface {
|
||||||
SetPage(Page)
|
SetPage(Page)
|
||||||
}
|
}
|
||||||
@@ -63,6 +67,8 @@ func (r Router) CreatePage(rte Route) Page {
|
|||||||
return NewAlbumsPage("Albums", rte.Arg, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
return NewAlbumsPage("Albums", rte.Arg, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
||||||
case Artist:
|
case Artist:
|
||||||
return NewArtistPage(rte.Arg, r.App.ServerManager, r.App.ImageManager, r.OpenRoute)
|
return NewArtistPage(rte.Arg, r.App.ServerManager, r.App.ImageManager, r.OpenRoute)
|
||||||
|
case Artists:
|
||||||
|
return NewArtistsPage(r.App.ServerManager, r.OpenRoute)
|
||||||
case Genre:
|
case Genre:
|
||||||
return NewGenrePage(rte.Arg, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
return NewGenrePage(rte.Arg, r.App.LibraryManager, r.App.ImageManager, r.OpenRoute)
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -2,6 +2,7 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
|
"supersonic/res"
|
||||||
"supersonic/ui/browsing"
|
"supersonic/ui/browsing"
|
||||||
"supersonic/ui/widgets"
|
"supersonic/ui/widgets"
|
||||||
|
|
||||||
@@ -32,9 +33,6 @@ func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App) MainWindo
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Router = browsing.NewRouter(app, m.BrowsingPane)
|
m.Router = browsing.NewRouter(app, m.BrowsingPane)
|
||||||
m.BrowsingPane.OnGoHome = func() {
|
|
||||||
m.Router.OpenRoute(HomePage)
|
|
||||||
}
|
|
||||||
m.BottomPanel = NewBottomPanel(app.Player, m.Router.OpenRoute)
|
m.BottomPanel = NewBottomPanel(app.Player, m.Router.OpenRoute)
|
||||||
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
m.BottomPanel.SetPlaybackManager(app.PlaybackManager)
|
||||||
m.BottomPanel.ImageManager = app.ImageManager
|
m.BottomPanel.ImageManager = app.ImageManager
|
||||||
@@ -51,6 +49,7 @@ func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App) MainWindo
|
|||||||
app.ServerManager.OnServerConnected(func() {
|
app.ServerManager.OnServerConnected(func() {
|
||||||
m.Router.OpenRoute(HomePage)
|
m.Router.OpenRoute(HomePage)
|
||||||
})
|
})
|
||||||
|
m.addNavigationButtons()
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +63,15 @@ func (m *MainWindow) PromptForFirstServer(cb func(string, string, string, string
|
|||||||
pop.Show()
|
pop.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MainWindow) addNavigationButtons() {
|
||||||
|
m.BrowsingPane.AddNavigationButton(res.ResDiscInvertPng, func() {
|
||||||
|
m.Router.OpenRoute(browsing.AlbumsRoute(backend.AlbumSortRecentlyAdded))
|
||||||
|
})
|
||||||
|
m.BrowsingPane.AddNavigationButton(res.ResPeopleInvertPng, func() {
|
||||||
|
m.Router.OpenRoute(browsing.ArtistsRoute())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MainWindow) Show() {
|
func (m *MainWindow) Show() {
|
||||||
m.Window.Show()
|
m.Window.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package widgets
|
package widgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,12 +32,22 @@ type ArtistGenrePlaylistRow struct {
|
|||||||
|
|
||||||
Item ArtistGenrePlaylistItemModel
|
Item ArtistGenrePlaylistItemModel
|
||||||
|
|
||||||
|
nameLabel *widget.Label
|
||||||
|
albumCountLabel *widget.Label
|
||||||
|
trackCountLabel *widget.Label
|
||||||
|
|
||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewArtistGenrePlaylistRow() *ArtistGenrePlaylistRow {
|
func NewArtistGenrePlaylistRow() *ArtistGenrePlaylistRow {
|
||||||
a := &ArtistGenrePlaylistRow{}
|
a := &ArtistGenrePlaylistRow{
|
||||||
|
nameLabel: widget.NewLabel(""),
|
||||||
|
albumCountLabel: widget.NewLabel("alCount"),
|
||||||
|
trackCountLabel: widget.NewLabel(""),
|
||||||
|
}
|
||||||
a.ExtendBaseWidget(a)
|
a.ExtendBaseWidget(a)
|
||||||
|
// layouts.NewColumnsLayout([]float32{-1, 50, 50})
|
||||||
|
a.container = container.New(layout.NewHBoxLayout(), a.nameLabel, a.albumCountLabel, a.trackCountLabel)
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +62,12 @@ func NewArtistGenrePlaylist(items []ArtistGenrePlaylistItemModel) *ArtistGenrePl
|
|||||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
row := item.(*ArtistGenrePlaylistRow)
|
row := item.(*ArtistGenrePlaylistRow)
|
||||||
row.Item = a.Items[id]
|
row.Item = a.Items[id]
|
||||||
|
row.albumCountLabel.Hidden = a.ShowAlbumCount
|
||||||
|
row.trackCountLabel.Hidden = a.ShowTrackCount
|
||||||
|
row.nameLabel.Text = row.Item.Name
|
||||||
|
row.albumCountLabel.Text = strconv.Itoa(row.Item.AlbumCount)
|
||||||
|
row.trackCountLabel.Text = strconv.Itoa(row.Item.TrackCount)
|
||||||
|
row.Refresh()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return a
|
return a
|
||||||
|
|||||||
Reference in New Issue
Block a user