update rest of icons to themed

This commit is contained in:
Drew Weymouth
2023-05-01 17:42:09 -07:00
parent 94157b3a00
commit cdac9ae66f
7 changed files with 38 additions and 18 deletions
+2 -2
View File
@@ -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()
})
+3 -2
View File
@@ -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()
+5 -5
View File
@@ -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
+2 -1
View File
@@ -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()
})
+1 -1
View File
@@ -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)
+18
View File
@@ -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()
}
+7 -7
View File
@@ -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)