Skip to main content

stynx_code_tui/widgets/
summary_bar.rs

1use ratatui::{
2    buffer::Buffer,
3    layout::Rect,
4    style::{Modifier, Style},
5    text::{Line, Span},
6    widgets::{Block, Paragraph, Widget},
7};
8
9use crate::theme;
10
11pub struct SummaryBar<'a> {
12    pub text: &'a str,
13}
14
15impl<'a> SummaryBar<'a> {
16    pub fn new(text: &'a str) -> Self {
17        Self { text }
18    }
19}
20
21impl<'a> Widget for SummaryBar<'a> {
22    fn render(self, area: Rect, buf: &mut Buffer) {
23        let line = Line::from(vec![
24            Span::styled("  ✓  ", Style::default().fg(theme::SUCCESS()).add_modifier(Modifier::BOLD)),
25            Span::styled(self.text.to_string(), Style::default().fg(theme::SUBTLE()).add_modifier(Modifier::ITALIC)),
26        ]);
27        Paragraph::new(line)
28            .block(Block::default().style(Style::default().bg(theme::SURFACE())))
29            .render(area, buf);
30    }
31}