speedtest-tui 0.1.1

A terminal-based network speed test tool with real-time gauges and graphs
pub mod diagnostics;
pub mod gauge;
pub mod graph;
pub mod history_view;
pub mod layout;
pub mod theme;
pub mod widgets;

use ratatui::prelude::*;

pub use theme::{Theme, ThemeName};

/// Render the main UI
pub fn render(frame: &mut Frame, app: &crate::app::App) {
    let theme = app.get_theme();
    let area = frame.area();

    // Clear with background color
    frame.render_widget(
        ratatui::widgets::Block::default().style(Style::default().bg(theme.background)),
        area,
    );

    // Main layout
    let chunks = layout::create_main_layout(area);

    // Render header
    layout::render_header(frame, chunks[0], app, &theme);

    // Render main content based on current view
    match app.current_view {
        crate::app::View::Main => {
            layout::render_main_view(frame, chunks[1], app, &theme);
        }
        crate::app::View::History => {
            history_view::render(frame, chunks[1], app, &theme);
        }
        crate::app::View::Diagnostics => {
            diagnostics::render(frame, chunks[1], app, &theme);
        }
        crate::app::View::Settings => {
            layout::render_settings_view(frame, chunks[1], app, &theme);
        }
    }

    // Render footer
    layout::render_footer(frame, chunks[2], app, &theme);

    // Render any popups
    if app.show_provider_popup {
        widgets::render_provider_popup(frame, app, &theme);
    }

    if app.show_theme_popup {
        widgets::render_theme_popup(frame, app, &theme);
    }

    if app.show_help_popup {
        widgets::render_help_popup(frame, &theme);
    }

    if app.show_results_popup {
        widgets::render_results_popup(frame, app, &theme);
    }
}