Testing ratatui
This commit is contained in:
parent
28483fe165
commit
843d05bec9
9 changed files with 349 additions and 9 deletions
30
src/ui/components/header.rs
Normal file
30
src/ui/components/header.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use crate::i18n::t;
|
||||
use crate::ui::dashboard::model::DashboardViewState;
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::{Alignment, Rect},
|
||||
style::{Color, Style, Stylize},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
};
|
||||
|
||||
pub fn render_header(frame: &mut Frame, area: Rect, state: &DashboardViewState) {
|
||||
let title = if state.is_loading {
|
||||
t("loading").to_string()
|
||||
} else {
|
||||
format!("{} - {}", t("dashboard-heaser"), state.title)
|
||||
};
|
||||
|
||||
let header = Paragraph::new(Line::from(vec![
|
||||
Span::styled("📈 ", Style::default().fg(Color::Cyan)),
|
||||
Span::styled(title, Style::default().fg(Color::White).bold()),
|
||||
]))
|
||||
.alignment(Alignment::Center)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.style(Style::default().fg(Color::Blue)),
|
||||
);
|
||||
|
||||
frame.render_widget(header, area);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue