working frontend, now changing color nonsense
This commit is contained in:
23
src/client/components/command_line.rs
Normal file
23
src/client/components/command_line.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
// src/client/components/command_line.rs
|
||||
use ratatui::{
|
||||
widgets::{Block, Paragraph},
|
||||
style::Style,
|
||||
layout::Rect,
|
||||
Frame,
|
||||
};
|
||||
use crate::client::colors::PastelGrayTheme;
|
||||
|
||||
pub fn render_command_line(f: &mut Frame, area: Rect, input: &str, active: bool) {
|
||||
let prompt = if active { ":" } else { "Press ':' for commands" };
|
||||
let style = if active {
|
||||
Style::default().fg(DoomColors::CYAN)
|
||||
} else {
|
||||
Style::default().fg(DoomColors::HL)
|
||||
};
|
||||
|
||||
let paragraph = Paragraph::new(format!("{}{}", prompt, input))
|
||||
.block(Block::default().style(Style::default().bg(DoomColors::BG)))
|
||||
.style(style);
|
||||
|
||||
f.render_widget(paragraph, area);
|
||||
}
|
||||
57
src/client/components/form.rs
Normal file
57
src/client/components/form.rs
Normal file
@@ -0,0 +1,57 @@
|
||||
// src/client/components/form.rs
|
||||
use ratatui::{
|
||||
widgets::{Paragraph, Block, Borders},
|
||||
layout::{Layout, Constraint, Direction, Rect},
|
||||
style::Style,
|
||||
text::Line,
|
||||
Frame,
|
||||
};
|
||||
use crate::client::colors::PastelGrayTheme;
|
||||
|
||||
pub fn render_form(
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
fields: &[&str],
|
||||
current_field: &usize,
|
||||
inputs: &[&String],
|
||||
) {
|
||||
let form_chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(vec![Constraint::Length(3); 8])
|
||||
.margin(1)
|
||||
.split(area);
|
||||
|
||||
let form_blocks = form_chunks.iter().enumerate().map(|(_i, chunk)| {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||
.split(*chunk);
|
||||
|
||||
vec![chunks[0], chunks[1]]
|
||||
}).flatten().collect::<Vec<Rect>>();
|
||||
|
||||
for (i, field) in fields.iter().enumerate() {
|
||||
let input = inputs[i].clone();
|
||||
let is_active = i == *current_field;
|
||||
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_style(Style::default().fg(if is_active {
|
||||
PastelGrayTheme::ACCENT
|
||||
} else {
|
||||
PastelGrayTheme::FG_LIGHT
|
||||
}))
|
||||
.title(Line::from(field.to_string()))
|
||||
.style(Style::default().bg(PastelGrayTheme::BG).fg(PastelGrayTheme::FG));
|
||||
|
||||
let paragraph = Paragraph::new(input.as_str())
|
||||
.block(block)
|
||||
.style(if is_active {
|
||||
Style::default().fg(PastelGrayTheme::HIGHLIGHT)
|
||||
} else {
|
||||
Style::default().fg(PastelGrayTheme::FG)
|
||||
});
|
||||
|
||||
f.render_widget(paragraph, form_blocks[i]);
|
||||
}
|
||||
}
|
||||
4
src/client/components/mod.rs
Normal file
4
src/client/components/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
// src/client/components/mod.rs
|
||||
pub mod form;
|
||||
pub mod preview_card;
|
||||
pub mod command_line;
|
||||
31
src/client/components/preview_card.rs
Normal file
31
src/client/components/preview_card.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
// src/client/components/preview_card.rs
|
||||
use ratatui::{
|
||||
widgets::{Block, List, ListItem},
|
||||
layout::Rect,
|
||||
style::Style,
|
||||
text::Text,
|
||||
Frame,
|
||||
};
|
||||
use crate::client::colors::PastelGrayTheme;
|
||||
|
||||
pub fn render_preview_card(f: &mut Frame, area: Rect, fields: &[&String]) {
|
||||
let card = Block::default()
|
||||
.borders(ratatui::widgets::Borders::ALL)
|
||||
.border_style(Style::default().fg(DoomColors::HL))
|
||||
.title(" Preview Card ")
|
||||
.style(Style::default().bg(DoomColors::BG));
|
||||
|
||||
let _inner_area = card.inner(area); // Prefix with underscore to indicate intentional unused
|
||||
|
||||
let items = vec![
|
||||
ListItem::new(Text::from(format!("Firma: {}", fields[0]))),
|
||||
ListItem::new(Text::from(format!("Ulica: {}", fields[1]))),
|
||||
// ... other fields ...
|
||||
];
|
||||
|
||||
let list = List::new(items)
|
||||
.block(card)
|
||||
.style(Style::default().bg(DoomColors::BG).fg(DoomColors::FG));
|
||||
|
||||
f.render_widget(list, area);
|
||||
}
|
||||
Reference in New Issue
Block a user