add artist discography page

This commit is contained in:
Drew Weymouth
2022-12-31 21:13:24 -08:00
parent 87b4762ae1
commit 0ff1b6bafd
8 changed files with 233 additions and 39 deletions
+16 -4
View File
@@ -62,8 +62,9 @@ type AlbumCard struct {
widget.BaseWidget
albumID string
artistID string
title *widget.Label
artist *widget.Label
artist *CustomHyperlink
container *fyne.Container
// updated by AlbumGrid
@@ -73,7 +74,9 @@ type AlbumCard struct {
PrevAlbumID string
ImgLoadCancel context.CancelFunc
OnPlay func()
OnPlay func()
OnShowAlbumPage func()
OnShowArtistPage func()
}
func (a *AlbumCard) MouseIn(*desktop.MouseEvent) {}
@@ -85,7 +88,7 @@ func (a *AlbumCard) MouseMoved(*desktop.MouseEvent) {}
func NewAlbumCard() *AlbumCard {
a := &AlbumCard{
title: widget.NewLabel(""),
artist: widget.NewLabel(""),
artist: NewCustomHyperlink(),
Cover: newAlbumCover(),
}
a.ExtendBaseWidget(a)
@@ -94,8 +97,12 @@ func NewAlbumCard() *AlbumCard {
a.OnPlay()
}
}
a.artist.OnTapped = func() {
if a.OnShowArtistPage != nil {
a.OnShowArtistPage()
}
}
a.title.Wrapping = fyne.TextTruncate
a.artist.Wrapping = fyne.TextTruncate
a.title.TextStyle = fyne.TextStyle{Bold: true}
a.createContainer()
@@ -113,12 +120,17 @@ func (a *AlbumCard) Update(al *subsonic.AlbumID3) {
a.title.SetText(al.Name)
a.artist.SetText(al.Artist)
a.albumID = al.ID
a.artistID = al.ArtistID
}
func (a *AlbumCard) AlbumID() string {
return a.albumID
}
func (a *AlbumCard) ArtistID() string {
return a.artistID
}
func (a *AlbumCard) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(a.container)
}
+7
View File
@@ -44,6 +44,8 @@ type CustomHyperlink struct {
widget.BaseWidget
h *hyperlinkWrapper
OnTapped func()
container *fyne.Container
minSize fyne.Size
}
@@ -52,6 +54,11 @@ func NewCustomHyperlink() *CustomHyperlink {
c := &CustomHyperlink{
h: newHyperlinkWrapper(200),
}
c.h.h.OnTapped = func() {
if c.OnTapped != nil {
c.OnTapped()
}
}
c.ExtendBaseWidget(c)
c.container = container.NewHBox(c.h, layout.NewSpacer())
return c