history of buffers implemented now
This commit is contained in:
@@ -5,6 +5,31 @@ use common::proto::multieko2::table_definition::ProfileTreeResponse;
|
||||
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,
|
||||
@@ -23,6 +48,7 @@ pub struct UiState {
|
||||
pub show_login: bool,
|
||||
pub show_register: bool,
|
||||
pub focus_outside_canvas: bool,
|
||||
pub buffer_history: Vec<AppView>,
|
||||
pub dialog: DialogState,
|
||||
}
|
||||
|
||||
@@ -139,6 +165,7 @@ impl Default for UiState {
|
||||
show_register: false,
|
||||
show_buffer_list: false,
|
||||
focus_outside_canvas: false,
|
||||
buffer_history: vec![AppView::Intro],
|
||||
dialog: DialogState::default(),
|
||||
}
|
||||
}
|
||||
@@ -157,3 +184,12 @@ impl Default for DialogState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UiState {
|
||||
/// Adds the given view to the history if it's different from the last one.
|
||||
pub fn update_buffer_history(&mut self, view: AppView) {
|
||||
if self.buffer_history.last() != Some(&view) {
|
||||
self.buffer_history.push(view.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user