working switching of the buffers properly well now

This commit is contained in:
filipriec
2025-04-15 16:03:14 +02:00
parent c091a39802
commit 6267e3d593
6 changed files with 123 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ use crate::state::pages::auth::RegisterState;
use crate::state::pages::admin::AdminState;
use crate::state::pages::intro::IntroState;
use crate::state::app::buffer::BufferState;
use crate::state::app::buffer::AppView;
use crate::state::app::state::AppState;
// Import SaveOutcome
use crate::tui::terminal::{EventReader, TerminalCore};
@@ -54,6 +55,30 @@ pub async fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
// Determine edit mode based on EventHandler state
let is_edit_mode = event_handler.is_edit_mode;
// --- Synchronize UI View from Active Buffer ---
if let Some(active_view) = buffer_state.get_active_view() {
// Reset all flags first
app_state.ui.show_intro = false;
app_state.ui.show_login = false;
app_state.ui.show_register = false;
app_state.ui.show_admin = false;
app_state.ui.show_form = false;
// Potentially reset focus flag unless dialog is shown
if !app_state.ui.dialog.dialog_show {
app_state.ui.focus_outside_canvas = false;
}
match active_view {
AppView::Intro => app_state.ui.show_intro = true,
AppView::Login => app_state.ui.show_login = true,
AppView::Register => app_state.ui.show_register = true,
AppView::Admin => app_state.ui.show_admin = true,
AppView::Form(_) => app_state.ui.show_form = true,
AppView::Scratch => {} // Or show a scratchpad component
}
}
// --- End Synchronization ---
terminal.draw(|f| {
render_ui(
f,