Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub struct Theme {
pub editing_fg: Color,
pub editing_title: Color,
pub overlay_text: Color,
primary: Color,
secondary: Color,
}

impl Theme {
Expand All @@ -122,8 +124,20 @@ impl Theme {
editing_fg: secondary,
editing_title: primary,
overlay_text: primary,
primary,
secondary,
}
}

#[must_use]
pub const fn primary_color(&self) -> Color {
self.primary
}

#[must_use]
pub const fn secondary_color(&self) -> Color {
self.secondary
}
}

impl ThemeName {
Expand Down
24 changes: 13 additions & 11 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,16 @@ fn draw(f: &mut ratatui::Frame<'_>, app: &App) {
f.render_widget(Clear, area);
let items: Vec<ListItem> = ThemeName::ALL
.iter()
.map(|t| {
ListItem::new(Span::styled(
t.display_name(),
Style::default().fg(theme.overlay_text),
))
.enumerate()
.map(|(idx, t)| {
let item_theme = t.theme();
let base_style = Style::default().fg(item_theme.primary_color());
let style = if idx == app.theme_selected {
base_style.bg(item_theme.secondary_color())
} else {
base_style
};
ListItem::new(Span::styled(t.display_name(), style))
})
.collect();
let mut state = ListState::default();
Expand All @@ -463,12 +468,9 @@ fn draw(f: &mut ratatui::Frame<'_>, app: &App) {
.border_type(BorderType::Plain)
.border_style(Style::default().fg(theme.overlay_border))
.style(Style::default().bg(theme.overlay_bg));
let list = List::new(items).block(block).highlight_style(
Style::default()
.bg(theme.overlay_highlight_bg)
.fg(theme.overlay_highlight_fg)
.add_modifier(Modifier::BOLD),
);
let list = List::new(items)
.block(block)
.highlight_style(Style::default().add_modifier(Modifier::BOLD));
f.render_stateful_widget(list, area, &mut state);
} else if matches!(app.mode(), InputMode::KeyCapture) {
if let Some(action) = app.capture_action {
Expand Down