compiled and working sidebar in ratatui

This commit is contained in:
filipriec
2025-03-21 15:53:40 +01:00
parent c46bbc26e1
commit d067f5b515
10 changed files with 134 additions and 14 deletions

View File

@@ -0,0 +1,45 @@
// src/ui/handlers/rat_state.rs
use crossterm::event::{KeyCode, KeyModifiers};
use crate::config::config::Config;
use crate::state::state::UiState;
pub struct UiStateHandler;
impl UiStateHandler {
pub fn toggle_sidebar(
ui_state: &mut UiState,
config: &Config,
key: KeyCode,
modifiers: KeyModifiers,
) -> bool {
if let Some(action) = config.get_action_for_key_in_mode(&config.keybindings.common, key, modifiers) {
if action == "toggle_sidebar" {
ui_state.show_sidebar = !ui_state.show_sidebar;
return true;
}
}
false
}
// Keep your existing handle_ui_action method if you need it for other UI actions
pub fn handle_ui_action(
ui_state: &mut UiState,
config: &Config,
key: KeyCode,
modifiers: KeyModifiers,
) -> bool {
let mut action_performed = false;
// Check for sidebar toggle
if let Some(action) = config.get_action_for_key_in_mode(&config.keybindings.common, key, modifiers) {
if action == "toggle_sidebar" {
ui_state.show_sidebar = !ui_state.show_sidebar;
action_performed = true;
}
}
// Add other UI actions here following the same pattern
action_performed
}
}