vcard_tui 0.1.2

Terminal UI application for managing vCard contacts.
use ratatui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use ratatui::text::Text;
use ratatui::widgets::Paragraph;
use ratatui::Frame;
use vcard_parser::traits::HasValue;

use crate::state::popup::property_url::{PropertyUrlSelected, PropertyUrlState};
use crate::tui::HasTypeParam;
use crate::util::{get_block, render_widget_with_textarea};

pub fn render_property_url_popup(state: &mut PropertyUrlState, frame: &mut Frame, rect: Rect) {
    let rows = Layout::default()
        .direction(Direction::Vertical)
        .constraints([
            Constraint::Max(3),
            Constraint::Length(3),
        ])
        .margin(1)
        .split(rect);
    let row1_cols = Layout::default()
        .direction(Direction::Horizontal)
        .constraints([
            Constraint::Percentage(25),
            Constraint::Percentage(75),
        ])
        .split(rows[0]);
    let row2_cols = Layout::default()
        .direction(Direction::Horizontal)
        .constraints([
            Constraint::Percentage(85),
            Constraint::Percentage(15),
        ])
        .split(rows[1]);

    render_widget_with_textarea(
        "Type",
        &state.type_param_get().get_value().to_string(),
        state.selected.is(PropertyUrlSelected::ParamType),
        state.textarea.as_mut(),
        frame,
        row1_cols[0],
    );
    render_widget_with_textarea(
        "Url",
        &state.property.get_value().to_string(),
        state.selected.is(PropertyUrlSelected::Uri),
        state.textarea.as_mut(),
        frame,
        row1_cols[1],
    );

    frame.render_widget(
        Paragraph::new(Text::raw("Save"))
            .block(get_block(state.selected.is(PropertyUrlSelected::Save), ""))
            .alignment(Alignment::Center),
        row2_cols[1],
    );
}