kind-of works but needs rendering work
This commit is contained in:
+43
-17
@@ -49,12 +49,13 @@ type ArtistPage struct {
|
||||
|
||||
artistInfo *mediaprovider.ArtistWithAlbums
|
||||
|
||||
albumGrid *widgets.GridView
|
||||
tracklistCtr *fyne.Container
|
||||
sortButton *widgets.SortChooserButton
|
||||
nowPlayingID string
|
||||
header *ArtistPageHeader
|
||||
container *fyne.Container
|
||||
albumGrid *widgets.GridView
|
||||
groupedReleases *widgets.GroupedReleases
|
||||
tracklistCtr *fyne.Container
|
||||
sortButton *widgets.SortChooserButton
|
||||
nowPlayingID string
|
||||
header *ArtistPageHeader
|
||||
container *fyne.Container
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -156,6 +157,10 @@ func (a *ArtistPage) Save() SavedPage {
|
||||
a.albumGrid.Clear()
|
||||
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
|
||||
}
|
||||
|
||||
@@ -294,27 +299,48 @@ func (a *ArtistPage) load() {
|
||||
}
|
||||
|
||||
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 {
|
||||
// page not loaded yet or invalid artist
|
||||
a.activeView = 0 // if page still loading, will show discography view first
|
||||
return
|
||||
}
|
||||
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)
|
||||
if useGroupedReleases {
|
||||
model := a.getGroupedReleasesModel()
|
||||
if g := a.pool.Obtain(util.WidgetTypeGroupedReleases); g != nil {
|
||||
a.groupedReleases = g.(*widgets.GroupedReleases)
|
||||
a.groupedReleases.Model = model
|
||||
} else {
|
||||
a.groupedReleases = widgets.NewGroupedReleases(model, a.im)
|
||||
}
|
||||
a.contr.ConnectGroupedReleasesActions(a.groupedReleases)
|
||||
} 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 {
|
||||
model := a.getGridViewAlbumsModel()
|
||||
a.albumGrid.ResetFixed(model)
|
||||
if useGroupedReleases {
|
||||
a.groupedReleases.Model = a.getGroupedReleasesModel()
|
||||
} else {
|
||||
model := a.getGridViewAlbumsModel()
|
||||
a.albumGrid.ResetFixed(model)
|
||||
}
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
@@ -97,35 +97,67 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
|
||||
grid.OnShowSecondaryPage = func(artistID string) {
|
||||
m.NavigateTo(ArtistRoute(artistID))
|
||||
}
|
||||
grid.OnAddToPlaylist = 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.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.OnAddToPlaylist = m.onAddAlbumToPlaylist
|
||||
grid.OnDownload = m.onDownloadAlbum
|
||||
grid.OnShare = func(albumID string) {
|
||||
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) {
|
||||
grid.OnShowItemPage = func(id string) { m.NavigateTo(ArtistRoute(id)) }
|
||||
grid.OnPlayNext = func(artistID string) {
|
||||
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
WidgetTypeTracklist
|
||||
WidgetTypeCompactTracklist
|
||||
WidgetTypeNowPlayingPage
|
||||
WidgetTypeGroupedReleases
|
||||
|
||||
// keep at bottom
|
||||
numWidgetTypes
|
||||
|
||||
@@ -88,7 +88,7 @@ func (g *GroupedReleases) Refresh() {
|
||||
g.cardPool.Put(objects[x])
|
||||
objects[x] = nil
|
||||
}
|
||||
if lenItems > len(objects) {
|
||||
if len(objects) > lenItems {
|
||||
objects = objects[:lenItems]
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ func (g *GroupedReleases) Refresh() {
|
||||
for x := len(objects); x < lenItems; x++ {
|
||||
card := g.cardPool.Get().(*GridViewItem)
|
||||
g.doUpdateItemCard(card, &items[x])
|
||||
objects = append(objects, card)
|
||||
}
|
||||
|
||||
g.sections[i].container.Objects = objects
|
||||
|
||||
Reference in New Issue
Block a user