step 3 compiled

This commit is contained in:
filipriec
2025-03-28 14:35:16 +01:00
parent 48b2658b55
commit f21953147b
2 changed files with 7 additions and 16 deletions

View File

@@ -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