summaryrefslogtreecommitdiff
path: root/crates/material_theme/src/dialog.rs
blob: a022548519d68dba1f184cbf95b1a7baded7542a (plain)
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
31
32
33
34
35
36
37
38
39
40
41
use iced_dialog::dialog::{Catalog, Style, StyleFn};
use iced_widget::container;
use iced_widget::core::{Background, border};

use super::{Theme, text};

impl Catalog for Theme {
    type Class<'a> = StyleFn<'a, Self>;

    fn default<'a>() -> <Self as Catalog>::Class<'a> {
        Box::new(default)
    }

    fn default_container<'a>() -> <Self as container::Catalog>::Class<'a> {
        Box::new(default_container)
    }

    fn default_title<'a>() -> <Self as iced_widget::text::Catalog>::Class<'a> {
        Box::new(text::surface)
    }

    fn style(&self, class: &<Self as Catalog>::Class<'_>) -> Style {
        class(self)
    }
}

pub fn default_container(theme: &Theme) -> container::Style {
    let colors = theme.colorscheme.surface;
    container::Style {
        background: Some(Background::Color(colors.surface_container.high)),
        text_color: Some(colors.on_surface_variant),
        border: border::rounded(28),
        ..container::Style::default()
    }
}

pub fn default(theme: &Theme) -> Style {
    Style {
        backdrop_color: theme.colorscheme.scrim,
    }
}