sidebar fixed bugs and buffer implementation 1

This commit is contained in:
filipriec
2025-04-14 22:14:01 +02:00
parent 0917654361
commit 8745c9ea2f
8 changed files with 125 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
use crate::components::{
render_background,
render_buffer_list,
render_command_line,
render_status_line,
intro::intro::render_intro,
@@ -40,16 +41,42 @@ pub fn render_ui(
) {
render_background(f, f.area(), theme);
// Adjust layout based on whether buffer list is shown
let constraints = if app_state.ui.show_buffer_list {
vec![
Constraint::Min(1), // Main content
Constraint::Length(1), // Buffer list
Constraint::Length(1), // Status line
Constraint::Length(1), // Command line
]
} else {
vec![
Constraint::Min(1), // Main content
Constraint::Length(1), // Status line (no buffer list)
Constraint::Length(1), // Command line
]
};
let root = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Min(1),
Constraint::Length(1),
Constraint::Length(1),
])
.constraints(constraints)
.split(f.area());
let main_content_area = root[0];
let mut buffer_list_area = None;
let status_line_area;
let command_line_area;
// Assign areas based on layout
if app_state.ui.show_buffer_list {
buffer_list_area = Some(root[1]);
status_line_area = root[2];
command_line_area = root[3];
} else {
status_line_area = root[1];
command_line_area = root[2];
}
if app_state.ui.show_intro {
render_intro(f, intro_state, main_content_area, theme);
} else if app_state.ui.show_register {
@@ -61,17 +88,17 @@ pub fn render_ui(
app_state,
register_state.current_field < 4
);
}else if app_state.ui.show_login {
} else if app_state.ui.show_login {
render_login(
f,
main_content_area,
theme,
f,
main_content_area,
theme,
login_state,
app_state,
login_state.current_field < 2
);
} else if app_state.ui.show_admin {
crate::components::admin::admin_panel::render_admin_panel(
crate::components::admin::admin_panel::render_admin_panel(
f,
auth_state,
admin_state,
@@ -136,10 +163,14 @@ pub fn render_ui(
total_count,
current_position,
);
} else{
}
render_status_line(f, root[1], current_dir, theme, is_edit_mode);
render_command_line(f, root[2], command_input, command_mode, theme, command_message);
// Render buffer list if enabled and area is available
if let Some(area) = buffer_list_area {
if app_state.ui.show_buffer_list {
render_buffer_list(f, area, theme, app_state);
}
}
render_status_line(f, status_line_area, current_dir, theme, is_edit_mode);
render_command_line(f, command_line_area, command_input, command_mode, theme, command_message);
}