Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccd76eabdd | ||
|
|
fabe1e0ca7 | ||
|
|
9bf1d065d5 |
4
client/src/components/admin.rs
Normal file
4
client/src/components/admin.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// src/components/admin.rs
|
||||||
|
pub mod admin_panel;
|
||||||
|
|
||||||
|
pub use admin_panel::*;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/components/handlers/admin_panel.rs
|
// src/components/admin/admin_panel.rs
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::Style,
|
style::Style,
|
||||||
8
client/src/components/common.rs
Normal file
8
client/src/components/common.rs
Normal 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::*;
|
||||||
@@ -1,18 +1,8 @@
|
|||||||
// src/components/handlers.rs
|
// src/components/handlers.rs
|
||||||
pub mod form;
|
pub mod form;
|
||||||
pub mod command_line;
|
|
||||||
pub mod status_line;
|
|
||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
pub mod sidebar;
|
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 form::*;
|
||||||
pub use status_line::render_status_line;
|
|
||||||
pub use canvas::*;
|
pub use canvas::*;
|
||||||
pub use sidebar::*;
|
pub use sidebar::*;
|
||||||
pub use background::*;
|
|
||||||
pub use intro::*;
|
|
||||||
pub use admin_panel::*;
|
|
||||||
|
|||||||
4
client/src/components/intro.rs
Normal file
4
client/src/components/intro.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// src/components/intro.rs
|
||||||
|
pub mod intro;
|
||||||
|
|
||||||
|
pub use intro::*;
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
// src/components/mod.rs
|
// src/components/mod.rs
|
||||||
pub mod models;
|
|
||||||
pub mod handlers;
|
pub mod handlers;
|
||||||
|
pub mod intro;
|
||||||
|
pub mod admin;
|
||||||
|
pub mod common;
|
||||||
|
|
||||||
pub use handlers::*;
|
pub use handlers::*;
|
||||||
|
pub use intro::*;
|
||||||
|
pub use admin::*;
|
||||||
|
pub use common::*;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ impl EventHandler {
|
|||||||
app_state: &mut crate::state::state::AppState,
|
app_state: &mut crate::state::state::AppState,
|
||||||
total_count: u64,
|
total_count: u64,
|
||||||
current_position: &mut 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>> {
|
) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||||
if app_state.ui.show_intro {
|
if app_state.ui.show_intro {
|
||||||
if let Event::Key(key) = event {
|
if let Event::Key(key) = event {
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ use crate::components::{
|
|||||||
render_background,
|
render_background,
|
||||||
render_command_line,
|
render_command_line,
|
||||||
render_status_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 crate::config::colors::Theme;
|
||||||
use ratatui::layout::{Constraint, Direction, Layout};
|
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);
|
sidebar::render_sidebar(f, sidebar_rect, theme, &app_state.profile_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
let form_constraint = Layout::default()
|
// This change makes the form stay stationary when toggling sidebar
|
||||||
.direction(Direction::Horizontal)
|
let available_width = form_area.width;
|
||||||
.constraints([
|
let form_constraint = if available_width >= 80 {
|
||||||
Constraint::Min(0),
|
// Use main_content_area for centering when enough space
|
||||||
Constraint::Length(80.min(form_area.width)),
|
Layout::default()
|
||||||
Constraint::Min(0),
|
.direction(Direction::Horizontal)
|
||||||
])
|
.constraints([
|
||||||
.split(form_area)[1];
|
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]
|
// Convert fields to &[&str] and values to &[&String]
|
||||||
let fields: Vec<&str> = form_state.fields.iter().map(|s| s.as_str()).collect();
|
let fields: Vec<&str> = form_state.fields.iter().map(|s| s.as_str()).collect();
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ use crate::config::config::Config;
|
|||||||
use crate::ui::handlers::{form::FormState, render::render_ui};
|
use crate::ui::handlers::{form::FormState, render::render_ui};
|
||||||
use crate::modes::handlers::event::EventHandler;
|
use crate::modes::handlers::event::EventHandler;
|
||||||
use crate::state::state::AppState;
|
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>> {
|
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::load()?;
|
let config = Config::load()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user