update rest of icons to themed
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user