border fixed

This commit is contained in:
filipriec
2025-04-05 17:34:26 +02:00
parent 1c662888c6
commit 0219dc0ede

View File

@@ -4,13 +4,13 @@ use crate::{
config::colors::themes::Theme,
state::pages::auth::AuthState,
components::common::dialog,
state::state::AppState, // Add this import
state::state::AppState,
};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout, Rect, Margin},
style::{Style, Modifier, Color}, // Removed unused Color import
style::{Style, Modifier, Color},
widgets::{Block, BorderType, Borders, Paragraph},
Frame, // Removed unused Span import
Frame,
};
pub fn render_login(
@@ -18,7 +18,7 @@ pub fn render_login(
area: Rect,
theme: &Theme,
state: &AuthState,
app_state: &AppState, // Add AppState parameter
app_state: &AppState,
is_edit_mode: bool,
) {
// Main container
@@ -47,24 +47,10 @@ pub fn render_login(
.split(inner_area);
// --- FORM RENDERING ---
let input_block = Block::default()
.borders(Borders::ALL)
.border_style(if is_edit_mode {
Style::default().fg(theme.accent)
} else {
Style::default().fg(theme.border)
})
.style(Style::default().bg(theme.bg));
// Calculate inner area BEFORE rendering
let input_area = input_block.inner(chunks[0]);
f.render_widget(input_block, chunks[0]);
// Use the canvas renderer for fields
// Directly pass the form area to canvas for border handling
crate::components::handlers::canvas::render_canvas(
f,
input_area, // Use the pre-calculated area
chunks[0],
state,
&["Username/Email", "Password"],
&state.current_field,
@@ -73,7 +59,17 @@ pub fn render_login(
is_edit_mode,
);
// --- BUTTONS --- (Keep this unchanged)
// --- ERROR MESSAGE ---
if let Some(err) = &state.error_message {
f.render_widget(
Paragraph::new(err.as_str())
.style(Style::default().fg(Color::Red))
.alignment(Alignment::Center),
chunks[1],
);
}
// --- BUTTONS ---
let button_chunks = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)])
@@ -123,20 +119,11 @@ pub fn render_login(
button_chunks[1],
);
// Error message
if let Some(err) = &state.error_message {
f.render_widget(
Paragraph::new(err.as_str())
.style(Style::default().fg(Color::Red))
.alignment(Alignment::Center),
chunks[1],
);
}
// --- DIALOG ---
if app_state.ui.dialog.show_dialog {
dialog::render_dialog(
f,
f.area(), // Use area() instead of deprecated size()
f.size(),
theme,
&app_state.ui.dialog.dialog_title,
&app_state.ui.dialog.dialog_message,