Skip to content

Commit

Permalink
switch to ImagePlaceholder on album page
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Nov 1, 2023
1 parent ffc6a8f commit b7393d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ui/browsing/albumpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -171,7 +170,7 @@ type AlbumPageHeader struct {

page *AlbumPage

cover *widgets.TappableImage
cover *widgets.ImagePlaceholder
titleLabel *widget.RichText
artistLabel *widgets.MultiHyperlink
genreLabel *widgets.MultiHyperlink
Expand All @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}

Expand Down
1 change: 1 addition & 0 deletions ui/dialogs/albuminfodialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b7393d1

Please sign in to comment.