use ratatui::prelude::*;
pub fn compute(area: Rect, input_height: u16, side_panel_open: bool) -> LayoutFull {
let (main_area, side_panel) = if side_panel_open && area.width > 80 {
let h_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(62), Constraint::Percentage(38)])
.split(area);
(h_chunks[0], Some(h_chunks[1]))
} else {
(area, None)
};
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(1), Constraint::Min(3), Constraint::Length(1), Constraint::Length(input_height), Constraint::Length(1), ])
.split(main_area);
LayoutFull {
main: Layout5 {
header: chunks[0],
messages: chunks[1],
status: chunks[2],
input: chunks[3],
footer: chunks[4],
},
side_panel,
}
}
pub struct LayoutFull {
pub main: Layout5,
pub side_panel: Option<Rect>,
}
pub struct Layout5 {
pub header: Rect,
pub messages: Rect,
pub status: Rect,
pub input: Rect,
pub footer: Rect,
}