Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
lib: Fix and improve theming
Erik Kundt committed 3 months ago
commit 1f2ecd79df31c82ce1279515bc9dde1a919c8424
parent bb0ed11
3 files changed +19 -13
modified src/ui.rs
@@ -472,6 +472,7 @@ where
            .with_area(area)
            .with_layout(layout.into())
            .with_ctx(self.ctx.clone())
+
            .with_theme(self.theme.clone())
    }

    pub fn layout<R>(
modified src/ui/theme.rs
@@ -6,11 +6,11 @@ use ratatui::style::{Color, Style, Stylize};
pub struct Theme {
    pub border_style: Style,
    pub focus_border_style: Style,
+
    pub scroll_style: Style,
+
    pub focus_scroll_style: Style,
    pub shortcuts_keys_style: Style,
    pub shortcuts_action_style: Style,
    pub textview_style: Style,
-
    pub textview_scroll_style: Style,
-
    pub textview_focus_scroll_style: Style,
    pub bar_on_black_style: Style,
    pub dim_no_focus: bool,
}
@@ -26,11 +26,11 @@ impl Theme {
        Self {
            border_style: Style::default().fg(Color::Rgb(170, 170, 170)),
            focus_border_style: Style::default(),
+
            scroll_style: Style::default().fg(Color::Rgb(170, 170, 170)),
+
            focus_scroll_style: Style::default(),
            shortcuts_keys_style: style::yellow(),
            shortcuts_action_style: style::reset(),
            textview_style: style::reset(),
-
            textview_scroll_style: style::cyan().dim(),
-
            textview_focus_scroll_style: style::cyan(),
            bar_on_black_style: Style::default().on_gray(),
            dim_no_focus: false,
        }
@@ -39,12 +39,12 @@ impl Theme {
    pub fn default_dark() -> Self {
        Self {
            border_style: Style::default().fg(Color::Indexed(240)),
-
            focus_border_style: Style::default().fg(Color::Indexed(246)),
+
            focus_border_style: Style::default().cyan(),
+
            scroll_style: Style::default().fg(Color::Indexed(240)),
+
            focus_scroll_style: style::cyan(),
            shortcuts_keys_style: style::yellow().dim(),
            shortcuts_action_style: style::gray().dim(),
            textview_style: style::reset(),
-
            textview_scroll_style: style::cyan().dim(),
-
            textview_focus_scroll_style: style::cyan(),
            bar_on_black_style: Style::default().on_black(),
            dim_no_focus: false,
        }
modified src/ui/widget.rs
@@ -572,10 +572,10 @@ where
                    .track_symbol(None)
                    .end_symbol(None)
                    .thumb_symbol("┃")
-
                    .style(if area_focus {
-
                        Style::default()
+
                    .style(if ui.has_focus {
+
                        ui.theme.focus_scroll_style
                    } else {
-
                        Style::default().dim()
+
                        ui.theme.scroll_style
                    });

                let mut state = ScrollbarState::default()
@@ -739,7 +739,12 @@ where
                        .begin_symbol(None)
                        .track_symbol(None)
                        .end_symbol(None)
-
                        .thumb_symbol("┃"),
+
                        .thumb_symbol("┃")
+
                        .style(if area_focus {
+
                            ui.theme.focus_scroll_style
+
                        } else {
+
                            ui.theme.scroll_style
+
                        }),
                ))
                .highlight_style(style::highlight(ui.has_focus))
                .style(tree_style)
@@ -1016,9 +1021,9 @@ impl Widget for TextView<'_> {
            .end_symbol(None)
            .thumb_symbol("┃")
            .style(if area_focus {
-
                Style::default()
+
                ui.theme.focus_scroll_style
            } else {
-
                Style::default().dim()
+
                ui.theme.scroll_style
            });

        let mut scroller_state = ScrollbarState::default()