sidebar as a feature
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
// src/components/handlers.rs
|
|
||||||
pub mod sidebar;
|
|
||||||
|
|
||||||
pub use sidebar::*;
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
// src/components/mod.rs
|
// src/components/mod.rs
|
||||||
pub mod handlers;
|
|
||||||
pub mod intro;
|
pub mod intro;
|
||||||
pub mod admin;
|
pub mod admin;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
@@ -7,7 +6,6 @@ pub mod form;
|
|||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
pub use handlers::*;
|
|
||||||
pub use intro::*;
|
pub use intro::*;
|
||||||
pub use admin::*;
|
pub use admin::*;
|
||||||
pub use common::*;
|
pub use common::*;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ pub mod functions;
|
|||||||
pub mod services;
|
pub mod services;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod buffer;
|
pub mod buffer;
|
||||||
|
pub mod sidebar;
|
||||||
|
|
||||||
pub use ui::run_ui;
|
pub use ui::run_ui;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// src/modes/handlers/event.rs
|
// src/modes/handlers/event.rs
|
||||||
use crate::config::binds::config::Config;
|
use crate::config::binds::config::Config;
|
||||||
use crate::config::binds::key_sequences::KeySequenceTracker;
|
use crate::config::binds::key_sequences::KeySequenceTracker;
|
||||||
use crate::buffer::functions;
|
use crate::buffer::{AppView, BufferState, switch_buffer, functions};
|
||||||
use crate::buffer::{AppView, BufferState, switch_buffer};
|
use crate::sidebar::toggle_sidebar;
|
||||||
use crate::functions::modes::navigation::add_logic_nav;
|
use crate::functions::modes::navigation::add_logic_nav;
|
||||||
use crate::functions::modes::navigation::add_logic_nav::SaveLogicResultSender;
|
use crate::functions::modes::navigation::add_logic_nav::SaveLogicResultSender;
|
||||||
use crate::functions::modes::navigation::add_table_nav::SaveTableResultSender;
|
use crate::functions::modes::navigation::add_table_nav::SaveTableResultSender;
|
||||||
@@ -436,7 +436,7 @@ impl EventHandler {
|
|||||||
let key_code = key_event.code;
|
let key_code = key_event.code;
|
||||||
let modifiers = key_event.modifiers;
|
let modifiers = key_event.modifiers;
|
||||||
|
|
||||||
if UiStateHandler::toggle_sidebar(
|
if toggle_sidebar(
|
||||||
&mut app_state.ui,
|
&mut app_state.ui,
|
||||||
config,
|
config,
|
||||||
key_code,
|
key_code,
|
||||||
|
|||||||
21
client/src/sidebar/logic.rs
Normal file
21
client/src/sidebar/logic.rs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// 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
|
||||||
|
}
|
||||||
7
client/src/sidebar/mod.rs
Normal file
7
client/src/sidebar/mod.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// src/sidebar/mod.rs
|
||||||
|
|
||||||
|
pub mod ui;
|
||||||
|
pub mod logic;
|
||||||
|
|
||||||
|
pub use ui::{calculate_sidebar_layout, render_sidebar};
|
||||||
|
pub use logic::toggle_sidebar;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/components/handlers/sidebar.rs
|
// src/sidebar/ui.rs
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
widgets::{Block, List, ListItem},
|
widgets::{Block, List, ListItem},
|
||||||
layout::{Rect, Direction, Layout, Constraint},
|
layout::{Rect, Direction, Layout, Constraint},
|
||||||
@@ -6,33 +6,19 @@ use crate::state::app::state::UiState;
|
|||||||
pub struct UiStateHandler;
|
pub struct UiStateHandler;
|
||||||
|
|
||||||
impl UiStateHandler {
|
impl UiStateHandler {
|
||||||
pub fn toggle_sidebar(
|
|
||||||
|
pub fn toggle_buffer_list(
|
||||||
ui_state: &mut UiState,
|
ui_state: &mut UiState,
|
||||||
config: &Config,
|
config: &Config,
|
||||||
key: KeyCode,
|
key: KeyCode,
|
||||||
modifiers: KeyModifiers,
|
modifiers: KeyModifiers,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Some(action) = config.get_action_for_key_in_mode(&config.keybindings.common, key, modifiers) {
|
if let Some(action) = config.get_common_action(key, modifiers) {
|
||||||
if action == "toggle_sidebar" {
|
if action == "toggle_buffer_list" {
|
||||||
ui_state.show_sidebar = !ui_state.show_sidebar;
|
ui_state.show_buffer_list = !ui_state.show_buffer_list;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_buffer_list(
|
|
||||||
ui_state: &mut UiState,
|
|
||||||
config: &Config,
|
|
||||||
key: KeyCode,
|
|
||||||
modifiers: KeyModifiers,
|
|
||||||
) -> bool {
|
|
||||||
if let Some(action) = config.get_common_action(key, modifiers) {
|
|
||||||
if action == "toggle_buffer_list" {
|
|
||||||
ui_state.show_buffer_list = !ui_state.show_buffer_list;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ use crate::components::{
|
|||||||
common::dialog::render_dialog,
|
common::dialog::render_dialog,
|
||||||
common::find_file_palette,
|
common::find_file_palette,
|
||||||
common::search_palette::render_search_palette,
|
common::search_palette::render_search_palette,
|
||||||
handlers::sidebar::{self, calculate_sidebar_layout},
|
|
||||||
intro::intro::render_intro,
|
intro::intro::render_intro,
|
||||||
render_background,
|
render_background,
|
||||||
render_command_line,
|
render_command_line,
|
||||||
render_status_line,
|
render_status_line,
|
||||||
};
|
};
|
||||||
|
use crate::sidebar::{calculate_sidebar_layout, render_sidebar};
|
||||||
use crate::buffer::render_buffer_list;
|
use crate::buffer::render_buffer_list;
|
||||||
use crate::config::colors::themes::Theme;
|
use crate::config::colors::themes::Theme;
|
||||||
use crate::modes::general::command_navigation::NavigationState;
|
use crate::modes::general::command_navigation::NavigationState;
|
||||||
@@ -168,7 +168,7 @@ pub fn render_ui(
|
|||||||
let (sidebar_area, form_actual_area) =
|
let (sidebar_area, form_actual_area) =
|
||||||
calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area);
|
calculate_sidebar_layout(app_state.ui.show_sidebar, main_content_area);
|
||||||
if let Some(sidebar_rect) = sidebar_area {
|
if let Some(sidebar_rect) = sidebar_area {
|
||||||
sidebar::render_sidebar(
|
render_sidebar(
|
||||||
f,
|
f,
|
||||||
sidebar_rect,
|
sidebar_rect,
|
||||||
theme,
|
theme,
|
||||||
|
|||||||
Reference in New Issue
Block a user