buffer working
This commit is contained in:
61
client/src/components/handlers/buffer_list.rs
Normal file
61
client/src/components/handlers/buffer_list.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
// src/components/handlers/buffer_list.rs
|
||||
|
||||
use crate::config::colors::themes::Theme;
|
||||
use crate::state::app::state::AppState;
|
||||
use ratatui::{
|
||||
layout::{Alignment, Rect}, // Added Alignment
|
||||
style::{Style, Stylize},
|
||||
text::{Line, Span}, // Added Span
|
||||
widgets::{Block, Borders, Paragraph}, // Changed widgets
|
||||
Frame,
|
||||
};
|
||||
|
||||
pub fn render_buffer_list(
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
theme: &Theme,
|
||||
app_state: &AppState,
|
||||
) {
|
||||
let mut current_buffer_name = "*scratch*"; // Default
|
||||
|
||||
// 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 {
|
||||
// Potentially make this more specific later (e.g., show table name)
|
||||
current_buffer_name = "Data Form";
|
||||
}
|
||||
// Add more conditions if other views exist
|
||||
|
||||
// Create the text line for the buffer name with padding
|
||||
let buffer_text = Line::from(vec![
|
||||
Span::raw(" "), // Left padding
|
||||
Span::styled(
|
||||
current_buffer_name,
|
||||
Style::default().fg(theme.bg).bg(theme.highlight), // Style active tab
|
||||
),
|
||||
Span::raw(" "), // Right padding
|
||||
]);
|
||||
|
||||
// Create the paragraph centered within the block
|
||||
let paragraph = Paragraph::new(buffer_text)
|
||||
.alignment(Alignment::Left) // Align text left, padding handles spacing
|
||||
.block(
|
||||
Block::default()
|
||||
// Keep only the bottom border to act as a separator
|
||||
.borders(Borders::BOTTOM)
|
||||
.border_style(Style::default().fg(theme.secondary)),
|
||||
)
|
||||
// Set the background for the entire area (behind the text/block)
|
||||
.style(Style::default().bg(theme.bg));
|
||||
|
||||
// Render the paragraph widget
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user