kind-of works but needs rendering work
This commit is contained in:
+43
-17
@@ -49,12 +49,13 @@ type ArtistPage struct {
|
|||||||
|
|
||||||
artistInfo *mediaprovider.ArtistWithAlbums
|
artistInfo *mediaprovider.ArtistWithAlbums
|
||||||
|
|
||||||
albumGrid *widgets.GridView
|
albumGrid *widgets.GridView
|
||||||
tracklistCtr *fyne.Container
|
groupedReleases *widgets.GroupedReleases
|
||||||
sortButton *widgets.SortChooserButton
|
tracklistCtr *fyne.Container
|
||||||
nowPlayingID string
|
sortButton *widgets.SortChooserButton
|
||||||
header *ArtistPageHeader
|
nowPlayingID string
|
||||||
container *fyne.Container
|
header *ArtistPageHeader
|
||||||
|
container *fyne.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -156,6 +157,10 @@ func (a *ArtistPage) Save() SavedPage {
|
|||||||
a.albumGrid.Clear()
|
a.albumGrid.Clear()
|
||||||
a.pool.Release(util.WidgetTypeGridView, a.albumGrid)
|
a.pool.Release(util.WidgetTypeGridView, a.albumGrid)
|
||||||
}
|
}
|
||||||
|
if a.groupedReleases != nil {
|
||||||
|
a.groupedReleases.Model = widgets.GroupedReleasesModel{}
|
||||||
|
a.pool.Release(util.WidgetTypeGroupedReleases, a.groupedReleases)
|
||||||
|
}
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,27 +299,48 @@ func (a *ArtistPage) load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *ArtistPage) showAlbumGrid(reSort bool) {
|
func (a *ArtistPage) showAlbumGrid(reSort bool) {
|
||||||
if a.albumGrid == nil {
|
useGroupedReleases := a.artistInfo != nil && len(a.artistInfo.Albums) <= 50
|
||||||
|
|
||||||
|
if a.albumGrid == nil && a.groupedReleases == nil {
|
||||||
if a.artistInfo == nil {
|
if a.artistInfo == nil {
|
||||||
// page not loaded yet or invalid artist
|
// page not loaded yet or invalid artist
|
||||||
a.activeView = 0 // if page still loading, will show discography view first
|
a.activeView = 0 // if page still loading, will show discography view first
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
model := a.getGridViewAlbumsModel()
|
if useGroupedReleases {
|
||||||
if g := a.pool.Obtain(util.WidgetTypeGridView); g != nil {
|
model := a.getGroupedReleasesModel()
|
||||||
a.albumGrid = g.(*widgets.GridView)
|
if g := a.pool.Obtain(util.WidgetTypeGroupedReleases); g != nil {
|
||||||
a.albumGrid.Placeholder = myTheme.AlbumIcon
|
a.groupedReleases = g.(*widgets.GroupedReleases)
|
||||||
a.albumGrid.ResetFixed(model)
|
a.groupedReleases.Model = model
|
||||||
|
} else {
|
||||||
|
a.groupedReleases = widgets.NewGroupedReleases(model, a.im)
|
||||||
|
}
|
||||||
|
a.contr.ConnectGroupedReleasesActions(a.groupedReleases)
|
||||||
} else {
|
} else {
|
||||||
a.albumGrid = widgets.NewFixedGridView(model, a.im, myTheme.AlbumIcon)
|
model := a.getGridViewAlbumsModel()
|
||||||
|
if g := a.pool.Obtain(util.WidgetTypeGridView); g != nil {
|
||||||
|
a.albumGrid = g.(*widgets.GridView)
|
||||||
|
a.albumGrid.Placeholder = myTheme.AlbumIcon
|
||||||
|
a.albumGrid.ResetFixed(model)
|
||||||
|
} else {
|
||||||
|
a.albumGrid = widgets.NewFixedGridView(model, a.im, myTheme.AlbumIcon)
|
||||||
|
}
|
||||||
|
a.contr.ConnectAlbumGridActions(a.albumGrid)
|
||||||
}
|
}
|
||||||
a.contr.ConnectAlbumGridActions(a.albumGrid)
|
|
||||||
} else if reSort {
|
} else if reSort {
|
||||||
model := a.getGridViewAlbumsModel()
|
if useGroupedReleases {
|
||||||
a.albumGrid.ResetFixed(model)
|
a.groupedReleases.Model = a.getGroupedReleasesModel()
|
||||||
|
} else {
|
||||||
|
model := a.getGridViewAlbumsModel()
|
||||||
|
a.albumGrid.ResetFixed(model)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
a.sortButton.Show()
|
a.sortButton.Show()
|
||||||
a.container.Objects[0].(*fyne.Container).Objects[0] = a.albumGrid
|
if useGroupedReleases {
|
||||||
|
a.container.Objects[0].(*fyne.Container).Objects[0] = a.groupedReleases
|
||||||
|
} else {
|
||||||
|
a.container.Objects[0].(*fyne.Container).Objects[0] = a.albumGrid
|
||||||
|
}
|
||||||
a.container.Objects[0].Refresh()
|
a.container.Objects[0].Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,35 +97,67 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
|
|||||||
grid.OnShowSecondaryPage = func(artistID string) {
|
grid.OnShowSecondaryPage = func(artistID string) {
|
||||||
m.NavigateTo(ArtistRoute(artistID))
|
m.NavigateTo(ArtistRoute(artistID))
|
||||||
}
|
}
|
||||||
grid.OnAddToPlaylist = func(albumID string) {
|
grid.OnAddToPlaylist = m.onAddAlbumToPlaylist
|
||||||
go func() {
|
grid.OnDownload = m.onDownloadAlbum
|
||||||
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("error loading album: %s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fyne.Do(func() {
|
|
||||||
m.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(album.Tracks))
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
grid.OnDownload = func(albumID string) {
|
|
||||||
go func() {
|
|
||||||
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("error loading album: %s", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fyne.Do(func() {
|
|
||||||
m.ShowDownloadDialog(album.Tracks, album.Name)
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
grid.OnShare = func(albumID string) {
|
grid.OnShare = func(albumID string) {
|
||||||
m.ShowShareDialog(albumID)
|
m.ShowShareDialog(albumID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Controller) ConnectGroupedReleasesActions(grid *widgets.GroupedReleases) {
|
||||||
|
grid.OnAddToQueue = func(albumID string) {
|
||||||
|
go m.App.PlaybackManager.LoadAlbum(albumID, backend.Append, false)
|
||||||
|
}
|
||||||
|
grid.OnPlayNext = func(albumID string) {
|
||||||
|
go m.App.PlaybackManager.LoadAlbum(albumID, backend.InsertNext, false)
|
||||||
|
}
|
||||||
|
grid.OnPlay = func(albumID string, shuffle bool) {
|
||||||
|
go m.App.PlaybackManager.PlayAlbum(albumID, 0, shuffle)
|
||||||
|
}
|
||||||
|
grid.OnFavorite = func(albumID string, favorite bool) {
|
||||||
|
m.App.ServerManager.Server.SetFavorite(mediaprovider.RatingFavoriteParameters{
|
||||||
|
AlbumIDs: []string{albumID},
|
||||||
|
}, favorite)
|
||||||
|
}
|
||||||
|
grid.OnShowItemPage = func(albumID string) {
|
||||||
|
m.NavigateTo(AlbumRoute(albumID))
|
||||||
|
}
|
||||||
|
grid.OnShowSecondaryPage = func(artistID string) {
|
||||||
|
m.NavigateTo(ArtistRoute(artistID))
|
||||||
|
}
|
||||||
|
grid.OnAddToPlaylist = m.onAddAlbumToPlaylist
|
||||||
|
grid.OnDownload = m.onDownloadAlbum
|
||||||
|
grid.OnShare = func(albumID string) {
|
||||||
|
m.ShowShareDialog(albumID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Controller) onAddAlbumToPlaylist(albumID string) {
|
||||||
|
go func() {
|
||||||
|
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error loading album: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fyne.Do(func() {
|
||||||
|
m.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(album.Tracks))
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Controller) onDownloadAlbum(albumID string) {
|
||||||
|
go func() {
|
||||||
|
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error loading album: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fyne.Do(func() {
|
||||||
|
m.ShowDownloadDialog(album.Tracks, album.Name)
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
|
func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
|
||||||
grid.OnShowItemPage = func(id string) { m.NavigateTo(ArtistRoute(id)) }
|
grid.OnShowItemPage = func(id string) { m.NavigateTo(ArtistRoute(id)) }
|
||||||
grid.OnPlayNext = func(artistID string) {
|
grid.OnPlayNext = func(artistID string) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const (
|
|||||||
WidgetTypeTracklist
|
WidgetTypeTracklist
|
||||||
WidgetTypeCompactTracklist
|
WidgetTypeCompactTracklist
|
||||||
WidgetTypeNowPlayingPage
|
WidgetTypeNowPlayingPage
|
||||||
|
WidgetTypeGroupedReleases
|
||||||
|
|
||||||
// keep at bottom
|
// keep at bottom
|
||||||
numWidgetTypes
|
numWidgetTypes
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ func (g *GroupedReleases) Refresh() {
|
|||||||
g.cardPool.Put(objects[x])
|
g.cardPool.Put(objects[x])
|
||||||
objects[x] = nil
|
objects[x] = nil
|
||||||
}
|
}
|
||||||
if lenItems > len(objects) {
|
if len(objects) > lenItems {
|
||||||
objects = objects[:lenItems]
|
objects = objects[:lenItems]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +100,7 @@ func (g *GroupedReleases) Refresh() {
|
|||||||
for x := len(objects); x < lenItems; x++ {
|
for x := len(objects); x < lenItems; x++ {
|
||||||
card := g.cardPool.Get().(*GridViewItem)
|
card := g.cardPool.Get().(*GridViewItem)
|
||||||
g.doUpdateItemCard(card, &items[x])
|
g.doUpdateItemCard(card, &items[x])
|
||||||
|
objects = append(objects, card)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.sections[i].container.Objects = objects
|
g.sections[i].container.Objects = objects
|
||||||
|
|||||||
Reference in New Issue
Block a user