Skip to content

Commit

Permalink
[settings] preview uses actual system default variant when “system de…
Browse files Browse the repository at this point in the history
…fault” is selected
  • Loading branch information
toaster committed Jun 13, 2024
1 parent d6170d2 commit 81ecd12
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/fyne_settings/settings/appearance.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ 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"
"fyne.io/fyne/v2/widget"
)

const (
systemThemeName = "system default"
themeNameDark = "dark"
themeNameLight = "light"
themeNameSystem = "system default"
)

// Settings gives access to user interfaces to control Fyne settings
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 81ecd12

Please sign in to comment.