moving state out of ui

This commit is contained in:
filipriec
2025-02-25 23:36:53 +01:00
parent 5010b73bab
commit fef821c800
6 changed files with 6 additions and 11 deletions

2
client/src/state/mod.rs Normal file
View File

@@ -0,0 +1,2 @@
// src/state/mod.rs
pub mod state;

32
client/src/state/state.rs Normal file
View File

@@ -0,0 +1,32 @@
// src/client/ui/handlers/state.rs
use std::env;
pub struct AppState {
pub is_saved: bool,
pub current_dir: String,
pub total_count: u64,
pub current_position: u64,
}
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 {
is_saved: false,
current_dir,
total_count: 0,
current_position: 0,
})
}
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;
}
}