Skip to content

Commit

Permalink
Merge pull request #517 from dweymouth/feat/gridview-iconbuttons
Browse files Browse the repository at this point in the history
Add favorite + menu icon-buttons to bottom right of album/artist grid cards when hovered
  • Loading branch information
dweymouth authored Dec 29, 2024
2 parents 672faa1 + bb2a4aa commit 619d1fa
Show file tree
Hide file tree
Showing 7 changed files with 552 additions and 35 deletions.
10 changes: 6 additions & 4 deletions ui/browsing/artistpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ func (a *ArtistPage) getGridViewAlbumsModel() []widgets.GridViewItemModel {
sort.Slice(a.artistInfo.Albums, sortFunc)
return sharedutil.MapSlice(a.artistInfo.Albums, func(al *mediaprovider.Album) widgets.GridViewItemModel {
return widgets.GridViewItemModel{
Name: al.Name,
ID: al.ID,
CoverArtID: al.CoverArtID,
Secondary: []string{strconv.Itoa(al.YearOrZero())},
Name: al.Name,
ID: al.ID,
CoverArtID: al.CoverArtID,
Secondary: []string{strconv.Itoa(al.YearOrZero())},
CanFavorite: true,
IsFavorite: al.Favorite,
}
})
}
Expand Down
14 changes: 8 additions & 6 deletions ui/browsing/favoritespage.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (a *FavoritesPage) createHeader(activeBtnIdx int) {
a.shuffleBtn.Hidden = activeBtnIdx != 2 /*favorite songs*/
a.searcher = widgets.NewSearchEntry()
a.searcher.PlaceHolder = lang.L("Search page")
a.searcher.OnSearched = a.OnSearched
a.searcher.OnSearched = a.onSearched
a.searcher.Entry.Text = a.searchText
a.filterBtn = widgets.NewAlbumFilterButton(a.filter, a.mp.GetGenres)
a.filterBtn.FavoriteDisabled = true
Expand Down Expand Up @@ -267,7 +267,7 @@ func (a *FavoritesPage) SearchWidget() fyne.Focusable {
return a.searcher
}

func (a *FavoritesPage) OnSearched(query string) {
func (a *FavoritesPage) onSearched(query string) {
if query == "" {
a.albumGrid.ResetFromState(a.gridState)
a.searchGridState = nil
Expand Down Expand Up @@ -386,10 +386,12 @@ func buildArtistGridViewModel(artists []*mediaprovider.Artist) []widgets.GridVie
albums = lang.L("album")
}
model = append(model, widgets.GridViewItemModel{
ID: ar.ID,
CoverArtID: ar.CoverArtID,
Name: ar.Name,
Secondary: []string{fmt.Sprintf("%d %s", ar.AlbumCount, albums)},
ID: ar.ID,
CoverArtID: ar.CoverArtID,
Name: ar.Name,
Secondary: []string{fmt.Sprintf("%d %s", ar.AlbumCount, albums)},
CanFavorite: true,
IsFavorite: ar.Favorite,
})
}
return model
Expand Down
10 changes: 10 additions & 0 deletions ui/controller/connectactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
grid.OnPlay = func(albumID string, shuffle bool) {
go m.App.PlaybackManager.PlayAlbum(albumID, 0, shuffle)
}
grid.OnFavorite = func(albumID string, favorite bool) {
m.App.ServerManager.Server.SetFavorite(mediaprovider.RatingFavoriteParameters{
AlbumIDs: []string{albumID},
}, favorite)
}
grid.OnShowItemPage = func(albumID string) {
m.NavigateTo(AlbumRoute(albumID))
}
Expand Down Expand Up @@ -128,6 +133,11 @@ func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
go m.DoAddTracksToPlaylistWorkflow(
sharedutil.TracksToIDs(m.GetArtistTracks(artistID)))
}
grid.OnFavorite = func(artistID string, favorite bool) {
m.App.ServerManager.Server.SetFavorite(mediaprovider.RatingFavoriteParameters{
ArtistIDs: []string{artistID},
}, favorite)
}
grid.OnDownload = func(artistID string) {
go func() {
tracks := m.GetArtistTracks(artistID)
Expand Down
3 changes: 3 additions & 0 deletions ui/theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const (
)

var (
GridViewHoveredIconColor color.Color = color.White
GridViewIconColor color.Color = darkenColor(color.White, 0.2)

AlbumIcon fyne.Resource = theme.NewThemedResource(res.ResDiscSvg)
ArtistIcon fyne.Resource = theme.NewThemedResource(res.ResPeopleSvg)
RadioIcon fyne.Resource = theme.NewThemedResource(res.ResBroadcastSvg)
Expand Down
Loading

0 comments on commit 619d1fa

Please sign in to comment.