zilliz 1.4.3

TUI and CLI tool for managing Zilliz Cloud clusters and Milvus operations
Documentation
use ratatui::prelude::*;

use super::app::{App, Screen};
use super::views;
use super::widgets::status_bar;

/// Root render function: splits the frame into [content, status bar] and
/// dispatches the content area based on the top of the screen stack.
pub fn render(frame: &mut Frame, app: &App) {
    let area = frame.area();
    let layout = Layout::vertical([Constraint::Min(0), Constraint::Length(1)]).split(area);
    let content = layout[0];
    let bar = layout[1];

    // If Help is on top, render the screen *below* it first then overlay.
    let top = app.current_screen().clone();
    let host = if matches!(top, Screen::Help) {
        app.screen_below_top().cloned().unwrap_or(Screen::Home)
    } else {
        top.clone()
    };

    render_screen(frame, app, content, &host);

    if matches!(top, Screen::Help) {
        views::help_overlay::render(frame, app, content);
    }

    status_bar::render(frame, app, bar);
}

fn render_screen(frame: &mut Frame, app: &App, area: Rect, screen: &Screen) {
    match screen {
        Screen::Home => views::home::render(frame, app, area),
        Screen::SignInRegion => views::sign_in_region::render(frame, app, area),
        Screen::SignInMethod => views::sign_in_method::render(frame, app, area),
        Screen::SignInBrowser => views::sign_in_browser::render(frame, app, area),
        Screen::SignInApiKey => views::sign_in_api_key::render(frame, app, area),
        Screen::LogoutConfirm => {
            // Render the home behind, then the confirm card on top.
            views::home::render(frame, app, area);
            views::logout_confirm::render(frame, app, area);
        }
        // Help is handled at the caller layer (overlay over host screen).
        Screen::Help => views::home::render(frame, app, area),
    }
}