switch to ImagePlaceholder on album page

This commit is contained in:
Drew Weymouth
2023-10-31 22:19:05 -07:00
parent ffc6a8fc98
commit b7393d1bc8
2 changed files with 7 additions and 8 deletions
+6 -8
View File
@@ -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()
}
+1
View File
@@ -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