From 7af3035e5af4191fb6721b3b6f62cbbe4bc43cac Mon Sep 17 00:00:00 2001 From: Thomas Baag Date: Sat, 21 Sep 2024 08:28:02 +0200 Subject: [PATCH] feat(config): add more theme configuration for UI elements (#424) Co-authored-by: Ayyan <119342035+ayn2op@users.noreply.github.com> --- cmd/guilds_tree.go | 2 ++ cmd/messages_text.go | 1 + cmd/state.go | 2 ++ internal/config/theme.go | 16 ++++++++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/guilds_tree.go b/cmd/guilds_tree.go index bc7a37a..f95d6cb 100644 --- a/cmd/guilds_tree.go +++ b/cmd/guilds_tree.go @@ -73,6 +73,7 @@ func (gt *GuildsTree) createFolderNode(folder gateway.GuildFolder) { func (gt *GuildsTree) createGuildNode(n *tview.TreeNode, g discord.Guild) { guildNode := tview.NewTreeNode(g.Name) guildNode.SetReference(g.ID) + guildNode.SetColor(tcell.GetColor(cfg.Theme.GuildsTree.GuildColor)) n.AddChild(guildNode) } @@ -124,6 +125,7 @@ func (gt *GuildsTree) createChannelNode(n *tview.TreeNode, c discord.Channel) *t channelNode := tview.NewTreeNode(gt.channelToString(c)) channelNode.SetReference(c.ID) + channelNode.SetColor(tcell.GetColor(cfg.Theme.GuildsTree.ChannelColor)) n.AddChild(channelNode) return channelNode } diff --git a/cmd/messages_text.go b/cmd/messages_text.go index f4340c9..41fee40 100644 --- a/cmd/messages_text.go +++ b/cmd/messages_text.go @@ -39,6 +39,7 @@ func newMessagesText() *MessagesText { app.Draw() }) + mt.SetTextColor(tcell.GetColor(cfg.Theme.MessagesText.ContentColor)) mt.SetBackgroundColor(tcell.GetColor(cfg.Theme.BackgroundColor)) mt.SetTitle("Messages") diff --git a/cmd/state.go b/cmd/state.go index 40f4b66..741ccea 100644 --- a/cmd/state.go +++ b/cmd/state.go @@ -12,6 +12,7 @@ import ( "github.com/diamondburned/arikawa/v3/gateway" "github.com/diamondburned/arikawa/v3/utils/httputil/httpdriver" "github.com/diamondburned/ningen/v3" + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) @@ -54,6 +55,7 @@ func (s *State) onRequest(r httpdriver.Request) error { func (s *State) onReady(r *gateway.ReadyEvent) { root := mainFlex.guildsTree.GetRoot() dmNode := tview.NewTreeNode("Direct Messages") + dmNode.SetColor(tcell.GetColor(cfg.Theme.GuildsTree.PrivateChannelColor)) root.AddChild(dmNode) // Track guilds that have a parent (folder) to add orphan channels later diff --git a/internal/config/theme.go b/internal/config/theme.go index cea85a8..87ad987 100644 --- a/internal/config/theme.go +++ b/internal/config/theme.go @@ -16,12 +16,16 @@ type ( } GuildsTreeTheme struct { - AutoExpandFolders bool `toml:"auto_expand_folders"` - Graphics bool `toml:"graphics"` + AutoExpandFolders bool `toml:"auto_expand_folders"` + ChannelColor string `toml:"channel_color"` + Graphics bool `toml:"graphics"` + GuildColor string `toml:"guild_color"` + PrivateChannelColor string `toml:"private_channel_color"` } MessagesTextTheme struct { AuthorColor string `toml:"author_color"` + ContentColor string `toml:"content_color"` EmoteColor string `toml:"emote_color"` ReplyIndicator string `toml:"reply_indicator"` } @@ -37,11 +41,15 @@ func defaultTheme() Theme { TitleColor: "default", GuildsTree: GuildsTreeTheme{ - AutoExpandFolders: true, - Graphics: true, + AutoExpandFolders: true, + ChannelColor: tview.Styles.PrimaryTextColor.String(), + Graphics: true, + GuildColor: tview.Styles.PrimaryTextColor.String(), + PrivateChannelColor: tview.Styles.PrimaryTextColor.String(), }, MessagesText: MessagesTextTheme{ AuthorColor: "aqua", + ContentColor: tview.Styles.PrimaryTextColor.String(), EmoteColor: "green", ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ", },