working needs a small fix

This commit is contained in:
filipriec
2025-04-07 13:24:22 +02:00
parent e29b576102
commit 37f12ea6f0
7 changed files with 69 additions and 18 deletions

View File

@@ -4,6 +4,8 @@ use crossterm::event::KeyEvent;
use crate::config::binds::config::Config;
use crate::state::state::AppState;
use crate::state::pages::form::FormState;
use crate::state::pages::auth::AuthState;
use crate::state::canvas_state::CanvasState;
use crate::tui::functions::{intro, admin};
pub async fn handle_navigation_event(
@@ -11,6 +13,7 @@ pub async fn handle_navigation_event(
config: &Config,
form_state: &mut FormState,
app_state: &mut AppState,
auth_state: &mut AuthState,
command_mode: &mut bool,
command_input: &mut String,
command_message: &mut String,
@@ -18,7 +21,7 @@ pub async fn handle_navigation_event(
if let Some(action) = config.get_general_action(key.code, key.modifiers) {
match action {
"move_up" => {
move_up(app_state);
move_up(app_state, auth_state);
return Ok((false, String::new()));
}
"move_down" => {
@@ -61,8 +64,16 @@ pub async fn handle_navigation_event(
Ok((false, String::new()))
}
pub fn move_up(app_state: &mut AppState) {
if app_state.ui.show_intro {
pub fn move_up(app_state: &mut AppState, auth_state: &mut AuthState) {
if app_state.ui.focus_outside_canvas && app_state.ui.show_login {
if app_state.general.selected_item == 0 {
app_state.ui.focus_outside_canvas = false;
let last_field_index = auth_state.fields().len().saturating_sub(1);
auth_state.set_current_field(last_field_index);
} else {
app_state.general.selected_item = app_state.general.selected_item.saturating_sub(1);
}
} else if app_state.ui.show_intro {
app_state.ui.intro_state.previous_option();
} else if app_state.ui.show_admin {
// Assuming profile_tree.profiles is the list we're navigating
@@ -81,7 +92,12 @@ pub fn move_up(app_state: &mut AppState) {
}
pub fn move_down(app_state: &mut AppState) {
if app_state.ui.show_intro {
if app_state.ui.focus_outside_canvas && app_state.ui.show_login {
let num_general_elements = 2;
if app_state.general.selected_item < num_general_elements - 1 {
app_state.general.selected_item += 1;
}
} else if app_state.ui.show_intro {
app_state.ui.intro_state.next_option();
} else if app_state.ui.show_admin {
// Assuming profile_tree.profiles is the list we're navigating