Better controls, mark unread

This commit is contained in:
cool-mist 2025-07-22 00:21:27 +05:30
parent df0370b01e
commit d43996d049
2 changed files with 12 additions and 20 deletions

View File

@ -60,20 +60,20 @@ impl<'a> Widget for ArticlesWidget<'a> {
let mut lines = Vec::new(); let mut lines = Vec::new();
let id = Span::styled( let id = Span::styled(
format!("{:>3}. ", idx + 1), format!("{:>3}. ", idx + 1),
get_channel_id_style(current_highlighted), get_article_id_style(current_highlighted),
); );
let title = Span::styled( let title = Span::styled(
article.title.clone(), article.title.clone(),
get_channel_title_style(current_highlighted), get_article_title_style(current_highlighted),
); );
lines.push(Line::from(vec![id, title])); let unread = if article.unread {
if let Some(pub_date) = article.pub_date { Span::styled(" (unread)", Style::default().fg(Color::Red))
let pub_date_text = format!("Published: {}", pub_date); } else {
let pub_date_span = Span::styled(pub_date_text, get_channel_pub_date_style(false)); Span::raw("")
lines.push(Line::from(vec![pub_date_span])); };
}
lines.push(Line::from(vec![id, title, unread]));
let para = Paragraph::new(lines) let para = Paragraph::new(lines)
.block(Block::default()) .block(Block::default())
.style(get_channel_list_item_block_style(current_highlighted)) .style(get_channel_list_item_block_style(current_highlighted))
@ -83,7 +83,7 @@ impl<'a> Widget for ArticlesWidget<'a> {
} }
} }
fn get_channel_id_style(highlighted: bool) -> Style { fn get_article_id_style(highlighted: bool) -> Style {
if highlighted { if highlighted {
Style::default() Style::default()
.fg(Color::Black) .fg(Color::Black)
@ -103,17 +103,7 @@ fn get_channel_list_item_block_style(highlighted: bool) -> Style {
} }
} }
fn get_channel_pub_date_style(highlighted: bool) -> Style { fn get_article_title_style(highlighted: bool) -> Style {
if highlighted {
Style::default()
.fg(Color::Black)
.add_modifier(Modifier::BOLD)
} else {
Style::default()
}
}
fn get_channel_title_style(highlighted: bool) -> Style {
if highlighted { if highlighted {
Style::default() Style::default()
.fg(Color::Black) .fg(Color::Black)

View File

@ -32,6 +32,8 @@ pub fn parse_ui_action(raw_event: Event) -> UiAction {
return match key_event.code { return match key_event.code {
KeyCode::Char('l') => UiAction::FocusPaneRight, KeyCode::Char('l') => UiAction::FocusPaneRight,
KeyCode::Char('h') => UiAction::FocusPaneLeft, KeyCode::Char('h') => UiAction::FocusPaneLeft,
KeyCode::Char('k') => UiAction::FocusEntryUp,
KeyCode::Char('j') => UiAction::FocusEntryDown,
KeyCode::Char('d') => UiAction::ToggleDebug, KeyCode::Char('d') => UiAction::ToggleDebug,
KeyCode::Char('q') => UiAction::Exit, KeyCode::Char('q') => UiAction::Exit,
KeyCode::Enter => UiAction::OpenArticle, KeyCode::Enter => UiAction::OpenArticle,