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
+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)