proper form in a card
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// src/client/components/form.rs
|
// src/client/components/form.rs
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
widgets::Paragraph,
|
widgets::{Paragraph, Block, Borders},
|
||||||
layout::{Layout, Constraint, Direction, Rect},
|
layout::{Layout, Constraint, Direction, Rect, Margin},
|
||||||
style::Style,
|
style::Style,
|
||||||
text::{Line, Span},
|
text::{Line, Span},
|
||||||
Frame,
|
Frame,
|
||||||
@@ -16,11 +16,27 @@ pub fn render_form(
|
|||||||
inputs: &[&String],
|
inputs: &[&String],
|
||||||
theme: &Theme,
|
theme: &Theme,
|
||||||
) {
|
) {
|
||||||
// Split the area into a single column layout
|
// Create a block for the Adresar card
|
||||||
|
let adresar_card = Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_style(Style::default().fg(theme.border))
|
||||||
|
.title(" Adresar ")
|
||||||
|
.style(Style::default().bg(theme.bg).fg(theme.fg));
|
||||||
|
|
||||||
|
// Render the card first
|
||||||
|
f.render_widget(adresar_card, area);
|
||||||
|
|
||||||
|
// Define the inner area for the form (inside the card)
|
||||||
|
let inner_area = area.inner(Margin {
|
||||||
|
horizontal: 1,
|
||||||
|
vertical: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Split the inner area into a single column layout
|
||||||
let form_chunks = Layout::default()
|
let form_chunks = Layout::default()
|
||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints(vec![Constraint::Length(1); fields.len()]) // Each field takes 1 row
|
.constraints(vec![Constraint::Length(1); fields.len()]) // Each field takes 1 row
|
||||||
.split(area);
|
.split(inner_area);
|
||||||
|
|
||||||
for (i, field) in fields.iter().enumerate() {
|
for (i, field) in fields.iter().enumerate() {
|
||||||
let input = inputs[i].clone();
|
let input = inputs[i].clone();
|
||||||
@@ -36,7 +52,7 @@ pub fn render_form(
|
|||||||
let label = Paragraph::new(Line::from(Span::styled(
|
let label = Paragraph::new(Line::from(Span::styled(
|
||||||
field.to_string(),
|
field.to_string(),
|
||||||
Style::default().fg(theme.fg),
|
Style::default().fg(theme.fg),
|
||||||
)));
|
))); // Fixed: Added the missing closing parenthesis
|
||||||
f.render_widget(label, row_chunks[0]);
|
f.render_widget(label, row_chunks[0]);
|
||||||
|
|
||||||
// Render the input on the right
|
// Render the input on the right
|
||||||
|
|||||||
Reference in New Issue
Block a user