From 81ecd125aff9f79144134ea6097e824e3ea8484b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tilo=20Pr=C3=BCtz?= Date: Thu, 13 Jun 2024 18:05:37 +0200 Subject: [PATCH] =?UTF-8?q?[settings]=20preview=20uses=20actual=20system?= =?UTF-8?q?=20default=20variant=20when=20=E2=80=9Csystem=20default?= =?UTF-8?q?=E2=80=9D=20is=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/fyne_settings/settings/appearance.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/fyne_settings/settings/appearance.go b/cmd/fyne_settings/settings/appearance.go index 3f3b024ac7..5b13ad7244 100644 --- a/cmd/fyne_settings/settings/appearance.go +++ b/cmd/fyne_settings/settings/appearance.go @@ -11,6 +11,7 @@ import ( "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" + internalapp "fyne.io/fyne/v2/internal/app" intWidget "fyne.io/fyne/v2/internal/widget" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/theme" @@ -18,7 +19,9 @@ import ( ) const ( - systemThemeName = "system default" + themeNameDark = "dark" + themeNameLight = "light" + themeNameSystem = "system default" ) // Settings gives access to user interfaces to control Fyne settings @@ -56,11 +59,11 @@ func (s *Settings) LoadAppearanceScreen(w fyne.Window) fyne.CanvasObject { s.preview = s.createPreview() def := s.fyneSettings.ThemeName - themeNames := []string{"dark", "light"} + themeNames := []string{themeNameDark, themeNameLight} if runtime.GOOS == "darwin" || runtime.GOOS == "windows" { - themeNames = append(themeNames, systemThemeName) + themeNames = append(themeNames, themeNameSystem) if s.fyneSettings.ThemeName == "" { - def = systemThemeName + def = themeNameSystem } } themes := widget.NewSelect(themeNames, s.chooseTheme) @@ -102,7 +105,7 @@ func (s *Settings) LoadAppearanceScreen(w fyne.Window) fyne.CanvasObject { } func (s *Settings) chooseTheme(name string) { - if name == systemThemeName { + if name == themeNameSystem { name = "" } s.fyneSettings.ThemeName = name @@ -242,8 +245,11 @@ type previewTheme struct { func (p *previewTheme) Color(n fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color { variant := theme.VariantDark - if p.s.fyneSettings.ThemeName == "light" { + switch p.s.fyneSettings.ThemeName { + case themeNameLight: variant = theme.VariantLight + case themeNameSystem: + variant = internalapp.DefaultVariant() } switch n {