going directly into adminstate from appstate for the admin page. DESTROYED

This commit is contained in:
filipriec
2025-04-14 11:24:56 +02:00
parent 1927d1fa4d
commit 2d724876eb
10 changed files with 100 additions and 33 deletions

View File

@@ -0,0 +1,36 @@
// src/functions/modes/navigation/admin_nav.rs
use crate::state::app::state::AppState;
use crate::state::pages::admin::AdminState;
/// Handles moving the selection up in the admin profile list.
pub fn move_admin_list_up(app_state: &AppState, admin_state: &mut AdminState) {
// Read profile count directly from app_state where the source data lives
let profile_count = app_state.profile_tree.profiles.len();
if profile_count == 0 {
admin_state.list_state.select(None); // Ensure nothing selected if empty
return;
}
let current_index = admin_state.get_selected_index().unwrap_or(0);
let new_index = if current_index == 0 {
profile_count - 1 // Wrap to end
} else {
current_index.saturating_sub(1) // Move up
};
admin_state.list_state.select(Some(new_index));
}
/// Handles moving the selection down in the admin profile list.
pub fn move_admin_list_down(app_state: &AppState, admin_state: &mut AdminState) {
// Read profile count directly from app_state
let profile_count = app_state.profile_tree.profiles.len();
if profile_count == 0 {
admin_state.list_state.select(None); // Ensure nothing selected if empty
return;
}
let current_index = admin_state.get_selected_index().unwrap_or(0);
let new_index = (current_index + 1) % profile_count; // Wrap around
admin_state.list_state.select(Some(new_index));
}