status line finished
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
pub mod form;
|
||||
pub mod preview_card;
|
||||
pub mod command_line;
|
||||
pub mod status_line;
|
||||
|
||||
pub use command_line::render_command_line;
|
||||
pub use form::render_form;
|
||||
pub use preview_card::render_preview_card;
|
||||
pub use status_line::render_status_line;
|
||||
|
||||
30
src/client/components/status_line.rs
Normal file
30
src/client/components/status_line.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
// src/client/components/status_line.rs
|
||||
use ratatui::{
|
||||
widgets::{Paragraph, Block},
|
||||
style::Style,
|
||||
layout::{Rect, Alignment},
|
||||
text::{Line, Span},
|
||||
Frame,
|
||||
};
|
||||
use crate::client::colors::Theme;
|
||||
|
||||
pub fn render_status_line(f: &mut Frame, area: Rect, current_dir: &str, theme: &Theme) {
|
||||
// Program name and version
|
||||
let program_info = format!("multieko2 v{}", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
// Create the status line text
|
||||
let status_line = Line::from(vec![
|
||||
Span::styled(current_dir, Style::default().fg(theme.fg)),
|
||||
Span::styled(
|
||||
program_info,
|
||||
Style::default().fg(theme.accent).add_modifier(ratatui::style::Modifier::BOLD),
|
||||
),
|
||||
]);
|
||||
|
||||
// Render the status line
|
||||
let paragraph = Paragraph::new(status_line)
|
||||
.block(Block::default().style(Style::default().bg(theme.bg)))
|
||||
.alignment(Alignment::Left);
|
||||
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
// src/client/ui.rs
|
||||
use crossterm::event::{Event, KeyCode, KeyModifiers};
|
||||
use crate::client::terminal::AppTerminal;
|
||||
use crate::client::components::{render_command_line, render_form, render_preview_card};
|
||||
use crate::client::components::{render_command_line, render_form, render_preview_card, render_status_line}; // Add `render_status_line`
|
||||
use crate::client::colors::Theme;
|
||||
use ratatui::layout::{Constraint, Direction, Layout, Rect};
|
||||
use std::env;
|
||||
|
||||
pub fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut app_terminal = AppTerminal::new()?;
|
||||
@@ -34,11 +35,20 @@ pub fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
"Ucet", "Skladm", "ICO", "Kontakt", "Telefon", "Skladu", "Fax",
|
||||
];
|
||||
|
||||
// Get the current directory
|
||||
let current_dir = env::current_dir()?
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
|
||||
loop {
|
||||
app_terminal.draw(|f| {
|
||||
let root = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([Constraint::Min(10), Constraint::Length(1)])
|
||||
.constraints([
|
||||
Constraint::Min(10), // Main content area
|
||||
Constraint::Length(1), // Status line
|
||||
Constraint::Length(1), // Command line
|
||||
])
|
||||
.split(f.area());
|
||||
|
||||
// Main content area
|
||||
@@ -70,10 +80,14 @@ pub fn run_ui() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&theme,
|
||||
);
|
||||
|
||||
// Status line
|
||||
render_status_line(f, root[1], ¤t_dir, &theme);
|
||||
|
||||
// Command line
|
||||
render_command_line(f, root[1], &command_input, command_mode, &theme);
|
||||
render_command_line(f, root[2], &command_input, command_mode, &theme);
|
||||
})?;
|
||||
|
||||
// Event handling (unchanged)
|
||||
if let Event::Key(key) = app_terminal.read_event()? {
|
||||
if command_mode {
|
||||
match key.code {
|
||||
|
||||
Reference in New Issue
Block a user