sidebar fixed bugs and buffer implementation 1
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
// src/components/common.rs
|
||||
pub mod command_line;
|
||||
pub mod status_line;
|
||||
pub mod buffer_list;
|
||||
pub mod background;
|
||||
pub mod dialog;
|
||||
pub mod autocomplete;
|
||||
|
||||
pub use command_line::*;
|
||||
pub use status_line::*;
|
||||
pub use buffer_list::*;
|
||||
pub use background::*;
|
||||
pub use dialog::*;
|
||||
pub use autocomplete::*;
|
||||
|
||||
53
client/src/components/common/buffer_list.rs
Normal file
53
client/src/components/common/buffer_list.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
// src/components/common/buffer_list.rs
|
||||
|
||||
use crate::config::colors::themes::Theme;
|
||||
use crate::state::app::state::AppState;
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
style::{Style, Stylize},
|
||||
text::Line,
|
||||
widgets::{Block, Borders, List, ListItem, ListState},
|
||||
Frame,
|
||||
};
|
||||
|
||||
pub fn render_buffer_list(
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &Theme,
|
||||
app_state: &AppState,
|
||||
) {
|
||||
let mut items = Vec::new();
|
||||
let mut current_buffer_name = "*scratch*"; // Default if nothing else is shown
|
||||
|
||||
// Determine the active buffer name based on UI state
|
||||
if app_state.ui.show_intro {
|
||||
current_buffer_name = "Intro";
|
||||
} else if app_state.ui.show_register {
|
||||
current_buffer_name = "Register";
|
||||
} else if app_state.ui.show_login {
|
||||
current_buffer_name = "Login";
|
||||
} else if app_state.ui.show_admin {
|
||||
current_buffer_name = "Admin Panel";
|
||||
} else if app_state.ui.show_form {
|
||||
current_buffer_name = "Data Form"; // Or derive from selected profile/table if needed
|
||||
}
|
||||
|
||||
items.push(ListItem::new(Line::from(vec![
|
||||
" ".into(), // Padding
|
||||
current_buffer_name.fg(theme.highlight),
|
||||
" ".into(), // Padding
|
||||
])));
|
||||
|
||||
let list = List::new(items)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::TOP) // Simple top border
|
||||
.border_style(Style::default().fg(theme.secondary)),
|
||||
)
|
||||
.style(Style::default().bg(theme.bg).fg(theme.fg));
|
||||
|
||||
let mut state = ListState::default();
|
||||
|
||||
f.render_stateful_widget(list, area, &mut state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user