set placeholder image when album cover is not available
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
File diff suppressed because one or more lines are too long
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
fyne bundle -package res -prefix Res appicon-250.png > bundled.go
|
fyne bundle -package res -prefix Res appicon-250.png > bundled.go
|
||||||
|
fyne bundle -append -prefix Res albumplaceholder.png >> bundled.go
|
||||||
fyne bundle -append -prefix Res icons/freepik/disc.png >> bundled.go
|
fyne bundle -append -prefix Res icons/freepik/disc.png >> bundled.go
|
||||||
fyne bundle -append -prefix Res icons/freepik/disc-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/freepik/disc-invert.png >> bundled.go
|
||||||
fyne bundle -append -prefix Res icons/freepik/headphones.png >> bundled.go
|
fyne bundle -append -prefix Res icons/freepik/headphones.png >> bundled.go
|
||||||
@@ -29,4 +30,4 @@ fyne bundle -append -prefix Res icons/publicdomain/shuffle-invert.svg >> bundled
|
|||||||
|
|
||||||
fyne bundle -append -prefix Res ../LICENSE >> bundled.go
|
fyne bundle -append -prefix Res ../LICENSE >> bundled.go
|
||||||
fyne bundle -append -prefix Res licenses/BSDLICENSE >> bundled.go
|
fyne bundle -append -prefix Res licenses/BSDLICENSE >> bundled.go
|
||||||
fyne bundle -append -prefix Res licenses/MITLICENSE >> bundled.go
|
fyne bundle -append -prefix Res licenses/MITLICENSE >> bundled.go
|
||||||
|
|||||||
@@ -87,12 +87,14 @@ func (a *AboutDialog) buildCreditsContainer() fyne.CanvasObject {
|
|||||||
freepikURL, _ := url.Parse("https://www.flaticon.com/authors/freepik")
|
freepikURL, _ := url.Parse("https://www.flaticon.com/authors/freepik")
|
||||||
appIconCredit := widget.NewLabel("The Supersonic app icon is a derivative of a work created by Piotr Siedlecki and placed in the public domain.")
|
appIconCredit := widget.NewLabel("The Supersonic app icon is a derivative of a work created by Piotr Siedlecki and placed in the public domain.")
|
||||||
appIconCredit.Wrapping = fyne.TextWrapWord
|
appIconCredit.Wrapping = fyne.TextWrapWord
|
||||||
|
albumPlaceholderCredit := widget.NewLabel("The album cover placeholder image was created by @LaurenBacall originally for the MP3Tag project.")
|
||||||
|
albumPlaceholderCredit.Wrapping = fyne.TextWrapWord
|
||||||
return container.New(&layouts.VboxCustomPadding{ExtraPad: -10},
|
return container.New(&layouts.VboxCustomPadding{ExtraPad: -10},
|
||||||
widget.NewLabel("Major frameworks and modules used in this application include:"),
|
widget.NewLabel("Major frameworks and modules used in this application include:"),
|
||||||
container.NewHBox(widget.NewHyperlink("Fyne toolkit", fyneURL), widget.NewLabel("BSD 3-Clause License")),
|
container.NewHBox(widget.NewHyperlink("Fyne toolkit", fyneURL), widget.NewLabel("BSD 3-Clause License")),
|
||||||
container.NewHBox(widget.NewHyperlink("go-subsonic", goSubsonicURL), widget.NewLabel("GPL v3 License")),
|
container.NewHBox(widget.NewHyperlink("go-subsonic", goSubsonicURL), widget.NewLabel("GPL v3 License")),
|
||||||
container.NewHBox(widget.NewHyperlink("go-toml", goTomlURL), widget.NewLabel("MIT License")),
|
container.NewHBox(widget.NewHyperlink("go-toml", goTomlURL), widget.NewLabel("MIT License")),
|
||||||
appIconCredit,
|
appIconCredit, albumPlaceholderCredit,
|
||||||
container.NewHBox(widget.NewLabel("Additional icons by:"), widget.NewHyperlink("Freepik on flaticon.com", freepikURL)),
|
container.NewHBox(widget.NewLabel("Additional icons by:"), widget.NewHyperlink("Freepik on flaticon.com", freepikURL)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,10 +89,17 @@ func (a *albumCover) center() fyne.Position {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *albumCover) SetImage(im image.Image) {
|
func (a *albumCover) SetImage(im image.Image) {
|
||||||
|
a.Im.Resource = nil
|
||||||
a.Im.Image = im
|
a.Im.Image = im
|
||||||
a.Refresh()
|
a.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *albumCover) SetImageResource(res *fyne.StaticResource) {
|
||||||
|
a.Im.Image = nil
|
||||||
|
a.Im.Resource = res
|
||||||
|
a.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
func isInside(origin fyne.Position, radius float32, point fyne.Position) bool {
|
func isInside(origin fyne.Position, radius float32, point fyne.Position) bool {
|
||||||
x, y := (point.X - origin.X), (point.Y - origin.Y)
|
x, y := (point.X - origin.X), (point.Y - origin.Y)
|
||||||
return x*x+y*y <= radius*radius
|
return x*x+y*y <= radius*radius
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"image"
|
"image"
|
||||||
"log"
|
"log"
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
|
"supersonic/res"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
@@ -148,7 +149,6 @@ func (ag *AlbumGrid) doUpdateAlbumCard(albumIdx int, ac *AlbumCard) {
|
|||||||
}
|
}
|
||||||
ac.Update(album)
|
ac.Update(album)
|
||||||
ac.PrevAlbumID = album.ID
|
ac.PrevAlbumID = album.ID
|
||||||
// TODO: set image to a placeholder before spinning off async fetch
|
|
||||||
// cancel any previous image fetch
|
// cancel any previous image fetch
|
||||||
if ac.ImgLoadCancel != nil {
|
if ac.ImgLoadCancel != nil {
|
||||||
ac.ImgLoadCancel()
|
ac.ImgLoadCancel()
|
||||||
@@ -156,9 +156,11 @@ func (ag *AlbumGrid) doUpdateAlbumCard(albumIdx int, ac *AlbumCard) {
|
|||||||
}
|
}
|
||||||
if img, ok := ag.imageFetcher.GetAlbumThumbnailFromCache(album.ID); ok {
|
if img, ok := ag.imageFetcher.GetAlbumThumbnailFromCache(album.ID); ok {
|
||||||
ac.Cover.SetImage(img)
|
ac.Cover.SetImage(img)
|
||||||
ac.Cover.Refresh()
|
|
||||||
} else {
|
} else {
|
||||||
|
ac.Cover.SetImageResource(res.ResAlbumplaceholderPng)
|
||||||
|
// asynchronously fetch cover image
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
ac.ImgLoadCancel = cancel
|
||||||
go func(ctx context.Context) {
|
go func(ctx context.Context) {
|
||||||
i, err := ag.imageFetcher.GetAlbumThumbnail(album.ID)
|
i, err := ag.imageFetcher.GetAlbumThumbnail(album.ID)
|
||||||
select {
|
select {
|
||||||
@@ -167,13 +169,11 @@ func (ag *AlbumGrid) doUpdateAlbumCard(albumIdx int, ac *AlbumCard) {
|
|||||||
default:
|
default:
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ac.Cover.SetImage(i)
|
ac.Cover.SetImage(i)
|
||||||
ac.Cover.Refresh()
|
|
||||||
} else {
|
} else {
|
||||||
log.Printf("error fetching image: %s", err.Error())
|
log.Printf("error fetching image: %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(ctx)
|
}(ctx)
|
||||||
ac.ImgLoadCancel = cancel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if user has scrolled near the bottom, fetch more
|
// if user has scrolled near the bottom, fetch more
|
||||||
|
|||||||
Reference in New Issue
Block a user