improvements on the register.rs
This commit is contained in:
@@ -42,6 +42,7 @@ pub fn render_register(
|
|||||||
.direction(Direction::Vertical)
|
.direction(Direction::Vertical)
|
||||||
.constraints([
|
.constraints([
|
||||||
Constraint::Length(7), // Form (5 fields + padding)
|
Constraint::Length(7), // Form (5 fields + padding)
|
||||||
|
Constraint::Length(1), // Help text line
|
||||||
Constraint::Length(1), // Error message
|
Constraint::Length(1), // Error message
|
||||||
Constraint::Length(3), // Buttons
|
Constraint::Length(3), // Buttons
|
||||||
])
|
])
|
||||||
@@ -54,25 +55,31 @@ pub fn render_register(
|
|||||||
state, // The state object (RegisterState)
|
state, // The state object (RegisterState)
|
||||||
&[ // Field labels
|
&[ // Field labels
|
||||||
"Username",
|
"Username",
|
||||||
"Email (Optional)",
|
"Email*",
|
||||||
"Password (Optional)",
|
"Password*",
|
||||||
"Confirm Password",
|
"Confirm Password",
|
||||||
"Role (Optional)",
|
"Role* (Tab)",
|
||||||
],
|
],
|
||||||
&state.current_field(), // Pass current field index
|
&state.current_field(), // Pass current field index
|
||||||
&state.inputs().iter().map(|s| *s).collect::<Vec<&String>>(), // Pass inputs directly
|
&state.inputs().iter().map(|s| *s).collect::<Vec<&String>>(), // Pass inputs directly
|
||||||
theme,
|
theme,
|
||||||
is_edit_mode,
|
is_edit_mode,
|
||||||
// No need to pass suggestion state here, render_canvas uses the trait
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// --- HELP TEXT ---
|
||||||
|
let help_text = Paragraph::new("* are optional fields")
|
||||||
|
.style(Style::default().fg(theme.fg))
|
||||||
|
.alignment(Alignment::Center);
|
||||||
|
f.render_widget(help_text, chunks[1]);
|
||||||
|
|
||||||
|
|
||||||
// --- ERROR MESSAGE ---
|
// --- ERROR MESSAGE ---
|
||||||
if let Some(err) = &state.error_message {
|
if let Some(err) = &state.error_message {
|
||||||
f.render_widget(
|
f.render_widget(
|
||||||
Paragraph::new(err.as_str())
|
Paragraph::new(err.as_str())
|
||||||
.style(Style::default().fg(Color::Red))
|
.style(Style::default().fg(Color::Red))
|
||||||
.alignment(Alignment::Center),
|
.alignment(Alignment::Center),
|
||||||
chunks[1],
|
chunks[2],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +87,7 @@ pub fn render_register(
|
|||||||
let button_chunks = Layout::default()
|
let button_chunks = Layout::default()
|
||||||
.direction(Direction::Horizontal)
|
.direction(Direction::Horizontal)
|
||||||
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
|
||||||
.split(chunks[2]);
|
.split(chunks[3]);
|
||||||
|
|
||||||
// Register Button
|
// Register Button
|
||||||
let register_button_index = 0;
|
let register_button_index = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user