1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use floem::{
    reactive::RwSignal,
    views::{Decorators, TextInput},
    widgets::text_input as upstream_text_input,
};

use crate::get_current_theme;

use super::common_props::{OxySize, OxyVariant};

#[derive(Default, Clone, Copy)]
pub struct InputProps {
    pub variant: OxyVariant,
    pub size: OxySize,
}

pub fn text_input(buffer: RwSignal<String>, props: Option<InputProps>) -> TextInput {
    let base_widget = upstream_text_input(buffer);

    let theme = get_current_theme();

    let props = props.unwrap_or(InputProps::default());

    let styles_enhancer = theme.get_input_style(props);

    let styled_input = base_widget.style(move |s| styles_enhancer(s));

    styled_input
}