use ratatui::{
layout::{Constraint, Direction, Layout},
prelude::Rect,
};
pub fn calculate_modal_layout(area: Rect) -> (Rect, Rect, Rect) {
let w = area.width.saturating_sub(6).min(96);
let h = area.height.saturating_sub(8).min(32);
let x = area.x + (area.width.saturating_sub(w)) / 2;
let y = area.y + (area.height.saturating_sub(h)) / 2;
let rect = Rect {
x,
y,
width: w,
height: h,
};
let keybinds_height = 4;
let layout = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Min(1), Constraint::Length(keybinds_height)])
.split(rect);
let content_rect = layout[0];
let keybinds_rect = layout[1];
(rect, content_rect, keybinds_rect)
}