add Favorites page and toggle favorite button to album page

This commit is contained in:
Drew Weymouth
2023-01-21 17:31:52 -08:00
parent 6bae838f90
commit 96f0748767
5 changed files with 184 additions and 9 deletions
+40
View File
@@ -0,0 +1,40 @@
package widgets
import (
"supersonic/res"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
)
type FavoriteButton struct {
widget.Button
IsFavorited bool
}
func NewFavoriteButton(onTapped func()) *FavoriteButton {
f := &FavoriteButton{
Button: widget.Button{
OnTapped: onTapped,
Icon: res.ResHeartOutlineInvertPng,
},
}
f.ExtendBaseWidget(f)
return f
}
func (f *FavoriteButton) Tapped(e *fyne.PointEvent) {
f.IsFavorited = !f.IsFavorited
f.Button.Tapped(e)
f.Refresh()
}
func (f *FavoriteButton) Refresh() {
if f.IsFavorited {
f.Icon = res.ResHeartFilledInvertPng
} else {
f.Icon = res.ResHeartOutlineInvertPng
}
f.Button.Refresh()
}