add shuffle button to album and playlist pages
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"supersonic/backend"
|
||||
"supersonic/res"
|
||||
"supersonic/ui/controller"
|
||||
"supersonic/ui/layouts"
|
||||
"supersonic/ui/util"
|
||||
@@ -65,9 +66,9 @@ func NewAlbumPage(
|
||||
widgets.ColumnArtist, widgets.ColumnTime, widgets.ColumnPlays})
|
||||
// connect tracklist actions
|
||||
a.tracklist.OnPlayTrackAt = a.onPlayTrackAt
|
||||
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true) }
|
||||
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true, false) }
|
||||
a.tracklist.OnPlaySelection = func(tracks []*subsonic.Child) {
|
||||
a.pm.LoadTracks(tracks, false)
|
||||
a.pm.LoadTracks(tracks, false, false)
|
||||
a.pm.PlayFromBeginning()
|
||||
}
|
||||
a.tracklist.OnAddToPlaylist = a.contr.DoAddTracksToPlaylistWorkflow
|
||||
@@ -148,7 +149,6 @@ type AlbumPageHeader struct {
|
||||
miscLabel *widget.Label
|
||||
|
||||
toggleFavButton *widgets.FavoriteButton
|
||||
playButton *widget.Button
|
||||
|
||||
container *fyne.Container
|
||||
}
|
||||
@@ -178,9 +178,13 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
|
||||
page.nav(GenreRoute(a.genre))
|
||||
}
|
||||
a.miscLabel = widget.NewLabel("")
|
||||
a.playButton = widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() {
|
||||
playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() {
|
||||
page.onPlayTrackAt(0)
|
||||
})
|
||||
shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() {
|
||||
page.pm.LoadAlbum(page.albumID, false, true)
|
||||
page.pm.PlayFromBeginning()
|
||||
})
|
||||
a.toggleFavButton = widgets.NewFavoriteButton(a.toggleFavorited)
|
||||
|
||||
// Todo: there's got to be a way to make this less convoluted. Custom layout?
|
||||
@@ -190,7 +194,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
|
||||
container.NewVBox(
|
||||
container.New(&layouts.VboxCustomPadding{ExtraPad: -12}, a.artistLabel, a.genreLabel, a.miscLabel),
|
||||
container.NewVBox(
|
||||
container.NewHBox(widgets.NewHSpace(2), a.playButton),
|
||||
container.NewHBox(widgets.NewHSpace(2), playButton, shuffleBtn),
|
||||
container.NewHBox(widgets.NewHSpace(2), a.toggleFavButton),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -57,9 +57,9 @@ func NewPlaylistPage(
|
||||
}
|
||||
// connect tracklist actions
|
||||
a.tracklist.OnPlayTrackAt = a.onPlayTrackAt
|
||||
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true) }
|
||||
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true, false) }
|
||||
a.tracklist.OnPlaySelection = func(tracks []*subsonic.Child) {
|
||||
a.pm.LoadTracks(tracks, false)
|
||||
a.pm.LoadTracks(tracks, false, false)
|
||||
a.pm.PlayFromBeginning()
|
||||
}
|
||||
a.tracklist.OnAddToPlaylist = a.contr.DoAddTracksToPlaylistWorkflow
|
||||
@@ -143,8 +143,6 @@ type PlaylistPageHeader struct {
|
||||
ownerLabel *widget.Label
|
||||
trackTimeLabel *widget.Label
|
||||
|
||||
playButton *widget.Button
|
||||
|
||||
container *fyne.Container
|
||||
}
|
||||
|
||||
@@ -162,16 +160,21 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader {
|
||||
a.ownerLabel = widget.NewLabel("")
|
||||
a.createdAtLabel = widget.NewLabel("")
|
||||
a.trackTimeLabel = widget.NewLabel("")
|
||||
a.playButton = widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() {
|
||||
playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() {
|
||||
page.onPlayTrackAt(0)
|
||||
})
|
||||
// TODO: find way to pad shuffle svg rather than using a space in the label string
|
||||
shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() {
|
||||
page.pm.LoadPlaylist(page.playlistID, false /*append*/, true /*shuffle*/)
|
||||
page.pm.PlayFromBeginning()
|
||||
})
|
||||
|
||||
a.container = container.NewBorder(nil, nil, a.image, nil,
|
||||
container.NewVBox(a.titleLabel, container.New(&layouts.VboxCustomPadding{ExtraPad: -10},
|
||||
a.descriptionLabel,
|
||||
a.ownerLabel,
|
||||
a.trackTimeLabel),
|
||||
container.NewHBox(a.playButton),
|
||||
container.NewHBox(playButton, shuffleBtn),
|
||||
))
|
||||
return a
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user