// src/sidebar/state.rs
use crossterm::event::{KeyCode, KeyModifiers};
use crate::config::binds::config::Config;
use crate::state::app::state::UiState;

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
}
