fixing autocomplete, bombarded code, nothing in here

This commit is contained in:
filipriec
2025-04-11 22:39:09 +02:00
parent e7e8b0b3f6
commit e145d63ba6
3 changed files with 53 additions and 64 deletions

View File

@@ -46,69 +46,7 @@ pub fn render_register(
])
.split(inner_area);
// --- FORM RENDERING (Manual) ---
let form_area = chunks[0];
let field_labels = [
"Username",
"Email (Optional)",
"Password (Optional)",
"Confirm Password",
"Role (Optional)",
];
let num_fields = field_labels.len();
// Layout for labels and inputs within the form area
let form_layout = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(30), Constraint::Percentage(70)])
.split(form_area);
let label_area = form_layout[0];
let input_area = form_layout[1];
// Calculate vertical layout for input rows
let input_rows = Layout::default()
.direction(Direction::Vertical)
.constraints(vec![Constraint::Length(1); num_fields])
.split(input_area);
let mut role_input_rect = Rect::default(); // Store role input rect for dropdown positioning
// Render labels and inputs row by row
for i in 0..num_fields {
let is_active_field = state.current_field() == i;
// Render Label
let label = Paragraph::new(format!("{}:", field_labels[i]))
.style(Style::default().fg(theme.fg))
.alignment(Alignment::Right);
let label_rect = Rect {
x: label_area.x,
y: input_rows[i].y,
width: label_area.width.saturating_sub(1),
height: 1,
};
f.render_widget(label, label_rect);
// Render Input
let input_value = state.inputs()[i]; // Get value using CanvasState trait
let input_widget = Paragraph::new(input_value.as_str())
.style(if is_active_field {
Style::default().fg(theme.highlight)
} else {
Style::default().fg(theme.fg)
});
f.render_widget(input_widget, input_rows[i]);
if i == 4 { // Store the role input field's Rect
role_input_rect = input_rows[i];
}
// Set cursor for the active field
if is_active_field && is_edit_mode {
f.set_cursor(input_rows[i].x + state.current_cursor_pos() as u16, input_rows[i].y);
}
}
// --- ERROR MESSAGE ---
if let Some(err) = &state.error_message {