treewide: fix various UI bugs; optimize crypto dependencies & format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If8fe8b38c1d9c4fecd40ff71f88d2ae06a6a6964
This commit is contained in:
parent
764aafa88d
commit
3ccddce7fd
178 changed files with 58342 additions and 54241 deletions
|
|
@ -1,55 +1,57 @@
|
|||
use ratatui::Frame;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, Borders, Paragraph};
|
||||
use ratatui::{
|
||||
Frame,
|
||||
layout::Rect,
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
};
|
||||
|
||||
use crate::app::AppState;
|
||||
|
||||
pub fn render(f: &mut Frame, state: &AppState, area: Rect) {
|
||||
let label_style = Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
let value_style = Style::default().fg(Color::White);
|
||||
let section_style = Style::default()
|
||||
.fg(Color::Cyan)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
let label_style = Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
let value_style = Style::default().fg(Color::White);
|
||||
let section_style = Style::default()
|
||||
.fg(Color::Cyan)
|
||||
.add_modifier(Modifier::BOLD);
|
||||
|
||||
let pad = " ";
|
||||
let pad = " ";
|
||||
|
||||
let mut lines = vec![
|
||||
Line::default(),
|
||||
Line::from(Span::styled("--- Database Statistics ---", section_style)),
|
||||
];
|
||||
let mut lines = vec![
|
||||
Line::default(),
|
||||
Line::from(Span::styled("--- Database Statistics ---", section_style)),
|
||||
];
|
||||
|
||||
if let Some(ref stats) = state.database_stats {
|
||||
for (key, value) in stats {
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::styled(format!("{key:<20}"), label_style),
|
||||
Span::styled(value.to_string(), value_style),
|
||||
]));
|
||||
}
|
||||
} else {
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::raw("Press 'r' to load database statistics"),
|
||||
]));
|
||||
if let Some(ref stats) = state.database_stats {
|
||||
for (key, value) in stats {
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::styled(format!("{key:<20}"), label_style),
|
||||
Span::styled(value.to_string(), value_style),
|
||||
]));
|
||||
}
|
||||
|
||||
lines.push(Line::default());
|
||||
lines.push(Line::from(Span::styled("--- Actions ---", section_style)));
|
||||
} else {
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::raw("v: Vacuum database"),
|
||||
]));
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::raw("Esc: Return to library"),
|
||||
Span::raw(pad),
|
||||
Span::raw("Press 'r' to load database statistics"),
|
||||
]));
|
||||
}
|
||||
|
||||
let paragraph =
|
||||
Paragraph::new(lines).block(Block::default().borders(Borders::ALL).title(" Database "));
|
||||
lines.push(Line::default());
|
||||
lines.push(Line::from(Span::styled("--- Actions ---", section_style)));
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::raw("v: Vacuum database"),
|
||||
]));
|
||||
lines.push(Line::from(vec![
|
||||
Span::raw(pad),
|
||||
Span::raw("Esc: Return to library"),
|
||||
]));
|
||||
|
||||
f.render_widget(paragraph, area);
|
||||
let paragraph = Paragraph::new(lines)
|
||||
.block(Block::default().borders(Borders::ALL).title(" Database "));
|
||||
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue