working needs a small fix
This commit is contained in:
@@ -6,11 +6,12 @@ use crate::services::grpc_client::GrpcClient;
|
||||
use crate::state::canvas_state::CanvasState;
|
||||
use crate::state::pages::auth::AuthState;
|
||||
use crate::state::pages::form::FormState;
|
||||
use crate::state::state::AppState;
|
||||
use crate::functions::modes::read_only::{auth_ro, form_ro};
|
||||
use crossterm::event::KeyEvent;
|
||||
|
||||
pub async fn handle_read_only_event(
|
||||
app_state: &crate::state::state::AppState,
|
||||
app_state: &mut AppState,
|
||||
key: KeyEvent,
|
||||
config: &Config,
|
||||
form_state: &mut FormState,
|
||||
@@ -90,6 +91,7 @@ pub async fn handle_read_only_event(
|
||||
} else if app_state.ui.show_login {
|
||||
auth_ro::execute_action(
|
||||
action,
|
||||
app_state,
|
||||
auth_state,
|
||||
ideal_cursor_column,
|
||||
key_sequence_tracker,
|
||||
@@ -136,6 +138,7 @@ pub async fn handle_read_only_event(
|
||||
} else if app_state.ui.show_login {
|
||||
auth_ro::execute_action(
|
||||
action,
|
||||
app_state,
|
||||
auth_state,
|
||||
ideal_cursor_column,
|
||||
key_sequence_tracker,
|
||||
@@ -181,6 +184,7 @@ pub async fn handle_read_only_event(
|
||||
} else if app_state.ui.show_login {
|
||||
auth_ro::execute_action(
|
||||
action,
|
||||
app_state,
|
||||
auth_state,
|
||||
ideal_cursor_column,
|
||||
key_sequence_tracker,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -76,6 +76,7 @@ impl EventHandler {
|
||||
config,
|
||||
form_state,
|
||||
app_state,
|
||||
auth_state,
|
||||
&mut self.command_mode,
|
||||
&mut self.command_input,
|
||||
&mut self.command_message,
|
||||
@@ -154,7 +155,7 @@ impl EventHandler {
|
||||
}
|
||||
|
||||
return read_only::handle_read_only_event(
|
||||
&app_state,
|
||||
app_state,
|
||||
key,
|
||||
config,
|
||||
form_state,
|
||||
|
||||
@@ -19,6 +19,10 @@ impl ModeManager {
|
||||
return AppMode::Command;
|
||||
}
|
||||
|
||||
if app_state.ui.focus_outside_canvas {
|
||||
return AppMode::General;
|
||||
}
|
||||
|
||||
if app_state.ui.show_login {
|
||||
if event_handler.is_edit_mode {
|
||||
AppMode::Edit
|
||||
|
||||
Reference in New Issue
Block a user