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

View File

@@ -4,6 +4,5 @@ pub mod ui;
pub mod form;
pub mod event;
pub mod render;
pub mod state;
pub use ui::run_ui;

View File

@@ -1,32 +0,0 @@
// 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;
}
}

View File

@@ -3,7 +3,9 @@
use crate::tui::terminal::AppTerminal;
use crate::config::colors::Theme;
use crate::config::config::Config;
use crate::ui::handlers::{event::EventHandler, form::FormState, state::AppState, render::render_ui};
use crate::ui::handlers::{event::EventHandler, form::FormState, render::render_ui};
use crate::state::state::AppState;
pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::load()?;