feat: Add Share option for artists, albums, and tracks

This feature is only available on the Subsonic media provider. Using a
Jellyfin server will make Supersonic hide the "Share" option.

* Artists: Option available in grid view and in Artist view.
* Albums: Option available in grid view and in Album view.
* Tracks: Option available in tracklist, when a single track is selected.
This commit is contained in:
Michael Manganiello
2024-03-03 20:44:58 -03:00
parent ee0e18e118
commit 9d3725cb51
16 changed files with 174 additions and 6 deletions
+28 -1
View File
@@ -237,7 +237,9 @@ func (a *ArtistPage) showTopTracks() {
}
tl.Options = widgets.TracklistOptions{AutoNumber: true}
_, canRate := a.mp.(mediaprovider.SupportsRating)
_, canShare := a.mp.(mediaprovider.SupportsSharing)
tl.Options.DisableRating = !canRate
tl.Options.HideSharing = !canShare
tl.SetVisibleColumns(a.cfg.TracklistColumns)
tl.SetSorting(a.trackSort)
tl.OnVisibleColumnsChanged = func(cols []string) {
@@ -292,6 +294,7 @@ type ArtistPageHeader struct {
favoriteBtn *widgets.FavoriteButton
playBtn *widget.Button
playRadioBtn *widget.Button
menuBtn *widget.Button
container *fyne.Container
}
@@ -318,6 +321,25 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader {
go a.artistPage.contr.PlayArtistDiscography(a.artistID, false /*shuffle*/)
})
a.playRadioBtn = widget.NewButtonWithIcon("Play Artist Radio", myTheme.ShuffleIcon, a.artistPage.playArtistRadio)
_, canShare := a.artistPage.mp.(mediaprovider.SupportsSharing)
if canShare {
var pop *widget.PopUpMenu
a.menuBtn = widget.NewButtonWithIcon("", theme.MoreHorizontalIcon(), nil)
a.menuBtn.OnTapped = func() {
if pop == nil {
share := fyne.NewMenuItem("Share...", func() {
a.artistPage.contr.CreateShareURL(a.artistID)
})
share.Icon = myTheme.ShareIcon
menu := fyne.NewMenu("", share)
pop = widget.NewPopUpMenu(menu, fyne.CurrentApp().Driver().CanvasForObject(a))
}
pos := fyne.CurrentApp().Driver().AbsolutePositionForObject(a.menuBtn)
pop.ShowAtPosition(fyne.NewPos(pos.X, pos.Y+a.menuBtn.Size().Height))
}
}
a.biographyDisp.Wrapping = fyne.TextWrapWord
a.biographyDisp.Truncation = fyne.TextTruncateEllipsis
a.ExtendBaseWidget(a)
@@ -407,12 +429,17 @@ func (a *ArtistPageHeader) toggleFavorited() {
}
func (a *ArtistPageHeader) createContainer() {
btnContainer := container.NewHBox(util.NewHSpace(2), a.favoriteBtn, a.playBtn, a.playRadioBtn)
if a.menuBtn != nil {
btnContainer.Add(a.menuBtn)
}
a.container = util.AddHeaderBackground(
container.NewBorder(nil, nil, a.artistImage, nil,
container.NewVBox(
container.New(&layouts.VboxCustomPadding{ExtraPad: -10},
a.titleDisp, a.biographyDisp, a.similarArtists),
container.NewHBox(util.NewHSpace(2), a.favoriteBtn, a.playBtn, a.playRadioBtn)),
btnContainer),
))
}