This commit is contained in:
filipriec
2025-08-20 11:33:34 +02:00
parent 2cda54633f
commit 589220a2ba
6 changed files with 11 additions and 62 deletions

View File

@@ -3,8 +3,7 @@ use crate::config::colors::themes::Theme;
use crate::state::app::highlight::HighlightState;
use crate::state::app::state::AppState;
use crate::state::pages::add_table::{AddTableFocus, AddTableState};
use canvas::{render_canvas_default, render_canvas};
use canvas::canvas::HighlightState as CanvasHighlightState;
use canvas::{render_canvas_default, render_canvas, FormEditor};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Modifier, Style},
@@ -14,15 +13,6 @@ use ratatui::{
};
use crate::components::common::dialog;
// Helper function to convert between HighlightState types
fn convert_highlight_state(local: &HighlightState) -> CanvasHighlightState {
match local {
HighlightState::Off => CanvasHighlightState::Off,
HighlightState::Characterwise { anchor } => CanvasHighlightState::Characterwise { anchor: *anchor },
HighlightState::Linewise { anchor_line } => CanvasHighlightState::Linewise { anchor_line: *anchor_line },
}
}
/// Renders the Add New Table page layout, structuring the display of table information,
/// input fields, and action buttons. Adapts layout based on terminal width.
pub fn render_add_table(
@@ -358,12 +348,8 @@ pub fn render_add_table(
);
// --- Canvas Rendering (Column Definition Input) - USING CANVAS LIBRARY ---
let canvas_highlight_state = convert_highlight_state(highlight_state);
let _active_field_rect = render_canvas(
f,
canvas_area,
add_table_state, // will later be wrapped in FormEditor
);
let editor = FormEditor::new(add_table_state.clone());
let _active_field_rect = render_canvas(f, canvas_area, &editor, theme);
// --- Button Style Helpers ---
let get_button_style = |button_focus: AddTableFocus, current_focus| {