use ratatui::layout::{Constraint, Direction, Layout, Rect};
pub fn determine_layout(count: usize, screen_width: u16) -> (u16, u16, bool) {
let use_two_column = count >= 10 && count < 30 && screen_width >= 120;
let (width, height) = if count < 10 {
(50, 35) } else if count < 30 {
if use_two_column {
(75, 45) } else {
(65, 45) }
} else {
(75, 55) };
(width, height, use_two_column)
}
pub fn center_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
let vertical = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Percentage((100 - percent_y) / 2),
Constraint::Percentage(percent_y),
Constraint::Percentage((100 - percent_y) / 2),
])
.split(r);
let horizontal = Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Percentage((100 - percent_x) / 2),
Constraint::Percentage(percent_x),
Constraint::Percentage((100 - percent_x) / 2),
])
.split(vertical[1]);
horizontal[1]
}