buffer its independent, needs fixes

This commit is contained in:
filipriec
2025-04-15 13:57:17 +02:00
parent f42790980d
commit f94006dd08
7 changed files with 86 additions and 56 deletions

View File

@@ -2,34 +2,10 @@
use std::env;
use common::proto::multieko2::table_definition::ProfileTreeResponse;
use crate::state::app::buffer::BufferState;
use crate::modes::handlers::mode_manager::AppMode;
use crate::ui::handlers::context::DialogPurpose;
/// Represents the distinct views or "buffers" the user can navigate.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AppView {
Intro,
Login,
Register,
Admin,
Form(String),
Scratch,
}
impl AppView {
/// Returns the display name for the view.
pub fn display_name(&self) -> &str {
match self {
AppView::Intro => "Intro",
AppView::Login => "Login",
AppView::Register => "Register",
AppView::Admin => "Admin Panel",
AppView::Form(name) => name.as_str(),
AppView::Scratch => "*scratch*",
}
}
}
pub struct DialogState {
pub dialog_show: bool,
pub dialog_title: String,
@@ -48,8 +24,6 @@ pub struct UiState {
pub show_login: bool,
pub show_register: bool,
pub focus_outside_canvas: bool,
pub buffer_history: Vec<AppView>,
pub active_buffer_index: usize,
pub dialog: DialogState,
}
@@ -166,8 +140,6 @@ impl Default for UiState {
show_register: false,
show_buffer_list: false,
focus_outside_canvas: false,
buffer_history: vec![AppView::Intro],
active_buffer_index: 0,
dialog: DialogState::default(),
}
}
@@ -186,20 +158,3 @@ impl Default for DialogState {
}
}
}
impl UiState {
/// Updates the buffer history and active index.
pub fn update_buffer_history(&mut self, view: AppView) {
let existing_pos = self.buffer_history.iter().position(|v| v == &view);
match existing_pos {
Some(pos) => {
self.active_buffer_index = pos;
}
None => {
self.buffer_history.push(view.clone());
self.active_buffer_index = self.buffer_history.len() - 1;
}
}
}
}