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

Theme selection, as mentioned in #3

This commit is contained in:
Chris Howey 2021-03-25 09:59:30 -05:00
parent 86d5331f1f
commit 029dfa483c
4 changed files with 33 additions and 10 deletions

View File

@ -60,13 +60,7 @@ func aboutTabItem() *container.TabItem {
w.Resize(fyne.NewSize(450, 800))
w.Show()
})
return container.NewTabItemWithIcon("About", theme.InfoIcon(), container.NewBorder(nil,
widget.NewForm(
widget.NewFormItem("croc GUI", widget.NewHyperlink("v1.4.1", parseURL("https://github.com/howeyc/crocgui"))),
widget.NewFormItem("croc", widget.NewHyperlink("v8.6.7", parseURL("https://github.com/schollz/croc"))),
),
nil,
nil,
return container.NewTabItemWithIcon("About", theme.InfoIcon(),
container.NewVScroll(container.NewVBox(aboutInfo, licenseToggle)),
))
)
}

View File

@ -21,10 +21,13 @@ func main() {
a.Preferences().SetString("relay-address", a.Preferences().StringWithFallback("relay-address", "croc.schollz.com:9009"))
a.Preferences().SetString("relay-password", a.Preferences().StringWithFallback("relay-password", "pass123"))
a.Preferences().SetString("relay-ports", a.Preferences().StringWithFallback("relay-ports", "9009,9010,9011,9012,9013"))
a.Preferences().SetBool("disable-local", a.Preferences().BoolWithFallback("disable-local", true))
a.Preferences().SetBool("disable-local", a.Preferences().BoolWithFallback("disable-local", false))
a.Preferences().SetBool("force-local", a.Preferences().BoolWithFallback("force-local", false))
a.Preferences().SetBool("disable-multiplexing", a.Preferences().BoolWithFallback("disable-multiplexing", false))
a.Preferences().SetBool("disable-compression", a.Preferences().BoolWithFallback("disable-compression", false))
a.Preferences().SetString("theme", a.Preferences().StringWithFallback("theme", "light"))
setTheme(a.Preferences().String("theme"))
textlogores := fyne.NewStaticResource("text-logo", textlogobytes)
textlogo := canvas.NewImageFromResource(textlogores)

View File

@ -1,3 +1,4 @@
- Add license info
- Allow user to change theme
- Update to show filename for content:// URI on android
- Save defaults on start so settings tab also shows defaults
- Add license info

View File

@ -8,7 +8,27 @@ import (
"fyne.io/fyne/v2/widget"
)
func setTheme(themeName string) {
a := fyne.CurrentApp()
switch themeName {
case "light":
a.Settings().SetTheme(theme.LightTheme())
case "dark":
a.Settings().SetTheme(theme.DarkTheme())
default:
// TODO: get system
a.Settings().SetTheme(theme.LightTheme())
}
}
func settingsTabItem(a fyne.App) *container.TabItem {
themeBinding := binding.BindPreferenceString("theme", a.Preferences())
themeSelect := widget.NewSelect([]string{"light", "dark"}, func(selection string) {
setTheme(selection)
themeBinding.Set(selection)
})
currentTheme, _ := themeBinding.Get()
themeSelect.SetSelected(currentTheme)
return container.NewTabItemWithIcon("Settings", theme.SettingsIcon(), container.NewVBox(
widget.NewLabelWithStyle("Relay", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
widget.NewForm(
@ -28,5 +48,10 @@ func settingsTabItem(a fyne.App) *container.TabItem {
widget.NewFormItem("", widget.NewCheckWithData("Disable Multiplexing", binding.BindPreferenceBool("disable-multiplexing", a.Preferences()))),
widget.NewFormItem("", widget.NewCheckWithData("Disable Compression", binding.BindPreferenceBool("disable-compression", a.Preferences()))),
),
widget.NewSeparator(),
widget.NewLabelWithStyle("Appearance", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
widget.NewForm(
widget.NewFormItem("Theme", themeSelect),
),
))
}