//! UI rendering module. //! //! Routes rendering by screen (Loading → Auth → Main) and checks terminal size. mod auth; pub mod chat_list; mod compose_bar; pub mod components; pub mod footer; mod loading; mod main_screen; pub mod messages; mod modals; pub mod profile; use crate::app::{App, AppScreen}; use crate::tdlib::TdClientTrait; use ratatui::layout::Alignment; use ratatui::style::{Color, Modifier, Style}; use ratatui::widgets::Paragraph; use ratatui::Frame; /// Минимальная высота терминала const MIN_HEIGHT: u16 = 10; /// Минимальная ширина терминала const MIN_WIDTH: u16 = 40; pub fn render(f: &mut Frame, app: &mut App) { let area = f.area(); // Проверяем минимальный размер терминала if area.width < MIN_WIDTH || area.height < MIN_HEIGHT { render_size_warning(f, area.width, area.height); return; } match app.screen { AppScreen::Loading => loading::render(f, app), AppScreen::Auth => auth::render(f, app), AppScreen::Main => main_screen::render(f, app), } // Global overlay: account switcher (renders on top of ANY screen) if app.account_switcher.is_some() { modals::render_account_switcher(f, area, app); } } fn render_size_warning(f: &mut Frame, width: u16, height: u16) { let message = format!("{}x{}\nМинимум: {}x{}", width, height, MIN_WIDTH, MIN_HEIGHT); let warning = Paragraph::new(message) .style( Style::default() .fg(Color::Yellow) .add_modifier(Modifier::BOLD), ) .alignment(Alignment::Center); f.render_widget(warning, f.area()); }