make track title in bottom panel link to Now Playing page

This commit is contained in:
Drew Weymouth
2023-04-30 10:17:34 -07:00
parent 78194165f4
commit 053474f669
8 changed files with 44 additions and 14 deletions
+4
View File
@@ -90,6 +90,10 @@ func (c *CustomHyperlink) SetText(text string) {
c.Refresh()
}
func (c *CustomHyperlink) SetTextStyle(style fyne.TextStyle) {
c.h.TextStyle = style
}
func (c *CustomHyperlink) Resize(size fyne.Size) {
c.h.MaxWidth = size.Width
c.BaseWidget.Resize(size)
+8 -5
View File
@@ -15,7 +15,7 @@ import (
type NowPlayingCard struct {
widget.BaseWidget
trackName *widget.Label
trackName *CustomHyperlink
artistName *CustomHyperlink
albumName *CustomHyperlink
cover *TappableImage
@@ -27,7 +27,7 @@ type NowPlayingCard struct {
func NewNowPlayingCard() *NowPlayingCard {
n := &NowPlayingCard{
trackName: widget.NewLabel(""),
trackName: NewCustomHyperlink(),
artistName: NewCustomHyperlink(),
albumName: NewCustomHyperlink(),
}
@@ -35,8 +35,7 @@ func NewNowPlayingCard() *NowPlayingCard {
n.cover = NewTappableImage(n.onShowCoverImage)
n.artistName.Hidden = true
n.albumName.Hidden = true
n.trackName.Wrapping = fyne.TextTruncate
n.trackName.TextStyle = fyne.TextStyle{Bold: true}
n.trackName.SetTextStyle(fyne.TextStyle{Bold: true})
n.cover.SetMinSize(fyne.NewSize(85, 85))
n.cover.FillMode = canvas.ImageFillContain
@@ -59,7 +58,7 @@ func (n *NowPlayingCard) CreateRenderer() fyne.WidgetRenderer {
}
func (n *NowPlayingCard) Update(track, artist string, artistNavigable bool, album string, cover image.Image) {
n.trackName.Text = track
n.trackName.SetText(track)
n.artistName.SetText(artist)
n.artistName.Hidden = artist == ""
n.artistName.Disabled = !artistNavigable
@@ -76,3 +75,7 @@ func (n *NowPlayingCard) OnArtistNameTapped(f func()) {
func (n *NowPlayingCard) OnAlbumNameTapped(f func()) {
n.albumName.OnTapped = f
}
func (n *NowPlayingCard) OnTrackNameTapped(f func()) {
n.trackName.OnTapped = f
}
+16
View File
@@ -231,6 +231,22 @@ func (t *Tracklist) UnselectAll() {
t.list.Refresh()
}
func (t *Tracklist) SelectAndScrollToTrack(trackID string) {
t.tracksMutex.RLock()
idx := -1
for i, tr := range t.Tracks {
if tr.ID == trackID {
idx = i
break
}
}
t.tracksMutex.RUnlock()
if idx >= 0 {
t.list.ScrollTo(idx)
t.selectionMgr.Select(idx)
}
}
func (t *Tracklist) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(t.container)
}