Compare commits

..

3 Commits

Author SHA1 Message Date
filipriec
ccd76eabdd components are redesigned 2025-03-22 15:45:55 +01:00
filipriec
fabe1e0ca7 changing components infrastructure 2025-03-22 15:36:49 +01:00
filipriec
9bf1d065d5 restored functionality 2025-03-22 15:11:08 +01:00
14 changed files with 51 additions and 23 deletions

View File

@@ -0,0 +1,4 @@
// src/components/admin.rs
pub mod admin_panel;
pub use admin_panel::*;

View File

@@ -1,4 +1,4 @@
// src/components/handlers/admin_panel.rs
// src/components/admin/admin_panel.rs
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::Style,

View File

@@ -0,0 +1,8 @@
// src/components/common.rs
pub mod command_line;
pub mod status_line;
pub mod background;
pub use command_line::*;
pub use status_line::*;
pub use background::*;

View File

@@ -1,18 +1,8 @@
// src/components/handlers.rs
pub mod form;
pub mod command_line;
pub mod status_line;
pub mod canvas;
pub mod sidebar;
pub mod background;
pub mod intro;
pub mod admin_panel;
pub use command_line::render_command_line;
pub use form::*;
pub use status_line::render_status_line;
pub use canvas::*;
pub use sidebar::*;
pub use background::*;
pub use intro::*;
pub use admin_panel::*;

View File

@@ -0,0 +1,4 @@
// src/components/intro.rs
pub mod intro;
pub use intro::*;

View File

@@ -1,5 +1,10 @@
// src/components/mod.rs
pub mod models;
pub mod handlers;
pub mod intro;
pub mod admin;
pub mod common;
pub use handlers::*;
pub use intro::*;
pub use admin::*;
pub use common::*;

View File

@@ -47,7 +47,7 @@ impl EventHandler {
app_state: &mut crate::state::state::AppState,
total_count: u64,
current_position: &mut u64,
intro_state: &mut crate::components::handlers::intro::IntroState,
intro_state: &mut crate::components::intro::intro::IntroState,
) -> Result<(bool, String), Box<dyn std::error::Error>> {
if app_state.ui.show_intro {
if let Event::Key(key) = event {

View File

@@ -4,7 +4,8 @@ use crate::components::{
render_background,
render_command_line,
render_status_line,
handlers::{sidebar::{self, calculate_sidebar_layout}, intro, admin_panel::AdminPanelState, form::render_form},
handlers::{sidebar::{self, calculate_sidebar_layout}, admin_panel::AdminPanelState, form::render_form},
intro::{intro},
};
use crate::config::colors::Theme;
use ratatui::layout::{Constraint, Direction, Layout};
@@ -53,14 +54,29 @@ pub fn render_ui(
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.min(form_area.width)),
Constraint::Min(0),
])
.split(form_area)[1];
// This change makes the form stay stationary when toggling sidebar
let available_width = form_area.width;
let form_constraint = if available_width >= 80 {
// Use main_content_area for centering when enough space
Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Min(0),
Constraint::Length(80),
Constraint::Min(0),
])
.split(main_content_area)[1]
} else {
// Use form_area (post sidebar) when limited space
Layout::default()
.direction(Direction::Horizontal)
.constraints([
Constraint::Min(0),
Constraint::Length(80.min(available_width)),
Constraint::Min(0),
])
.split(form_area)[1]
};
// Convert fields to &[&str] and values to &[&String]
let fields: Vec<&str> = form_state.fields.iter().map(|s| s.as_str()).collect();

View File

@@ -9,7 +9,8 @@ use crate::config::config::Config;
use crate::ui::handlers::{form::FormState, render::render_ui};
use crate::modes::handlers::event::EventHandler;
use crate::state::state::AppState;
use crate::components::handlers::{intro::IntroState, admin_panel::AdminPanelState};
use crate::components::handlers::{admin_panel::AdminPanelState};
use crate::components::intro::{intro::IntroState};
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::load()?;