feat: improve empty hint

This commit is contained in:
itsscb 2025-07-26 21:51:40 +02:00
parent c704dd1a47
commit 3ff7770471

View File

@ -428,8 +428,10 @@ impl Widget for &mut App {
Color::White Color::White
}; };
let items: Vec<Row> = self let items: Vec<Row> = if self.logs.is_empty() {
.logs vec![Row::new(vec!["Nothing here yet"])]
} else {
self.logs
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, item)| { .map(|(i, item)| {
@ -457,22 +459,16 @@ impl Widget for &mut App {
.style(Style::new().fg(row_text_color)) .style(Style::new().fg(row_text_color))
.height(2) .height(2)
}) })
.collect(); .collect()
};
let empty = items.is_empty(); let table = Table::new(items, [Constraint::Min(200), Constraint::Min(20)])
let mut table = Table::new(items, [Constraint::Min(200), Constraint::Min(20)])
.block(block) .block(block)
.header(header) .header(header)
.highlight_symbol("> ") .highlight_symbol("> ")
.row_highlight_style(highlight_style) .row_highlight_style(highlight_style)
.highlight_spacing(HighlightSpacing::Always); .highlight_spacing(HighlightSpacing::Always);
if empty {
table = table.footer(
Row::new(vec!["Nothing here yet"]).style(Style::default().fg(COLOR_SECONDARY)),
);
}
StatefulWidget::render(table, area, buf, &mut self.state); StatefulWidget::render(table, area, buf, &mut self.state);
} }
} }