Files
zesdex/crates/zesdex-backend/src/view/overlays/loading.rs
T

36 lines
1.3 KiB
Rust
Raw Normal View History

//! Overlay: loading / processing spinner — shown during blocking operations
//! (e.g., streaming response, tool execution).
//!
//! Flow: renders an animated spinner frame from `state.misc.tick_count` with
//! a "Processing, please wait..." message.
use ratatui::style::{Modifier, Style};
use ratatui::text::Span;
use ratatui::widgets::{Block, Paragraph};
use ratatui::Frame;
use crate::view::theme::Theme;
use tracing;
/// Render the Loading overlay — spinner animation + processing message.
pub fn render(
frame: &mut Frame,
area: ratatui::layout::Rect,
block: Block<'static>,
state: &crate::app::state::rest::AppStateRest,
) {
tracing::debug!("overlay: Loading");
let block = block
.title(Span::styled(
" Loading ",
Style::default()
.fg(Theme::WARNING)
.add_modifier(Modifier::BOLD),
))
.border_style(Style::default().fg(Theme::WARNING));
let spinner = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
let frame_idx = (state.misc.tick_count as usize) % spinner.len();
let content = format!(" {} Processing, please wait...", spinner[frame_idx]);
let paragraph = Paragraph::new(content).block(block);
frame.render_widget(paragraph, area);
}