aboutsummaryrefslogtreecommitdiff
path: root/src/container.rs
blob: 5c253add858cf781d220c7539f6ac845e6b6c7c5 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
use iced_widget::container::{Catalog, Style, StyleFn};
use iced_widget::core::{Background, Border, border};

use super::Theme;

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

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

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

pub fn transparent(_theme: &Theme) -> Style {
    Style {
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn primary(theme: &Theme) -> Style {
    let primary = theme.colors().primary;

    Style {
        background: Some(Background::Color(primary.color)),
        text_color: Some(primary.on_primary),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn primary_container(theme: &Theme) -> Style {
    let primary = theme.colors().primary;

    Style {
        background: Some(Background::Color(primary.primary_container)),
        text_color: Some(primary.on_primary_container),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn secondary(theme: &Theme) -> Style {
    let secondary = theme.colors().secondary;

    Style {
        background: Some(Background::Color(secondary.color)),
        text_color: Some(secondary.on_secondary),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn secondary_container(theme: &Theme) -> Style {
    let secondary = theme.colors().secondary;

    Style {
        background: Some(Background::Color(secondary.secondary_container)),
        text_color: Some(secondary.on_secondary_container),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn tertiary(theme: &Theme) -> Style {
    let tertiary = theme.colors().tertiary;

    Style {
        background: Some(Background::Color(tertiary.color)),
        text_color: Some(tertiary.on_tertiary),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn tertiary_container(theme: &Theme) -> Style {
    let tertiary = theme.colors().tertiary;

    Style {
        background: Some(Background::Color(tertiary.tertiary_container)),
        text_color: Some(tertiary.on_tertiary_container),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn error(theme: &Theme) -> Style {
    let error = theme.colors().error;

    Style {
        background: Some(Background::Color(error.color)),
        text_color: Some(error.on_error),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn error_container(theme: &Theme) -> Style {
    let error = theme.colors().error;

    Style {
        background: Some(Background::Color(error.error_container)),
        text_color: Some(error.on_error_container),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn surface(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.color)),
        text_color: Some(surface.on_surface),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn surface_container_lowest(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.surface_container.lowest)),
        text_color: Some(surface.on_surface),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn surface_container_low(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.surface_container.low)),
        text_color: Some(surface.on_surface),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn surface_container(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.surface_container.base)),
        text_color: Some(surface.on_surface),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn surface_container_high(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.surface_container.high)),
        text_color: Some(surface.on_surface),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn surface_container_highest(theme: &Theme) -> Style {
    let surface = theme.colors().surface;

    Style {
        background: Some(Background::Color(surface.surface_container.highest)),
        text_color: Some(surface.on_surface),
        border: border::rounded(8),
        ..Style::default()
    }
}

pub fn inverse_surface(theme: &Theme) -> Style {
    let inverse = theme.colors().inverse;

    Style {
        background: Some(Background::Color(inverse.inverse_surface)),
        text_color: Some(inverse.inverse_on_surface),
        border: border::rounded(4),
        ..Style::default()
    }
}

pub fn outlined(theme: &Theme) -> Style {
    let base = transparent(theme);

    Style {
        border: Border {
            color: theme.colors().outline.color,
            ..base.border
        },
        ..base
    }
}