forked from libsgh/chrome_updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_theme.go
47 lines (41 loc) · 1.12 KB
/
custom_theme.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/theme"
"image/color"
"strings"
)
type MyTheme struct {
Theme binding.String
Lang binding.String
}
var _ fyne.Theme = (*MyTheme)(nil)
// Font return bundled font resource
func (mt MyTheme) Font(s fyne.TextStyle) fyne.Resource {
lang := getString(mt.Lang)
if lang == "zh-CN" || ((lang == "System" || lang == "") && DefaultLocaleName() == "zh-CN") {
if s.Bold {
return resourceAssetsFontAlibabaPuHuiTi385BoldTtf
}
return resourceAssetsFontAlibabaPuHuiTi355RegularTtf
}
return theme.DefaultTheme().Font(s)
}
func (mt *MyTheme) Color(n fyne.ThemeColorName, v fyne.ThemeVariant) color.Color {
t, _ := mt.Theme.Get()
if strings.Contains(t, LoadString("ThemeLightOption")) {
v = theme.VariantLight
} else if strings.Contains(t, LoadString("ThemeDarkOption")) {
v = theme.VariantDark
} else {
v = 2
}
return theme.DefaultTheme().Color(n, v)
}
func (*MyTheme) Icon(n fyne.ThemeIconName) fyne.Resource {
return theme.DefaultTheme().Icon(n)
}
func (*MyTheme) Size(n fyne.ThemeSizeName) float32 {
return theme.DefaultTheme().Size(n)
}