Skip to content

Commit

Permalink
add black theme
Browse files Browse the repository at this point in the history
  • Loading branch information
howeyc committed Mar 25, 2021
1 parent 029dfa4 commit 048a293
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.github.howeyc.crocgui"
android:versionCode="8"
android:versionName="1.4.1">
android:versionCode="9"
android:versionName="1.5.0">

<application android:label="Croc">
<activity android:name="org.golang.app.GoNativeActivity"
Expand Down
39 changes: 39 additions & 0 deletions internal/croctheme/blackTheme.go
Original file line number Diff line number Diff line change
@@ -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)
}
6 changes: 5 additions & 1 deletion settings.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"crocgui/internal/croctheme"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
Expand All @@ -15,6 +17,8 @@ func setTheme(themeName string) {
a.Settings().SetTheme(theme.LightTheme())
case "dark":
a.Settings().SetTheme(theme.DarkTheme())
case "black":
a.Settings().SetTheme(croctheme.BlackTheme())
default:
// TODO: get system
a.Settings().SetTheme(theme.LightTheme())
Expand All @@ -23,7 +27,7 @@ func setTheme(themeName string) {

func settingsTabItem(a fyne.App) *container.TabItem {
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)
themeBinding.Set(selection)
})
Expand Down

0 comments on commit 048a293

Please sign in to comment.