From d8d2777e28b18ecfbf24221ffb8e136245fd7a23 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Tue, 23 Jul 2024 09:11:49 -0500 Subject: [PATCH] fix: theme weirdness --- src/utils/customwidgets.go | 8 +++++++- src/utils/theme.go | 15 +++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/utils/customwidgets.go b/src/utils/customwidgets.go index 9db745a..4790ad8 100644 --- a/src/utils/customwidgets.go +++ b/src/utils/customwidgets.go @@ -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) diff --git a/src/utils/theme.go b/src/utils/theme.go index 65ea087..50060f7 100644 --- a/src/utils/theme.go +++ b/src/utils/theme.go @@ -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) }