going into a new canvas library structure

This commit is contained in:
Priec
2025-08-19 13:24:48 +02:00
parent 858f5137d8
commit d0ff449e3b
7 changed files with 76 additions and 71 deletions

View File

@@ -13,7 +13,8 @@ use ratatui::{
Frame,
};
use crate::state::app::highlight::HighlightState;
use canvas::canvas::{render_canvas, HighlightState as CanvasHighlightState}; // Use canvas library's render function
use canvas::{FormEditor, render_canvas_default, render_suggestions_dropdown, DefaultCanvasTheme};
use canvas::canvas::HighlightState as CanvasHighlightState;
// Helper function to convert between HighlightState types
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
@@ -58,15 +59,17 @@ pub fn render_login(
])
.split(inner_area);
// --- FORM RENDERING (Using canvas library directly) ---
let canvas_highlight_state = convert_highlight_state(highlight_state);
render_canvas(
// --- FORM RENDERING (Using new canvas API) ---
let _canvas_highlight_state = convert_highlight_state(highlight_state);
// Wrap LoginState in FormEditor
let editor = FormEditor::new(login_state.clone());
let input_rect = render_canvas_default(
f,
chunks[0],
login_state, // LoginState implements CanvasState
theme, // Theme implements CanvasTheme
is_edit_mode,
&canvas_highlight_state,
&editor,
theme,
);
// --- ERROR MESSAGE ---
@@ -88,7 +91,7 @@ pub fn render_login(
// Login Button
let login_button_index = 0;
let login_active = if app_state.ui.focus_outside_canvas {
app_state.focused_button_index== login_button_index
app_state.focused_button_index == login_button_index
} else {
false
};
@@ -115,7 +118,7 @@ pub fn render_login(
// Return Button
let return_button_index = 1;
let return_active = if app_state.ui.focus_outside_canvas {
app_state.focused_button_index== return_button_index
app_state.focused_button_index == return_button_index
} else {
false
};
@@ -139,6 +142,19 @@ pub fn render_login(
button_chunks[1],
);
// --- SUGGESTIONS DROPDOWN (if active) ---
if app_state.current_mode == crate::modes::handlers::mode_manager::AppMode::Edit {
if let Some(input_rect) = input_rect {
render_suggestions_dropdown(
f,
f.area(),
input_rect,
&DefaultCanvasTheme,
&editor,
);
}
}
// --- DIALOG ---
if app_state.ui.dialog.dialog_show {
dialog::render_dialog(