#136: add menu button to album page with options to add album to queue or playlist

This commit is contained in:
Drew Weymouth
2023-04-19 18:13:31 -07:00
parent 8780477025
commit e61dace0dd
3 changed files with 27 additions and 1 deletions
+1
View File
@@ -9,6 +9,7 @@
- [#55](https://github.com/dweymouth/supersonic/issues/55) Show disc number and disc count for multi-disc albums
- [#115](https://github.com/dweymouth/supersonic/issues/115) Add search bar to artist, genres, and playlists pages
- [#104](https://github.com/dweymouth/supersonic/issues/104) Add alternate (e.g. external) hostname to server connection config
- [#136](https://github.com/dweymouth/supersonic/issues/136) Add "..." button to album page with menu to add album to queue or playlist
### Fixes
- **todo-commithash** Don't show update available prompt if the found version is the same as the running app version
+8
View File
@@ -51,6 +51,14 @@ func TrackIDOrEmptyStr(track *subsonic.Child) string {
return track.ID
}
func TracksToIDs(tracks []*subsonic.Child) []string {
ret := make([]string, len(tracks))
for i, tr := range tracks {
ret[i] = tr.ID
}
return ret
}
type TrackReorderOp int
const (
+18 -1
View File
@@ -175,6 +175,23 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
page.pm.LoadTracks(page.tracklist.Tracks, false, true)
page.pm.PlayFromBeginning()
})
var pop *widget.PopUpMenu
menuBtn := widget.NewButtonWithIcon("", theme.MoreHorizontalIcon(), nil)
menuBtn.OnTapped = func() {
if pop == nil {
menu := fyne.NewMenu("",
fyne.NewMenuItem("Add to queue", func() {
a.page.pm.LoadAlbum(a.albumID, true /*append*/, false /*shuffle*/)
}),
fyne.NewMenuItem("Add to playlist...", func() {
a.page.contr.DoAddTracksToPlaylistWorkflow(
sharedutil.TracksToIDs(a.page.tracklist.Tracks))
}))
pop = widget.NewPopUpMenu(menu, fyne.CurrentApp().Driver().CanvasForObject(a))
}
pos := fyne.CurrentApp().Driver().AbsolutePositionForObject(menuBtn)
pop.ShowAtPosition(fyne.NewPos(pos.X, pos.Y+menuBtn.Size().Height))
}
a.toggleFavButton = widgets.NewFavoriteButton(func() { go a.toggleFavorited() })
// Todo: there's got to be a way to make this less convoluted. Custom layout?
@@ -184,7 +201,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
container.NewVBox(
container.New(&layouts.VboxCustomPadding{ExtraPad: -12}, a.artistLabel, a.genreLabel, a.miscLabel),
container.NewVBox(
container.NewHBox(util.NewHSpace(2), playButton, shuffleBtn),
container.NewHBox(util.NewHSpace(2), playButton, shuffleBtn, menuBtn),
container.NewHBox(util.NewHSpace(2), a.toggleFavButton),
),
),