not working, needs more fixes

This commit is contained in:
filipriec
2025-08-19 22:14:43 +02:00
parent 3eea6b9e88
commit 2cda54633f
2 changed files with 19 additions and 7 deletions

View File

@@ -13,15 +13,24 @@ use ratatui::{
Frame, Frame,
}; };
use crate::state::app::highlight::HighlightState; use crate::state::app::highlight::HighlightState;
use canvas::{FormEditor, render_canvas_default, render_canvas, render_suggestions_dropdown, DefaultCanvasTheme}; use canvas::{
FormEditor,
render_canvas,
render_suggestions_dropdown,
DefaultCanvasTheme,
};
use canvas::canvas::HighlightState as CanvasHighlightState; use canvas::canvas::HighlightState as CanvasHighlightState;
// Helper function to convert between HighlightState types // Helper function to convert between HighlightState types
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState { fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
match local { match local {
HighlightState::Off => CanvasHighlightState::Off, HighlightState::Off => CanvasHighlightState::Off,
HighlightState::Characterwise { anchor } => CanvasHighlightState::Characterwise { anchor: *anchor }, HighlightState::Characterwise { anchor } => {
HighlightState::Linewise { anchor_line } => CanvasHighlightState::Linewise { anchor_line: *anchor_line }, CanvasHighlightState::Characterwise { anchor: *anchor }
}
HighlightState::Linewise { anchor_line } => {
CanvasHighlightState::Linewise { anchor_line: *anchor_line }
}
} }
} }
@@ -29,6 +38,7 @@ pub fn render_login(
f: &mut Frame, f: &mut Frame,
area: Rect, area: Rect,
theme: &Theme, theme: &Theme,
// FIX: take &LoginState (reference), not owned
login_state: &LoginState, login_state: &LoginState,
app_state: &AppState, app_state: &AppState,
is_edit_mode: bool, is_edit_mode: bool,
@@ -62,14 +72,15 @@ pub fn render_login(
// --- FORM RENDERING (Using new canvas API) --- // --- FORM RENDERING (Using new canvas API) ---
let _canvas_highlight_state = convert_highlight_state(highlight_state); let _canvas_highlight_state = convert_highlight_state(highlight_state);
// Wrap LoginState in FormEditor // Wrap LoginState in FormEditor (no clone needed)
let editor = FormEditor::new(login_state.clone()); let editor = FormEditor::new(login_state);
// Use DefaultCanvasTheme instead of app Theme
let input_rect = render_canvas( let input_rect = render_canvas(
f, f,
chunks[0], chunks[0],
&editor, &editor,
theme, &DefaultCanvasTheme,
); );
// --- ERROR MESSAGE --- // --- ERROR MESSAGE ---
@@ -150,7 +161,7 @@ pub fn render_login(
f.area(), f.area(),
input_rect, input_rect,
&DefaultCanvasTheme, &DefaultCanvasTheme,
&editor, &editor, // FIX: pass &editor
); );
} }
} }

View File

@@ -21,6 +21,7 @@ pub struct AuthState {
} }
/// Represents the state of the Login form UI /// Represents the state of the Login form UI
#[derive(Clone)]
pub struct LoginState { pub struct LoginState {
pub username: String, pub username: String,
pub password: String, pub password: String,