diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index 9f483a9..f25fb01 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -4,10 +4,10 @@ import ( "fmt" "log" "supersonic/backend" - "supersonic/res" "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -170,7 +170,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { playButton := widget.NewButtonWithIcon("Play", theme.MediaPlayIcon(), func() { go page.pm.PlayAlbum(page.albumID, 0) }) - shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() { + shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { page.pm.LoadTracks(page.tracklist.Tracks, false, true) page.pm.PlayFromBeginning() }) diff --git a/ui/browsing/artistpage.go b/ui/browsing/artistpage.go index 7eac001..b1967aa 100644 --- a/ui/browsing/artistpage.go +++ b/ui/browsing/artistpage.go @@ -9,6 +9,7 @@ import ( "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -253,7 +254,7 @@ type ArtistPageHeader struct { similarArtists *fyne.Container favoriteBtn *widgets.FavoriteButton playBtn *widget.Button - playRadioBtn *widget.Button + playRadioBtn *widgets.ThemedIconButton container *fyne.Container } @@ -275,7 +276,7 @@ func NewArtistPageHeader(page *ArtistPage) *ArtistPageHeader { } a.favoriteBtn = widgets.NewFavoriteButton(func() { go a.toggleFavorited() }) a.playBtn = widget.NewButtonWithIcon("Play Discography", theme.MediaPlayIcon(), page.playAllTracks) - a.playRadioBtn = widget.NewButtonWithIcon("Play Artist Radio", res.ResShuffleInvertSvg, page.playArtistRadio) + a.playRadioBtn = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play Artist Radio", page.playArtistRadio) a.biographyDisp.Wrapping = fyne.TextWrapWord a.ExtendBaseWidget(a) a.createContainer() diff --git a/ui/browsing/genrepage.go b/ui/browsing/genrepage.go index 70d2730..84ce6c5 100644 --- a/ui/browsing/genrepage.go +++ b/ui/browsing/genrepage.go @@ -2,8 +2,8 @@ package browsing import ( "supersonic/backend" - "supersonic/res" "supersonic/ui/controller" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -29,7 +29,7 @@ type GenrePage struct { searcher *widgets.Searcher searchText string titleDisp *widget.RichText - playRandom *widget.Button + playRandom *widgets.ThemedIconButton OnPlayAlbum func(string, int) @@ -50,7 +50,7 @@ func NewGenrePage(genre string, contr *controller.Controller, pm *backend.Playba g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, g.playRandomSongs) + g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Play random", g.playRandomSongs) iter := g.lm.GenreIter(g.genre) g.grid = widgets.NewGridView(widgets.NewGridViewAlbumIterator(iter), g.im) g.grid.OnPlay = g.onPlayAlbum @@ -93,8 +93,8 @@ func restoreGenrePage(saved *savedGenrePage) *GenrePage { g.titleDisp.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ SizeName: theme.SizeNameHeadingText, } - g.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, g.playRandomSongs) - g.grid = widgets.NewGridViewFromState(saved.gridState) + g.playRandom = widgets.NewThemedIconButton(myTheme.IconNameShuffle, "Play random", g.playRandomSongs) + g.grid = widgets.NewAlbumGridFromState(saved.gridState) g.searcher = widgets.NewSearcher() g.searcher.OnSearched = g.OnSearched g.searcher.Entry.Text = saved.searchText diff --git a/ui/browsing/playlistpage.go b/ui/browsing/playlistpage.go index 1fddf60..ff54876 100644 --- a/ui/browsing/playlistpage.go +++ b/ui/browsing/playlistpage.go @@ -8,6 +8,7 @@ import ( "supersonic/sharedutil" "supersonic/ui/controller" "supersonic/ui/layouts" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "supersonic/ui/widgets" @@ -205,7 +206,7 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader { page.pm.PlayFromBeginning() }) // TODO: find way to pad shuffle svg rather than using a space in the label string - shuffleBtn := widget.NewButtonWithIcon(" Shuffle", res.ResShuffleInvertSvg, func() { + shuffleBtn := widgets.NewThemedIconButton(myTheme.IconNameShuffle, " Shuffle", func() { page.pm.LoadTracks(page.tracklist.Tracks, false /*append*/, true /*shuffle*/) page.pm.PlayFromBeginning() }) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 633d013..c46a09c 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -58,7 +58,7 @@ func (m *MyTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Col if variant == theme.VariantDark { return color.RGBA{R: 35, G: 35, B: 35, A: 255} } - return color.RGBA{R: 225, G: 225, B: 225, A: 255} + return color.RGBA{R: 225, G: 223, B: 225, A: 255} case theme.ColorNameScrollBar: if variant == theme.VariantDark { return theme.DarkTheme().Color(theme.ColorNameForeground, variant) diff --git a/ui/widgets/themed.go b/ui/widgets/themed.go index b709607..9e7036f 100644 --- a/ui/widgets/themed.go +++ b/ui/widgets/themed.go @@ -61,3 +61,21 @@ func (t *ThemedRectangle) Refresh() { func (t *ThemedRectangle) CreateRenderer() fyne.WidgetRenderer { return widget.NewSimpleRenderer(t.rect) } + +type ThemedTappableIcon struct { + TappableIcon + + IconName fyne.ThemeIconName +} + +func NewThemedTappableIcon(iconName fyne.ThemeIconName) *ThemedTappableIcon { + t := &ThemedTappableIcon{IconName: iconName} + t.ExtendBaseWidget(t) + return t +} + +func (t *ThemedTappableIcon) Refresh() { + icon := fyne.CurrentApp().Settings().Theme().Icon(t.IconName) + t.TappableIcon.Icon.Resource = icon + t.TappableIcon.Refresh() +} diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index af7b367..2a2cdce 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -1,13 +1,13 @@ -package widgets + package widgets import ( "fmt" "log" "strconv" - "supersonic/res" "supersonic/sharedutil" "supersonic/ui/layouts" "supersonic/ui/os" + myTheme "supersonic/ui/theme" "supersonic/ui/util" "sync" "time" @@ -524,7 +524,7 @@ func NewTrackRow(tracklist *Tracklist, playingIcon fyne.CanvasObject) *TrackRow t.album.OnTapped = func() { tracklist.onAlbumTapped(t.albumID) } t.dur = newTrailingAlignRichText() t.year = newTrailingAlignRichText() - favorite := NewTappbaleIcon(res.ResHeartOutlineInvertPng) + favorite := NewThemedTappableIcon(myTheme.IconNameNotFavorite) favorite.OnTapped = t.toggleFavorited t.favorite = container.NewCenter(favorite) t.rating = NewStarRating() @@ -623,10 +623,10 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { // Render favorite column if tr.Starred.IsZero() { t.isFavorite = false - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartOutlineInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite } else { t.isFavorite = true - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartFilledInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite } t.rating.Rating = tr.UserRating @@ -648,12 +648,12 @@ func (t *TrackRow) Update(tr *subsonic.Child, rowNum int) { func (t *TrackRow) toggleFavorited() { if t.isFavorite { - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartOutlineInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameNotFavorite t.favorite.Refresh() t.isFavorite = false t.tracklist.onSetFavorite(t.trackID, false) } else { - t.favorite.Objects[0].(*TappableIcon).Resource = res.ResHeartFilledInvertPng + t.favorite.Objects[0].(*ThemedTappableIcon).IconName = myTheme.IconNameFavorite t.favorite.Refresh() t.isFavorite = true t.tracklist.onSetFavorite(t.trackID, true)