From f21953147b306b3c9fbca80a913c673cb7ce4b82 Mon Sep 17 00:00:00 2001 From: filipriec Date: Fri, 28 Mar 2025 14:35:16 +0100 Subject: [PATCH] step 3 compiled --- client/src/modes/handlers/mode_manager.rs | 13 +++++++------ client/src/state/pages/auth.rs | 10 ---------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/client/src/modes/handlers/mode_manager.rs b/client/src/modes/handlers/mode_manager.rs index 4ec80aa..4c9b1af 100644 --- a/client/src/modes/handlers/mode_manager.rs +++ b/client/src/modes/handlers/mode_manager.rs @@ -15,14 +15,16 @@ pub struct ModeManager; impl ModeManager { // Determine current mode based on app state pub fn derive_mode(app_state: &AppState, event_handler: &EventHandler) -> AppMode { - // Command mode takes precedence if active if event_handler.command_mode { return AppMode::Command; } - // Check UI state flags - if app_state.ui.show_intro || app_state.ui.show_admin { - AppMode::General + if app_state.ui.show_login { // NEW: Check auth visibility + if event_handler.is_edit_mode { + AppMode::Edit + } else { + AppMode::ReadOnly + } } else if app_state.ui.show_form { if event_handler.is_edit_mode { AppMode::Edit @@ -30,11 +32,10 @@ impl ModeManager { AppMode::ReadOnly } } else { - // Fallback AppMode::General } } - + // Mode transition rules pub fn can_enter_command_mode(current_mode: AppMode) -> bool { !matches!(current_mode, AppMode::Edit) // Can't enter from Edit mode diff --git a/client/src/state/pages/auth.rs b/client/src/state/pages/auth.rs index 2d9be17..e7eb8ca 100644 --- a/client/src/state/pages/auth.rs +++ b/client/src/state/pages/auth.rs @@ -22,16 +22,6 @@ impl AuthState { current_cursor_pos: 0, } } - - // These methods are now redundant since we implement CanvasState - // but we'll keep them for backward compatibility - pub fn get_current_input_mut(&mut self) -> &mut String { - self.get_current_input_mut() - } - - pub fn get_current_input(&self) -> &str { - self.get_current_input() - } } impl CanvasState for AuthState {