[Add] Performance graphs won't show if UI is small
This commit is contained in:
parent
bfefa46839
commit
fb09972438
2 changed files with 47 additions and 23 deletions
|
|
@ -35,6 +35,7 @@ pub enum DataTypes {
|
|||
denied_profiles,
|
||||
content,
|
||||
messages,
|
||||
notifications,
|
||||
send_time,
|
||||
get_time,
|
||||
get_variant,
|
||||
|
|
@ -142,6 +143,11 @@ pub enum CommunicationType {
|
|||
message_other_iota,
|
||||
message_chunk,
|
||||
messages_get,
|
||||
|
||||
push_notification,
|
||||
read_notification,
|
||||
get_notifications,
|
||||
|
||||
change_confirm,
|
||||
confirm_receive,
|
||||
confirm_read,
|
||||
|
|
|
|||
|
|
@ -54,52 +54,70 @@ pub async fn render_tui() {
|
|||
let mut terminal = TERMINAL.lock().await;
|
||||
let _ = terminal.draw(|f| {
|
||||
let area = f.area();
|
||||
let chunks = Layout::default()
|
||||
|
||||
let is_horizontal = area.width >= 120;
|
||||
let chunks = if is_horizontal {
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([
|
||||
Constraint::Percentage(40),
|
||||
Constraint::Percentage(60),
|
||||
Constraint::Min(40),
|
||||
])
|
||||
.split(area);
|
||||
.split(area)
|
||||
} else {
|
||||
Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Percentage(40), Constraint::Percentage(60)])
|
||||
.split(area)
|
||||
};
|
||||
|
||||
let state = APP_STATE.lock().unwrap().clone();
|
||||
|
||||
// LOGS PANEL
|
||||
{
|
||||
let borders = if is_horizontal {
|
||||
Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)
|
||||
} else {
|
||||
Borders::LEFT.union(Borders::RIGHT).union(Borders::TOP)
|
||||
};
|
||||
let items: Vec<ListItem> = state
|
||||
.logs
|
||||
.iter()
|
||||
.rev()
|
||||
.map(|s| ListItem::new(s.clone()))
|
||||
.collect();
|
||||
let list = List::new(items).block(
|
||||
Block::default()
|
||||
.title("Logs")
|
||||
.borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)),
|
||||
);
|
||||
let list = List::new(items).block(Block::default().title("Logs").borders(borders));
|
||||
f.render_widget(list, chunks[0]);
|
||||
}
|
||||
// SETTINGS PANEL
|
||||
{
|
||||
let borders = if is_horizontal {
|
||||
Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)
|
||||
} else {
|
||||
Borders::ALL
|
||||
};
|
||||
settings_panel::draw(
|
||||
f,
|
||||
chunks[1],
|
||||
Block::default()
|
||||
.title("Settings")
|
||||
.borders(Borders::LEFT.union(Borders::TOP).union(Borders::BOTTOM)),
|
||||
Block::default().title("Settings").borders(borders),
|
||||
password,
|
||||
state.clone(),
|
||||
);
|
||||
if is_horizontal {
|
||||
draw_block_joins(
|
||||
f,
|
||||
chunks[1],
|
||||
Borders::TOP.union(Borders::LEFT).union(Borders::BOTTOM),
|
||||
Borders::LEFT,
|
||||
);
|
||||
} else {
|
||||
draw_block_joins(f, chunks[1], Borders::ALL, Borders::TOP);
|
||||
}
|
||||
}
|
||||
|
||||
// PERFORMANCE GRAPHS
|
||||
{
|
||||
if is_horizontal {
|
||||
let stack = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
|
|
|
|||
Loading…
Reference in a new issue