handle multiple artists properly in UI
This commit is contained in:
+13
-16
@@ -5,6 +5,7 @@ import (
|
||||
"image"
|
||||
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
@@ -122,18 +123,18 @@ func isInside(origin fyne.Position, radius float32, point fyne.Position) bool {
|
||||
}
|
||||
|
||||
type GridViewItemModel struct {
|
||||
Name string
|
||||
ID string
|
||||
CoverArtID string
|
||||
Secondary string
|
||||
SecondaryID string
|
||||
Name string
|
||||
ID string
|
||||
CoverArtID string
|
||||
Secondary []string
|
||||
SecondaryIDs []string
|
||||
}
|
||||
|
||||
type GridViewItem struct {
|
||||
widget.BaseWidget
|
||||
|
||||
itemID string
|
||||
secondaryID string
|
||||
secondaryIDs []string
|
||||
primaryText *widget.Hyperlink
|
||||
secondaryText *MultiHyperlink
|
||||
container *fyne.Container
|
||||
@@ -145,7 +146,7 @@ type GridViewItem struct {
|
||||
OnPlay func()
|
||||
OnShowContextMenu func(fyne.Position)
|
||||
OnShowItemPage func()
|
||||
OnShowSecondaryPage func()
|
||||
OnShowSecondaryPage func(string)
|
||||
}
|
||||
|
||||
func NewGridViewItem(placeholderResource fyne.Resource) *GridViewItem {
|
||||
@@ -174,9 +175,9 @@ func NewGridViewItem(placeholderResource fyne.Resource) *GridViewItem {
|
||||
}
|
||||
g.Cover.OnShowPage = showItemFn
|
||||
g.primaryText.OnTapped = showItemFn
|
||||
g.secondaryText.OnTapped = func(_ string) { // TODO
|
||||
g.secondaryText.OnTapped = func(s string) {
|
||||
if g.OnShowSecondaryPage != nil {
|
||||
g.OnShowSecondaryPage()
|
||||
g.OnShowSecondaryPage(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,14 +193,14 @@ func (g *GridViewItem) createContainer() {
|
||||
}
|
||||
|
||||
func (g *GridViewItem) NeedsUpdate(model GridViewItemModel) bool {
|
||||
return g.itemID != model.ID || g.secondaryID != model.SecondaryID
|
||||
return g.itemID != model.ID || !sharedutil.SliceEqual(g.secondaryIDs, model.SecondaryIDs)
|
||||
}
|
||||
|
||||
func (g *GridViewItem) Update(model GridViewItemModel) {
|
||||
g.itemID = model.ID
|
||||
g.secondaryID = model.SecondaryID
|
||||
g.secondaryIDs = model.SecondaryIDs
|
||||
g.primaryText.SetText(model.Name)
|
||||
g.secondaryText.Segments = []MultiHyperlinkSegment{{Text: model.Secondary, LinkID: model.SecondaryID}}
|
||||
g.secondaryText.BuildSegments(model.Secondary, model.SecondaryIDs)
|
||||
g.secondaryText.Refresh()
|
||||
g.Cover.ResetPlayButton()
|
||||
}
|
||||
@@ -212,10 +213,6 @@ func (g *GridViewItem) ItemID() string {
|
||||
return g.itemID
|
||||
}
|
||||
|
||||
func (g *GridViewItem) SecondaryID() string {
|
||||
return g.secondaryID
|
||||
}
|
||||
|
||||
func (g *GridViewItem) CreateRenderer() fyne.WidgetRenderer {
|
||||
return widget.NewSimpleRenderer(g.container)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user