Skip to content

Commit

Permalink
Fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Dec 23, 2023
1 parent 6b2b8a2 commit eb0c18e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/fyne_demo/main.go
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(&forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantDark})
a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark})
}),
widget.NewButton("Light", func() {
a.Settings().SetTheme(&forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantLight})
a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight})
}),
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne_demo/theme.go
Expand Up @@ -6,12 +6,12 @@ import (
"fyne.io/fyne/v2"
)

type forceVariantTheme struct {
type forcedVariant struct {
fyne.Theme

variant fyne.ThemeVariant
}

func (f *forceVariantTheme) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
func (f *forcedVariant) Color(name fyne.ThemeColorName, _ fyne.ThemeVariant) color.Color {
return f.Theme.Color(name, f.variant)
}
7 changes: 4 additions & 3 deletions cmd/fyne_demo/theme_test.go
Expand Up @@ -3,14 +3,15 @@ package main
import (
"testing"

"github.com/stretchr/testify/assert"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
"github.com/stretchr/testify/assert"
)

func TestForceVariantTheme_Color(t *testing.T) {
dark := &forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantDark}
light := &forceVariantTheme{Theme: theme.DefaultTheme(), variant: theme.VariantLight}
dark := &forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark}
light := &forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight}
unspecified := fyne.ThemeVariant(99)

assert.Equal(t, theme.DefaultTheme().Color(theme.ColorNameForeground, theme.VariantDark), dark.Color(theme.ColorNameForeground, unspecified))
Expand Down

0 comments on commit eb0c18e

Please sign in to comment.