From ac7a79ea2d42bb9a524eee50266038702f3c3203 Mon Sep 17 00:00:00 2001 From: Wibowo Arindrarto Date: Wed, 27 Dec 2023 05:00:28 +0100 Subject: [PATCH] feat(reader): Update feed tree and panes style --- internal/reader/feeds_pane.go | 16 ++++++++++------ internal/reader/theme.go | 30 ++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/internal/reader/feeds_pane.go b/internal/reader/feeds_pane.go index 170fbaa..0ebc534 100644 --- a/internal/reader/feeds_pane.go +++ b/internal/reader/feeds_pane.go @@ -79,7 +79,8 @@ func (fp *feedsPane) initTree() { tree := tview.NewTreeView(). SetRoot(root). - SetGraphicsColor(fp.theme.FeedsGroup). + SetGraphics(false). + SetPrefixes([]string{"", "ยท "}). SetCurrentNode(root). SetTopLevel(1) @@ -148,8 +149,11 @@ func (fp *feedsPane) makeDrawFuncs() (focusf, unfocusf drawFunc) { } func (fp *feedsPane) refreshColors() { - for _, node := range fp.TreeView.GetRoot().GetChildren() { - node.SetColor(fp.theme.FeedsGroup) + for _, gnode := range fp.TreeView.GetRoot().GetChildren() { + gnode.SetColor(fp.theme.FeedGroupNode) + for _, fnode := range gnode.GetChildren() { + fnode.SetColor(fp.theme.FeedNode) + } } } @@ -180,17 +184,17 @@ func (ug feedUpdatedGroup) Text(theme *Theme) string { } } -func feedNode(feed *internal.Feed, _ *Theme) *tview.TreeNode { +func feedNode(feed *internal.Feed, theme *Theme) *tview.TreeNode { return tview.NewTreeNode(feed.Title). SetReference(feed.FeedURL). - SetColor(tcell.ColorWhite). + SetColor(theme.FeedNode). SetSelectable(true) } func groupNode(ug feedUpdatedGroup, theme *Theme) *tview.TreeNode { return tview.NewTreeNode(ug.Text(theme)). SetReference(ug). - SetColor(theme.FeedsGroup). + SetColor(theme.FeedGroupNode). SetSelectable(true) } diff --git a/internal/reader/theme.go b/internal/reader/theme.go index 6d2ab3c..9dd337a 100644 --- a/internal/reader/theme.go +++ b/internal/reader/theme.go @@ -33,9 +33,13 @@ type Theme struct { TitleForegroundNormal tcell.Color TitleForegroundDim tcell.Color - FeedsGroup tcell.Color - FeedsGroupNormal tcell.Color - FeedsGroupDim tcell.Color + FeedGroupNode tcell.Color + FeedGroupNodeNormal tcell.Color + FeedGroupNodeDim tcell.Color + + FeedNode tcell.Color + FeedNodeNormal tcell.Color + FeedNodeDim tcell.Color LastPullForeground tcell.Color LastPullForegroundNormal tcell.Color @@ -64,7 +68,8 @@ func (theme *Theme) Dim() { theme.TitleForeground = theme.TitleForegroundDim theme.LastPullForeground = theme.LastPullForegroundDim theme.EventInfoForeground = theme.EventInfoForegroundDim - theme.FeedsGroup = theme.FeedsGroupDim + theme.FeedGroupNode = theme.FeedGroupNodeDim + theme.FeedNode = theme.FeedNodeDim } func (theme *Theme) Normalize() { @@ -72,7 +77,8 @@ func (theme *Theme) Normalize() { theme.TitleForeground = theme.TitleForegroundNormal theme.LastPullForeground = theme.LastPullForegroundNormal theme.EventInfoForeground = theme.EventInfoForegroundNormal - theme.FeedsGroup = theme.FeedsGroupNormal + theme.FeedGroupNode = theme.FeedGroupNodeNormal + theme.FeedNode = theme.FeedNodeNormal } func (theme *Theme) lineStyle() tcell.Style { @@ -104,13 +110,17 @@ var DarkTheme = &Theme{ BorderForegroundNormal: tcell.ColorWhite, BorderForegroundDim: darkForegroundDim, - TitleForeground: tcell.ColorYellow, - TitleForegroundNormal: tcell.ColorYellow, + TitleForeground: tcell.ColorAqua, + TitleForegroundNormal: tcell.ColorAqua, TitleForegroundDim: darkForegroundDim, - FeedsGroup: tcell.ColorGrey, - FeedsGroupNormal: tcell.ColorGrey, - FeedsGroupDim: darkForegroundDim, + FeedGroupNode: tcell.ColorGrey, + FeedGroupNodeNormal: tcell.ColorGrey, + FeedGroupNodeDim: darkForegroundDim, + + FeedNode: tcell.ColorWhite, + FeedNodeNormal: tcell.ColorWhite, + FeedNodeDim: darkForegroundDim, LastPullForeground: tcell.ColorGray, LastPullForegroundNormal: tcell.ColorGray,