Prechádzať zdrojové kódy

feat(config): add theme field (#134)

ayntgl 4 rokov pred
rodič
commit
20ca8a7268
3 zmenil súbory, kde vykonal 23 pridanie a 1 odobranie
  1. 3 1
      config/mod.go
  2. 15 0
      config/theme.go
  3. 5 0
      main.go

+ 3 - 1
config/mod.go

@@ -8,13 +8,15 @@ import (
 )
 
 type Config struct {
-	Keybindings KeybindingsConfig `toml:"keybindings"`
 	General     GeneralConfig     `toml:"general"`
+	Theme       ThemeConfig       `toml:"theme"`
+	Keybindings KeybindingsConfig `toml:"keybindings"`
 }
 
 func newConfig() Config {
 	return Config{
 		General:     newGeneralConfig(),
+		Theme:       newThemeConfig(),
 		Keybindings: newKeybindingsConfig(),
 	}
 }

+ 15 - 0
config/theme.go

@@ -0,0 +1,15 @@
+package config
+
+type ThemeConfig struct {
+	Background string `toml:"background"`
+	Border     string `toml:"border"`
+	Title      string `toml:"title"`
+}
+
+func newThemeConfig() ThemeConfig {
+	return ThemeConfig{
+		Background: "black",
+		Border:     "white",
+		Title:      "white",
+	}
+}

+ 5 - 0
main.go

@@ -5,6 +5,7 @@ import (
 
 	"github.com/ayntgl/discordo/discord"
 	"github.com/ayntgl/discordo/ui"
+	"github.com/gdamore/tcell/v2"
 	"github.com/rivo/tview"
 	"github.com/zalando/go-keyring"
 )
@@ -95,6 +96,10 @@ func main() {
 	tview.Borders.Horizontal = 0
 	tview.Borders.Vertical = 0
 
+	tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(app.Config.Theme.Background)
+	tview.Styles.BorderColor = tcell.GetColor(app.Config.Theme.Border)
+	tview.Styles.TitleColor = tcell.GetColor(app.Config.Theme.Title)
+
 	err := app.Run()
 	if err != nil {
 		panic(err)