fix: theme weirdness

This commit is contained in:
2024-07-23 09:11:49 -05:00
parent f00b134228
commit d8d2777e28
2 changed files with 18 additions and 5 deletions

View File

@@ -51,7 +51,13 @@ func (ct *ClickableText) Tapped(_ *fyne.PointEvent) {
setClipboard(ct.Text.Text)
// Set the text color to green when tapped, and reset it after 1 second
ct.tapBG.FillColor = color.RGBA{0, 120, 20, 200}
variant := fyne.CurrentApp().Settings().ThemeVariant()
switch variant {
case theme.VariantDark:
ct.tapBG.FillColor = color.RGBA{10, 110, 0, 180}
case theme.VariantLight:
ct.tapBG.FillColor = color.RGBA{10, 100, 10, 180}
}
go func() {
<-time.After(time.Millisecond * 400)

View File

@@ -13,6 +13,17 @@ var _ fyne.Theme = (*Theme)(nil)
// The color package has to be imported from "image/color".
func (m Theme) GetColor(name string) color.Color {
variant := fyne.CurrentApp().Settings().ThemeVariant()
switch variant {
case theme.VariantDark:
return color.RGBA{0, 0, 0, 255}
case theme.VariantLight:
return color.RGBA{255, 255, 255, 255}
}
return color.RGBA{0, 0, 0, 255}
}
func (m Theme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
if name == theme.ColorNameBackground {
if variant == theme.VariantLight {
@@ -43,10 +54,6 @@ func (m Theme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.
}
func (m Theme) Icon(name fyne.ThemeIconName) fyne.Resource {
// if name == theme.IconNameHome {
// return fyne.NewStaticResource("myHome", homeBytes)
// }
return theme.DefaultTheme().Icon(name)
}