add focus navigation to playlists list view
This commit is contained in:
@@ -191,7 +191,7 @@ func NewGenreList(sorting widgets.ListHeaderSort) *GenreList {
|
|||||||
r := NewGenreListRow(a.columnsLayout)
|
r := NewGenreListRow(a.columnsLayout)
|
||||||
r.OnTapped = func() { a.onGoToGenre(r.Item) }
|
r.OnTapped = func() { a.onGoToGenre(r.Item) }
|
||||||
r.OnFocusNeighbor = func(up bool) {
|
r.OnFocusNeighbor = func(up bool) {
|
||||||
a.list.FocusNeighbor(r.ListItemID, up)
|
a.list.FocusNeighbor(r.ItemID(), up)
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -306,17 +306,25 @@ func NewPlaylistList(initialSort widgets.ListHeaderSort) *PlaylistList {
|
|||||||
},
|
},
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
r := NewPlaylistListRow(a.columnsLayout)
|
r := NewPlaylistListRow(a.columnsLayout)
|
||||||
r.OnTapped = func() { a.onRowTapped(r.ID) }
|
r.OnTapped = func() { a.onRowTapped(r.PlaylistID) }
|
||||||
|
r.OnFocusNeighbor = func(up bool) {
|
||||||
|
a.list.FocusNeighbor(r.ItemID(), up)
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
},
|
},
|
||||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
row := item.(*PlaylistListRow)
|
row := item.(*PlaylistListRow)
|
||||||
row.ID = a.playlists[id].ID
|
if row.PlaylistID != a.playlists[id].ID {
|
||||||
row.nameLabel.Text = a.playlists[id].Name
|
row.EnsureUnfocused()
|
||||||
row.descrptionLabel.Text = a.playlists[id].Description
|
a.list.SetItemForID(id, row)
|
||||||
row.ownerLabel.Text = a.playlists[id].Owner
|
row.ListItemID = id
|
||||||
row.trackCountLabel.Text = strconv.Itoa(a.playlists[id].TrackCount)
|
row.PlaylistID = a.playlists[id].ID
|
||||||
row.Refresh()
|
row.nameLabel.Text = a.playlists[id].Name
|
||||||
|
row.descrptionLabel.Text = a.playlists[id].Description
|
||||||
|
row.ownerLabel.Text = a.playlists[id].Owner
|
||||||
|
row.trackCountLabel.Text = strconv.Itoa(a.playlists[id].TrackCount)
|
||||||
|
row.Refresh()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
a.container = container.NewBorder(a.header, nil, nil, nil, a.list)
|
a.container = container.NewBorder(a.header, nil, nil, nil, a.list)
|
||||||
@@ -399,17 +407,14 @@ func (p *PlaylistList) intSort(fieldFn func(*mediaprovider.Playlist) int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PlaylistListRow struct {
|
type PlaylistListRow struct {
|
||||||
widget.BaseWidget
|
widgets.FocusListRowBase
|
||||||
|
|
||||||
ID string
|
PlaylistID string
|
||||||
OnTapped func()
|
|
||||||
|
|
||||||
nameLabel *widget.Label
|
nameLabel *widget.Label
|
||||||
descrptionLabel *widget.Label
|
descrptionLabel *widget.Label
|
||||||
ownerLabel *widget.Label
|
ownerLabel *widget.Label
|
||||||
trackCountLabel *widget.Label
|
trackCountLabel *widget.Label
|
||||||
|
|
||||||
container *fyne.Container
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPlaylistListRow(layout *layouts.ColumnsLayout) *PlaylistListRow {
|
func NewPlaylistListRow(layout *layouts.ColumnsLayout) *PlaylistListRow {
|
||||||
@@ -421,7 +426,7 @@ func NewPlaylistListRow(layout *layouts.ColumnsLayout) *PlaylistListRow {
|
|||||||
}
|
}
|
||||||
a.trackCountLabel.Alignment = fyne.TextAlignTrailing
|
a.trackCountLabel.Alignment = fyne.TextAlignTrailing
|
||||||
a.ownerLabel.Truncation = fyne.TextTruncateEllipsis
|
a.ownerLabel.Truncation = fyne.TextTruncateEllipsis
|
||||||
a.container = container.New(layout, a.nameLabel, a.descrptionLabel, a.ownerLabel, a.trackCountLabel)
|
a.Content = container.New(layout, a.nameLabel, a.descrptionLabel, a.ownerLabel, a.trackCountLabel)
|
||||||
a.ExtendBaseWidget(a)
|
a.ExtendBaseWidget(a)
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
@@ -431,7 +436,3 @@ func (a *PlaylistListRow) Tapped(*fyne.PointEvent) {
|
|||||||
a.OnTapped()
|
a.OnTapped()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PlaylistListRow) CreateRenderer() fyne.WidgetRenderer {
|
|
||||||
return widget.NewSimpleRenderer(a.container)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user