1
0
mirror of https://github.com/taigrr/crocgui synced 2025-01-18 04:03:16 -08:00

add black theme

This commit is contained in:
Chris Howey 2021-03-25 14:36:05 -05:00
parent 029dfa483c
commit 048a293e98
3 changed files with 46 additions and 3 deletions

View File

@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.github.howeyc.crocgui" package="com.github.howeyc.crocgui"
android:versionCode="8" android:versionCode="9"
android:versionName="1.4.1"> android:versionName="1.5.0">
<application android:label="Croc"> <application android:label="Croc">
<activity android:name="org.golang.app.GoNativeActivity" <activity android:name="org.golang.app.GoNativeActivity"

View File

@ -0,0 +1,39 @@
package croctheme
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
)
func BlackTheme() fyne.Theme {
return &blackTheme{}
}
type blackTheme struct{}
var _ fyne.Theme = (*blackTheme)(nil)
func (b blackTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
if name == theme.ColorNameBackground {
return color.Black
}
if name == theme.ColorNameShadow {
return color.White
}
return theme.DarkTheme().Color(name, theme.VariantDark)
}
func (b blackTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
return theme.DarkTheme().Icon(name)
}
func (b blackTheme) Font(style fyne.TextStyle) fyne.Resource {
return theme.DarkTheme().Font(style)
}
func (bm blackTheme) Size(name fyne.ThemeSizeName) float32 {
return theme.DarkTheme().Size(name)
}

View File

@ -1,6 +1,8 @@
package main package main
import ( import (
"crocgui/internal/croctheme"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding" "fyne.io/fyne/v2/data/binding"
@ -15,6 +17,8 @@ func setTheme(themeName string) {
a.Settings().SetTheme(theme.LightTheme()) a.Settings().SetTheme(theme.LightTheme())
case "dark": case "dark":
a.Settings().SetTheme(theme.DarkTheme()) a.Settings().SetTheme(theme.DarkTheme())
case "black":
a.Settings().SetTheme(croctheme.BlackTheme())
default: default:
// TODO: get system // TODO: get system
a.Settings().SetTheme(theme.LightTheme()) a.Settings().SetTheme(theme.LightTheme())
@ -23,7 +27,7 @@ func setTheme(themeName string) {
func settingsTabItem(a fyne.App) *container.TabItem { func settingsTabItem(a fyne.App) *container.TabItem {
themeBinding := binding.BindPreferenceString("theme", a.Preferences()) themeBinding := binding.BindPreferenceString("theme", a.Preferences())
themeSelect := widget.NewSelect([]string{"light", "dark"}, func(selection string) { themeSelect := widget.NewSelect([]string{"light", "dark", "black"}, func(selection string) {
setTheme(selection) setTheme(selection)
themeBinding.Set(selection) themeBinding.Set(selection)
}) })