Skip to content

Commit 928843c

Browse files
committed
fix: auto theme detection not working
1 parent f2a890a commit 928843c

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

internal/app/ui/theme.go

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,26 @@ var themeColors = map[fyne.ThemeColorName][]color.Color{
3535
},
3636
}
3737

38-
type myTheme struct {
39-
mode settings.ColorTheme
38+
// customTheme represents a custom Fyne theme.
39+
// It adds colors to the default theme
40+
// and allows setting a fixed theme variant.
41+
type customTheme struct {
42+
defaultTheme fyne.Theme
43+
mode settings.ColorTheme
4044
}
4145

42-
func (ct myTheme) Color(c fyne.ThemeColorName, v fyne.ThemeVariant) color.Color {
43-
switch ct.mode {
46+
// newCustomTheme returns a new custom theme.
47+
// Must be called after the app has started.
48+
func newCustomTheme(mode settings.ColorTheme) *customTheme {
49+
th := &customTheme{
50+
defaultTheme: fyne.CurrentApp().Settings().Theme(),
51+
mode: mode,
52+
}
53+
return th
54+
}
55+
56+
func (th customTheme) Color(c fyne.ThemeColorName, v fyne.ThemeVariant) color.Color {
57+
switch th.mode {
4458
case settings.Dark:
4559
v = theme.VariantDark
4660
case settings.Light:
@@ -50,18 +64,18 @@ func (ct myTheme) Color(c fyne.ThemeColorName, v fyne.ThemeVariant) color.Color
5064
case colorNameInfo, colorNameCreative, colorNameSystem, colorNameAttention:
5165
return themeColors[c][v]
5266
default:
53-
return theme.DefaultTheme().Color(c, v)
67+
return th.defaultTheme.Color(c, v)
5468
}
5569
}
5670

57-
func (myTheme) Font(style fyne.TextStyle) fyne.Resource {
58-
return theme.DefaultTheme().Font(style)
71+
func (th customTheme) Font(style fyne.TextStyle) fyne.Resource {
72+
return th.defaultTheme.Font(style)
5973
}
6074

61-
func (myTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
62-
return theme.DefaultTheme().Icon(n)
75+
func (th customTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
76+
return th.defaultTheme.Icon(n)
6377
}
6478

65-
func (myTheme) Size(s fyne.ThemeSizeName) float32 {
66-
return theme.DefaultTheme().Size(s)
79+
func (th customTheme) Size(s fyne.ThemeSizeName) float32 {
80+
return th.defaultTheme.Size(s)
6781
}

internal/app/ui/ui.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ func NewBaseUI(arg BaseUIParams) *baseUI {
420420
u.training = newTraining(u)
421421
u.wealth = newWealth(u)
422422

423-
u.setColorTheme(u.settings.ColorTheme())
424423
u.MainWindow().SetMaster()
425424

426425
// SetOnStarted is called on initial start,
@@ -462,6 +461,7 @@ func (u *baseUI) Start() bool {
462461
return false
463462
}
464463
// First app start
464+
u.setColorTheme(u.settings.ColorTheme())
465465
if u.isOffline {
466466
slog.Info("App started in offline mode")
467467
} else {
@@ -912,7 +912,7 @@ func (u *baseUI) updateStatus() {
912912
}
913913

914914
func (u *baseUI) setColorTheme(s settings.ColorTheme) {
915-
u.app.Settings().SetTheme(myTheme{s})
915+
u.app.Settings().SetTheme(newCustomTheme(s))
916916
}
917917

918918
func (u *baseUI) updateMailIndicator() {

internal/app/ui/wealth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ func newWealth(u *baseUI) *wealth {
5858
color := theme.ColorNameForeground
5959
a.assetDetail.SetTitleStyle(size, color)
6060
a.assetDetail.HideLegend()
61+
a.assetDetail.SetYAxisLabel("B ISK")
6162
a.assetSplit.SetTitleStyle(size, color)
6263
a.walletSplit.SetTitleStyle(size, color)
6364
a.walletDetail.SetTitleStyle(size, color)
6465
a.walletDetail.HideLegend()
66+
a.walletDetail.SetYAxisLabel("B ISK")
6567
a.totalSplit.SetTitleStyle(size, color)
6668
a.characterSplit.SetTitleStyle(size, color)
6769

0 commit comments

Comments
 (0)