12345678910111213141516171819202122232425262728293031323334353637383940 |
- package data
- import (
- "fyne.io/fyne"
- )
- type ThemedResource struct {
- dark, light fyne.Resource
- }
- func isLight() bool {
- r, g, b, _ := fyne.CurrentApp().Settings().Theme().TextColor().RGBA()
- return r < 0xaaaa && g < 0xaaaa && b < 0xaaaa
- }
- func (res *ThemedResource) Name() string {
- if isLight() {
- return res.light.Name()
- }
- return res.dark.Name()
- }
- func (res *ThemedResource) Content() []byte {
- if isLight() {
- return res.light.Content()
- }
- return res.dark.Content()
- }
- func NewThemedResource(dark, light fyne.Resource) *ThemedResource {
- return &ThemedResource{dark, light}
- }
- var FyneScene = NewThemedResource(fynescenedark, fynescenelight)
|