From b7393d1bc8c87e3b5082871571186bd6c44e95ff Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Tue, 31 Oct 2023 22:18:42 -0700 Subject: [PATCH] switch to ImagePlaceholder on album page --- ui/browsing/albumpage.go | 14 ++++++-------- ui/dialogs/albuminfodialog.go | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index b0bd90e0..340b555e 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -14,7 +14,6 @@ import ( "github.com/dweymouth/supersonic/ui/widgets" "fyne.io/fyne/v2" - "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" @@ -171,7 +170,7 @@ type AlbumPageHeader struct { page *AlbumPage - cover *widgets.TappableImage + cover *widgets.ImagePlaceholder titleLabel *widget.RichText artistLabel *widgets.MultiHyperlink genreLabel *widgets.MultiHyperlink @@ -189,9 +188,8 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { // be directly captured in a closure throughout this function! a := &AlbumPageHeader{page: page} a.ExtendBaseWidget(a) - a.cover = widgets.NewTappableImage(func(*fyne.PointEvent) { go a.showPopUpCover() }) - a.cover.FillMode = canvas.ImageFillContain - a.cover.SetMinSize(fyne.NewSize(225, 225)) + a.cover = widgets.NewImagePlaceholder(myTheme.AlbumIcon, 225) + a.cover.OnTapped = func(*fyne.PointEvent) { go a.showPopUpCover() } a.titleLabel = widget.NewRichTextWithText("") a.titleLabel.Wrapping = fyne.TextTruncate @@ -230,7 +228,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { a.page.contr.ShowDownloadDialog(a.page.tracks, a.titleLabel.String()) }), fyne.NewMenuItem("Show Info...", func() { - a.page.contr.ShowAlbumInfoDialog(a.albumID, a.titleLabel.String(), a.cover.Image.Image) + a.page.contr.ShowAlbumInfoDialog(a.albumID, a.titleLabel.String(), a.cover.Image()) })) pop = widget.NewPopUpMenu(menu, fyne.CurrentApp().Driver().CanvasForObject(a)) } @@ -271,7 +269,7 @@ func (a *AlbumPageHeader) Update(album *mediaprovider.AlbumWithTracks, im *backe go func() { if cover, err := im.GetCoverThumbnail(album.CoverArtID); err == nil { - a.cover.Image.Image = cover + a.cover.SetImage(cover, true) a.cover.Refresh() } else { log.Printf("error fetching cover: %v", err) @@ -288,7 +286,7 @@ func (a *AlbumPageHeader) Clear() { a.miscLabel.SetText("") a.toggleFavButton.IsFavorited = false a.fullSizeCoverFetching = false - a.cover.Image.Image = nil + a.cover.SetImage(nil, false) a.cover.Refresh() } diff --git a/ui/dialogs/albuminfodialog.go b/ui/dialogs/albuminfodialog.go index 9839582f..18747c04 100644 --- a/ui/dialogs/albuminfodialog.go +++ b/ui/dialogs/albuminfodialog.go @@ -55,6 +55,7 @@ func (a *AlbumInfoDialog) buildMainContainer(albumInfo *mediaprovider.AlbumInfo, iconImage := canvas.NewImageFromImage(albumCover) iconImage.FillMode = canvas.ImageFillContain iconImage.SetMinSize(fyne.NewSize(100, 100)) + iconImage.Hidden = albumCover == nil title := widget.NewRichTextWithText(albumName) title.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = true title.Segments[0].(*widget.TextSegment).Style.SizeName = theme.SizeNameSubHeadingText