completion not working yet

This commit is contained in:
filipriec
2025-04-11 22:54:44 +02:00
parent e145d63ba6
commit 024a0de4af
5 changed files with 90 additions and 30 deletions

View File

@@ -46,7 +46,24 @@ pub fn render_register(
])
.split(inner_area);
// --- FORM RENDERING (Using render_canvas) ---
crate::components::handlers::canvas::render_canvas(
f,
chunks[0], // Area for the canvas
state, // The state object (RegisterState)
&[ // Field labels
"Username",
"Email (Optional)",
"Password (Optional)",
"Confirm Password",
"Role (Optional)",
],
&state.current_field(), // Pass current field index
&state.inputs().iter().map(|s| *s).collect::<Vec<&String>>(), // Pass inputs directly
theme,
is_edit_mode,
// No need to pass suggestion state here, render_canvas uses the trait
);
// --- ERROR MESSAGE ---
if let Some(err) = &state.error_message {
@@ -130,32 +147,4 @@ pub fn render_register(
app_state.ui.dialog.dialog_active_button_index,
);
}
// --- AUTOCOMPLETE DROPDOWN RENDERING ---
if state.show_role_suggestions && !state.role_suggestions.is_empty() {
// Calculate dropdown area below the role input field
let dropdown_height = (state.role_suggestions.len() as u16).min(5) + 2; // Max 5 suggestions + border
let dropdown_area = Rect {
x: role_input_rect.x,
y: role_input_rect.y + 1, // Position below the input line
width: role_input_rect.width.max(20), // Ensure minimum width
height: dropdown_height,
};
// Ensure dropdown doesn't go off screen (simple vertical check)
let screen_height = f.size().height;
let clamped_dropdown_area = if dropdown_area.bottom() > screen_height {
Rect::new(dropdown_area.x, dropdown_area.y.saturating_sub(dropdown_height + 1), dropdown_area.width, dropdown_area.height)
} else {
dropdown_area
};
autocomplete::render_autocomplete_dropdown(
f,
clamped_dropdown_area,
theme,
&state.role_suggestions,
state.selected_suggestion_index,
);
}
}