functions are now in the file dedicated to the functions belonging to the page
This commit is contained in:
@@ -4,6 +4,7 @@ use crossterm::event::KeyEvent;
|
||||
use crate::config::binds::config::Config;
|
||||
use crate::state::state::AppState;
|
||||
use crate::state::pages::form::FormState;
|
||||
use crate::tui::functions::{intro, admin};
|
||||
|
||||
pub async fn handle_navigation_event(
|
||||
key: KeyEvent,
|
||||
@@ -123,33 +124,9 @@ pub fn previous_option(app_state: &mut AppState) {
|
||||
|
||||
pub fn select(app_state: &mut AppState) {
|
||||
if app_state.ui.show_intro {
|
||||
// Handle selection in intro screen
|
||||
match app_state.ui.intro_state.selected_option {
|
||||
0 => { // Continue - show form
|
||||
app_state.ui.show_form = true;
|
||||
app_state.ui.show_admin = false;
|
||||
app_state.ui.show_login = false;
|
||||
}
|
||||
1 => { // Admin
|
||||
app_state.ui.show_form = false;
|
||||
app_state.ui.show_admin = true;
|
||||
app_state.ui.show_login = false;
|
||||
}
|
||||
2 => { // Login
|
||||
app_state.ui.show_form = false;
|
||||
app_state.ui.show_admin = false;
|
||||
app_state.ui.show_login = true;
|
||||
}
|
||||
_ => {} // Other options (shouldn't happen)
|
||||
}
|
||||
app_state.ui.show_intro = false;
|
||||
intro::handle_intro_selection(app_state);
|
||||
} else if app_state.ui.show_admin {
|
||||
// Handle selection in admin panel
|
||||
let profiles = &app_state.profile_tree.profiles;
|
||||
if !profiles.is_empty() && app_state.general.selected_item < profiles.len() {
|
||||
// Set the selected profile
|
||||
app_state.selected_profile = Some(profiles[app_state.general.selected_item].name.clone());
|
||||
}
|
||||
admin::handle_admin_selection(app_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
client/src/tui/functions.rs
Normal file
7
client/src/tui/functions.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
// src/tui/functions.rs
|
||||
|
||||
pub mod admin;
|
||||
pub mod intro;
|
||||
|
||||
pub use admin::*;
|
||||
pub use intro::*;
|
||||
8
client/src/tui/functions/admin.rs
Normal file
8
client/src/tui/functions/admin.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use crate::state::state::AppState;
|
||||
|
||||
pub fn handle_admin_selection(app_state: &mut AppState) {
|
||||
let profiles = &app_state.profile_tree.profiles;
|
||||
if !profiles.is_empty() && app_state.general.selected_item < profiles.len() {
|
||||
app_state.selected_profile = Some(profiles[app_state.general.selected_item].name.clone());
|
||||
}
|
||||
}
|
||||
23
client/src/tui/functions/intro.rs
Normal file
23
client/src/tui/functions/intro.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use crate::state::state::AppState;
|
||||
|
||||
pub fn handle_intro_selection(app_state: &mut AppState) {
|
||||
match app_state.ui.intro_state.selected_option {
|
||||
0 => { // Continue
|
||||
app_state.ui.show_form = true;
|
||||
app_state.ui.show_admin = false;
|
||||
app_state.ui.show_login = false;
|
||||
}
|
||||
1 => { // Admin
|
||||
app_state.ui.show_form = false;
|
||||
app_state.ui.show_admin = true;
|
||||
app_state.ui.show_login = false;
|
||||
}
|
||||
2 => { // Login
|
||||
app_state.ui.show_form = false;
|
||||
app_state.ui.show_admin = false;
|
||||
app_state.ui.show_login = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
app_state.ui.show_intro = false;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// src/tui/mod.rs
|
||||
pub mod terminal;
|
||||
pub mod controls;
|
||||
pub mod functions;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user