Skip to content

Commit

Permalink
feat(reader): Update feed tree and panes style
Browse files Browse the repository at this point in the history
  • Loading branch information
bow committed Dec 27, 2023
1 parent 52731a9 commit ac7a79e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
16 changes: 10 additions & 6 deletions internal/reader/feeds_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
}
}
}

Expand Down Expand Up @@ -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)
}

Expand Down
30 changes: 20 additions & 10 deletions internal/reader/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,15 +68,17 @@ 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() {
theme.BorderForeground = theme.BorderForegroundNormal
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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ac7a79e

Please sign in to comment.