diff --git a/about.go b/about.go index e68138b..d778987 100644 --- a/about.go +++ b/about.go @@ -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)), - )) + ) } diff --git a/main.go b/main.go index 46ed0c0..88b1e7a 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/metadata/en-US/changelogs/9.txt b/metadata/en-US/changelogs/9.txt index af00c42..39f391b 100644 --- a/metadata/en-US/changelogs/9.txt +++ b/metadata/en-US/changelogs/9.txt @@ -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 diff --git a/settings.go b/settings.go index 5ae63f8..17baa7a 100644 --- a/settings.go +++ b/settings.go @@ -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), + ), )) }