60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
// src/client/ui/handlers/render.rs
|
|
|
|
use crate::components::{render_command_line, render_preview_card, render_status_line};
|
|
use crate::config::colors::Theme;
|
|
use ratatui::layout::{Constraint, Direction, Layout};
|
|
use ratatui::Frame;
|
|
use super::form::FormState;
|
|
use crate::state::state::UiState;
|
|
|
|
pub fn render_ui(
|
|
f: &mut Frame,
|
|
form_state: &mut FormState,
|
|
theme: &Theme,
|
|
is_edit_mode: bool,
|
|
total_count: u64,
|
|
current_position: u64,
|
|
current_dir: &str,
|
|
command_input: &str,
|
|
command_mode: bool,
|
|
command_message: &str,
|
|
ui_state: &UiState,
|
|
) {
|
|
let root = Layout::default()
|
|
.direction(Direction::Vertical)
|
|
.constraints([
|
|
Constraint::Min(10), // Main content area
|
|
Constraint::Length(1), // Status line
|
|
Constraint::Length(1), // Command line
|
|
])
|
|
.split(f.area());
|
|
|
|
// Main content area
|
|
let main_chunks = Layout::default()
|
|
.direction(Direction::Horizontal)
|
|
.constraints([Constraint::Percentage(60), Constraint::Percentage(40)])
|
|
.split(root[0]);
|
|
|
|
// Left panel - Form
|
|
form_state.render(f, main_chunks[0], theme, is_edit_mode, total_count, current_position);
|
|
|
|
// Right panel - Preview Card
|
|
let preview_values: Vec<&String> = form_state.values.iter().collect();
|
|
render_preview_card(
|
|
f,
|
|
main_chunks[1],
|
|
&preview_values, // Pass dynamic values as &[&String]
|
|
&theme,
|
|
);
|
|
|
|
if ui_state.show_sidebar {
|
|
crate::components::handlers::sidebar::render_sidebar(f, main_chunks[0], theme);
|
|
}
|
|
|
|
// Status line
|
|
render_status_line(f, root[1], current_dir, theme, is_edit_mode);
|
|
|
|
// Command line
|
|
render_command_line(f, root[2], command_input, command_mode, theme, command_message);
|
|
}
|