Skip to content

Commit

Permalink
Stop using deprecated theme, improve docs
Browse files Browse the repository at this point in the history
Fixes #4208
  • Loading branch information
andydotxyz committed Sep 3, 2023
1 parent 23df176 commit 1c741ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/fyne_demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ func makeNav(setTutorial func(tutorial tutorials.Tutorial), loadPrevious bool) f

themes := container.NewGridWithColumns(2,
widget.NewButton("Dark", func() {
a.Settings().SetTheme(theme.DarkTheme())
a.Settings().SetTheme(&forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantDark})
}),
widget.NewButton("Light", func() {
a.Settings().SetTheme(theme.LightTheme())
a.Settings().SetTheme(&forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantLight})
}),
)

Expand Down
17 changes: 17 additions & 0 deletions cmd/fyne_demo/theme.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"image/color"

"fyne.io/fyne/v2"
)

type forceVariantTheme struct {
fyne.Theme

variant fyne.ThemeVariant
}

func (f *forceVariantTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
return f.Theme.Color(name, f.variant)
}
2 changes: 2 additions & 0 deletions theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
// DarkTheme defines the built-in dark theme colors and sizes.
//
// Deprecated: This method ignores user preference and should not be used, it will be removed in v3.0.
// If developers want to ignore user preference for theme variant they can set a custom theme.
func DarkTheme() fyne.Theme {
theme := &builtinTheme{variant: VariantDark}

Expand All @@ -48,6 +49,7 @@ func DefaultTheme() fyne.Theme {
// LightTheme defines the built-in light theme colors and sizes.
//
// Deprecated: This method ignores user preference and should not be used, it will be removed in v3.0.
// If developers want to ignore user preference for theme variant they can set a custom theme.
func LightTheme() fyne.Theme {
theme := &builtinTheme{variant: VariantLight}

Expand Down

0 comments on commit 1c741ce

Please sign in to comment.