70 lines
1.6 KiB
Rust
70 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 GeneralState {
|
|
pub selected_item: usize,
|
|
pub current_option: usize,
|
|
}
|
|
|
|
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>,
|
|
|
|
// UI preferences
|
|
pub ui: UiState,
|
|
pub general: GeneralState,
|
|
}
|
|
|
|
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,
|
|
ui: UiState::default(),
|
|
general: GeneralState {
|
|
selected_item: 0,
|
|
current_option: 0,
|
|
},
|
|
})
|
|
}
|
|
|
|
// 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,
|
|
}
|
|
}
|
|
}
|