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
30
use std::fmt::Display;

use floem::{view::View, views::Decorators, widgets::button as upstreambutton};

use crate::get_current_theme;

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

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

pub fn button<S: Display + 'static>(
    label: impl Fn() -> S + 'static,
    props: Option<ButtonProps>,
) -> impl View {
    let base_widget = upstreambutton(label);
    let theme = get_current_theme();

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

    let styles_enhancer = theme.get_button_style(props);

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

    styled_button
}