update album page header for multi-valued artists and genres

This commit is contained in:
Drew Weymouth
2023-10-22 12:01:16 -07:00
parent c8e43e7e53
commit 76f5c156d9
+14 -21
View File
@@ -166,17 +166,15 @@ func (a *AlbumPage) load() {
type AlbumPageHeader struct { type AlbumPageHeader struct {
widget.BaseWidget widget.BaseWidget
albumID string albumID string
coverID string coverID string
artistID string
genre string
page *AlbumPage page *AlbumPage
cover *widgets.TappableImage cover *widgets.TappableImage
titleLabel *widget.RichText titleLabel *widget.RichText
artistLabel *widget.Hyperlink artistLabel *widgets.MultiHyperlink
genreLabel *widget.Hyperlink genreLabel *widgets.MultiHyperlink
miscLabel *widget.Label miscLabel *widget.Label
toggleFavButton *widgets.FavoriteButton toggleFavButton *widgets.FavoriteButton
@@ -200,15 +198,13 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{
SizeName: theme.SizeNameHeadingText, SizeName: theme.SizeNameHeadingText,
} }
a.artistLabel = widget.NewHyperlink("", nil) a.artistLabel = widgets.NewMultiHyperlink()
a.artistLabel.Wrapping = fyne.TextTruncate a.artistLabel.OnTapped = func(id string) {
a.artistLabel.OnTapped = func() { a.page.contr.NavigateTo(controller.ArtistRoute(id))
a.page.contr.NavigateTo(controller.ArtistRoute(a.artistID))
} }
a.genreLabel = widget.NewHyperlink("", nil) a.genreLabel = widgets.NewMultiHyperlink()
a.genreLabel.Wrapping = fyne.TextTruncate a.genreLabel.OnTapped = func(genre string) {
a.genreLabel.OnTapped = func() { a.page.contr.NavigateTo(controller.GenreRoute(genre))
a.page.contr.NavigateTo(controller.GenreRoute(a.genre))
} }
a.miscLabel = widget.NewLabel("") a.miscLabel = widget.NewLabel("")
playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() {
@@ -266,11 +262,9 @@ func (a *AlbumPageHeader) CreateRenderer() fyne.WidgetRenderer {
func (a *AlbumPageHeader) Update(album *mediaprovider.AlbumWithTracks, im *backend.ImageManager) { func (a *AlbumPageHeader) Update(album *mediaprovider.AlbumWithTracks, im *backend.ImageManager) {
a.albumID = album.ID a.albumID = album.ID
a.coverID = album.CoverArtID a.coverID = album.CoverArtID
a.artistID = album.ArtistIDs[0]
a.titleLabel.Segments[0].(*widget.TextSegment).Text = album.Name a.titleLabel.Segments[0].(*widget.TextSegment).Text = album.Name
a.artistLabel.SetText(album.ArtistNames[0]) a.artistLabel.BuildSegments(album.ArtistNames, album.ArtistIDs)
a.genre = album.Genres[0] a.genreLabel.BuildSegments(album.Genres, album.Genres)
a.genreLabel.SetText(album.Genres[0])
a.miscLabel.SetText(formatMiscLabelStr(album)) a.miscLabel.SetText(formatMiscLabelStr(album))
a.toggleFavButton.IsFavorited = album.Favorite a.toggleFavButton.IsFavorited = album.Favorite
a.Refresh() a.Refresh()
@@ -288,10 +282,9 @@ func (a *AlbumPageHeader) Update(album *mediaprovider.AlbumWithTracks, im *backe
func (a *AlbumPageHeader) Clear() { func (a *AlbumPageHeader) Clear() {
a.albumID = "" a.albumID = ""
a.coverID = "" a.coverID = ""
a.artistID = ""
a.titleLabel.Segments[0].(*widget.TextSegment).Text = "" a.titleLabel.Segments[0].(*widget.TextSegment).Text = ""
a.artistLabel.SetText("") a.artistLabel.Segments = nil
a.genreLabel.SetText("") a.genreLabel.Segments = nil
a.miscLabel.SetText("") a.miscLabel.SetText("")
a.toggleFavButton.IsFavorited = false a.toggleFavButton.IsFavorited = false
a.fullSizeCoverFetching = false a.fullSizeCoverFetching = false