Files
komp_ac/client/src/state/state.rs
2025-03-23 12:30:00 +01:00

64 lines
1.6 KiB
Rust

// src/state/state.rs
use std::env;
use common::proto::multieko2::table_definition::ProfileTreeResponse;
pub struct UiState {
pub show_sidebar: bool,
pub is_saved: bool,
pub show_intro: bool,
pub show_admin: bool,
}
pub struct AppState {
// Core editor state
pub current_dir: String,
pub total_count: u64,
pub current_position: u64,
pub profile_tree: ProfileTreeResponse,
pub selected_profile: Option<String>,
pub admin_selected_item: usize, // Tracks selection in admin panel
pub admin_profiles: Vec<String>, // Stores admin panel data
// UI preferences
pub ui: UiState,
}
impl AppState {
pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
let current_dir = env::current_dir()?
.to_string_lossy()
.to_string();
Ok(AppState {
current_dir,
total_count: 0,
current_position: 0,
profile_tree: ProfileTreeResponse::default(),
selected_profile: None,
admin_selected_item: 0,
admin_profiles: Vec::new(),
ui: UiState::default(),
})
}
// Existing methods remain unchanged
pub fn update_total_count(&mut self, total_count: u64) {
self.total_count = total_count;
}
pub fn update_current_position(&mut self, current_position: u64) {
self.current_position = current_position;
}
}
impl Default for UiState {
fn default() -> Self {
Self {
show_sidebar: true,
is_saved: false,
show_intro: true,
show_admin: false,
}
}
}