displaying admin panel properly well
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// src/ui/handlers/render.rs
|
||||
|
||||
use crate::components::{
|
||||
render_background,
|
||||
render_command_line,
|
||||
render_status_line,
|
||||
handlers::{sidebar::{self, calculate_sidebar_layout}, intro, admin_panel::AdminPanelState},
|
||||
handlers::{sidebar::{self, calculate_sidebar_layout}, intro, admin_panel::AdminPanelState, form::render_form},
|
||||
};
|
||||
use crate::config::colors::Theme;
|
||||
use ratatui::layout::{Constraint, Direction, Layout};
|
||||
@@ -28,61 +29,55 @@ pub fn render_ui(
|
||||
) {
|
||||
render_background(f, f.area(), theme);
|
||||
|
||||
if app_state.ui.show_intro {
|
||||
intro_state.render(f, f.area(), theme);
|
||||
return;
|
||||
}
|
||||
|
||||
let root = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
Constraint::Min(10),
|
||||
Constraint::Min(1),
|
||||
Constraint::Length(1),
|
||||
Constraint::Length(1),
|
||||
])
|
||||
.split(f.area());
|
||||
|
||||
let main_content_area = root[0];
|
||||
let (sidebar_area, form_area) = if app_state.ui.show_admin {
|
||||
(None, main_content_area)
|
||||
if app_state.ui.show_intro {
|
||||
intro_state.render(f, main_content_area, theme);
|
||||
} else if app_state.ui.show_admin {
|
||||
admin_panel_state.render(f, main_content_area, theme);
|
||||
} else {
|
||||
calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area)
|
||||
};
|
||||
let available_width = form_area.width;
|
||||
let (sidebar_area, form_area) = calculate_sidebar_layout(
|
||||
app_state.ui.show_sidebar,
|
||||
main_content_area
|
||||
);
|
||||
|
||||
let form_constraint = if available_width >= 80 {
|
||||
Layout::default()
|
||||
if let Some(sidebar_rect) = sidebar_area {
|
||||
sidebar::render_sidebar(f, sidebar_rect, theme, &app_state.profile_tree);
|
||||
}
|
||||
|
||||
let form_constraint = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(80),
|
||||
Constraint::Length(80.min(form_area.width)),
|
||||
Constraint::Min(0),
|
||||
])
|
||||
.split(main_content_area)[1]
|
||||
} else {
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([
|
||||
Constraint::Min(0),
|
||||
Constraint::Length(80.min(available_width)),
|
||||
Constraint::Min(0),
|
||||
])
|
||||
.split(form_area)[1]
|
||||
};
|
||||
.split(form_area)[1];
|
||||
|
||||
form_state.render(
|
||||
// Convert fields to &[&str] and values to &[&String]
|
||||
let fields: Vec<&str> = form_state.fields.iter().map(|s| s.as_str()).collect();
|
||||
let values: Vec<&String> = form_state.values.iter().collect();
|
||||
|
||||
render_form(
|
||||
f,
|
||||
form_constraint,
|
||||
form_state,
|
||||
&fields,
|
||||
&form_state.current_field,
|
||||
&values,
|
||||
theme,
|
||||
is_edit_mode,
|
||||
total_count,
|
||||
current_position,
|
||||
);
|
||||
|
||||
if app_state.ui.show_admin {
|
||||
admin_panel_state.render(f, form_area, theme);
|
||||
} else if let Some(sidebar_rect) = sidebar_area {
|
||||
sidebar::render_sidebar(f, sidebar_rect, theme, &app_state.profile_tree);
|
||||
}
|
||||
|
||||
render_status_line(f, root[1], current_dir, theme, is_edit_mode);
|
||||
|
||||
Reference in New Issue
Block a user