prehnite/widget/
styles.rs

1pub mod container {
2    use iced::border::Radius;
3    use iced::widget::container;
4    use iced::Border;
5
6    pub fn unborder<'a>(
7        func: impl Fn(&iced::Theme) -> container::Style + 'a,
8    ) -> impl Fn(&iced::Theme) -> container::Style + 'a {
9        move |theme| func(theme).border(Border::default())
10    }
11
12    pub fn rect_box(theme: &iced::Theme) -> container::Style {
13        let mut style = container::bordered_box(theme);
14        style.border.radius = Radius::new(0);
15        style
16    }
17
18    pub fn not_focused_rect_box(theme: &iced::Theme) -> container::Style {
19        let mut style = rect_box(theme);
20        style = style.background(theme.palette().background);
21        style
22    }
23
24    pub fn focusable<'a>(is_focused: bool) -> impl Fn(&iced::Theme) -> container::Style + 'a {
25        move |theme| {
26            if is_focused {
27                rect_box(theme)
28            } else {
29                not_focused_rect_box(theme)
30            }
31        }
32    }
33}