From 4bf808523906c0300f964a7302c1ff33533916ba Mon Sep 17 00:00:00 2001 From: rigormorrtiss Date: Wed, 18 Aug 2021 19:48:32 +0400 Subject: [PATCH] refactor(util): remove *{Background,Foreground} in favor of Background & Foreground --- discordo.go | 6 ++++-- ui/inputfields.go | 6 +++--- ui/textviews.go | 5 +---- ui/treeviews.go | 5 +---- util/config.go | 6 ++---- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/discordo.go b/discordo.go index 30e7abb..ff54dcf 100644 --- a/discordo.go +++ b/discordo.go @@ -46,9 +46,11 @@ func main() { tview.Borders.BottomRight = ' ' conf = util.NewConfig() + tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(conf.Theme.Background) + app = ui.NewApp(onAppInputCapture) - guildsTreeView = ui.NewGuildsTreeView(onGuildsTreeViewSelected, conf.Theme) - messagesTextView = ui.NewMessagesTextView(app, conf.Theme) + guildsTreeView = ui.NewGuildsTreeView(onGuildsTreeViewSelected) + messagesTextView = ui.NewMessagesTextView(app) messageInputField = ui.NewMessageInputField(onMessageInputFieldInputCapture, conf.Theme) mainFlex = ui.NewMainFlex(guildsTreeView, messagesTextView, messageInputField) diff --git a/ui/inputfields.go b/ui/inputfields.go index b8babd9..e48e24f 100644 --- a/ui/inputfields.go +++ b/ui/inputfields.go @@ -6,13 +6,13 @@ import ( "github.com/rivo/tview" ) -func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey, theme *util.Theme) (i *tview.InputField) { +func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey, t *util.Theme) (i *tview.InputField) { i = tview.NewInputField() i. SetPlaceholder("Message..."). SetPlaceholderTextColor(tcell.ColorWhite). - SetFieldBackgroundColor(tcell.GetColor(theme.InputFieldBackground)). - SetBackgroundColor(tcell.GetColor(theme.InputFieldBackground)). + SetFieldBackgroundColor(tcell.GetColor(t.Background)). + SetBackgroundColor(tcell.GetColor(t.Background)). SetInputCapture(onMessageInputFieldInputCapture). SetBorder(true). SetBorderPadding(0, 0, 1, 0) diff --git a/ui/textviews.go b/ui/textviews.go index b524e37..5b38667 100644 --- a/ui/textviews.go +++ b/ui/textviews.go @@ -1,12 +1,10 @@ package ui import ( - "github.com/gdamore/tcell/v2" - "github.com/rigormorrtiss/discordo/util" "github.com/rivo/tview" ) -func NewMessagesTextView(app *tview.Application, theme *util.Theme) (textV *tview.TextView) { +func NewMessagesTextView(app *tview.Application) (textV *tview.TextView) { textV = tview.NewTextView() textV. SetDynamicColors(true). @@ -15,7 +13,6 @@ func NewMessagesTextView(app *tview.Application, theme *util.Theme) (textV *tvie SetChangedFunc(func() { app.Draw() }). - SetBackgroundColor(tcell.GetColor(theme.TextViewBackground)). SetBorder(true). SetBorderPadding(0, 0, 1, 0). SetTitleAlign(tview.AlignLeft) diff --git a/ui/treeviews.go b/ui/treeviews.go index 02b2bfc..9c6485a 100644 --- a/ui/treeviews.go +++ b/ui/treeviews.go @@ -1,12 +1,10 @@ package ui import ( - "github.com/gdamore/tcell/v2" - "github.com/rigormorrtiss/discordo/util" "github.com/rivo/tview" ) -func NewGuildsTreeView(onGuildsTreeViewSelected func(*tview.TreeNode), theme *util.Theme) (treeV *tview.TreeView) { +func NewGuildsTreeView(onGuildsTreeViewSelected func(*tview.TreeNode)) (treeV *tview.TreeView) { treeV = tview.NewTreeView() treeN := tview.NewTreeNode("") treeV. @@ -14,7 +12,6 @@ func NewGuildsTreeView(onGuildsTreeViewSelected func(*tview.TreeNode), theme *ut SetRoot(treeN). SetCurrentNode(treeN). SetSelectedFunc(onGuildsTreeViewSelected). - SetBackgroundColor(tcell.GetColor(theme.TreeViewBackground)). SetTitle("Guilds"). SetBorder(true). SetBorderPadding(0, 0, 1, 0). diff --git a/util/config.go b/util/config.go index ca7b1c7..ff9488f 100644 --- a/util/config.go +++ b/util/config.go @@ -6,10 +6,8 @@ import ( ) type Theme struct { - DropDownBackground string `json:"dropdown.background"` - TreeViewBackground string `json:"treeview.background"` - TextViewBackground string `json:"textview.background"` - InputFieldBackground string `json:"inputField.background"` + Background string `json:"background"` + Foreground string `json:"foreground"` } type Config struct {