zest_theme/theme/
custom.rs1use crate::{Component, Container, Palette, Theme, Typography};
7use embedded_graphics::{mono_font::MonoFont, pixelcolor::Rgb888};
8
9#[derive(Clone)]
12pub struct CustomBuilder<'a> {
13 theme: Theme<'a, Rgb888>,
14}
15
16impl<'a> CustomBuilder<'a> {
17 #[must_use]
19 pub fn from_dark() -> Self {
20 Self {
21 theme: crate::theme::dark::THEME,
22 }
23 }
24
25 #[must_use]
27 pub fn from_light() -> Self {
28 Self {
29 theme: crate::theme::light::THEME,
30 }
31 }
32
33 #[must_use]
35 pub fn from_theme(theme: Theme<'a, Rgb888>) -> Self {
36 Self { theme }
37 }
38
39 #[must_use]
41 pub fn accent(mut self, accent: Component<Rgb888>) -> Self {
42 self.theme.accent = accent;
43 self
44 }
45
46 #[must_use]
48 pub fn background(mut self, bg: Container<Rgb888>) -> Self {
49 self.theme.background = bg;
50 self
51 }
52
53 #[must_use]
55 pub fn primary(mut self, primary: Container<Rgb888>) -> Self {
56 self.theme.primary = primary;
57 self
58 }
59
60 #[must_use]
62 pub fn palette(mut self, palette: Palette<Rgb888>) -> Self {
63 self.theme.palette = palette;
64 self
65 }
66
67 #[must_use]
69 pub fn typography(mut self, typography: Typography<'a>) -> Self {
70 self.theme.typography = typography;
71 self
72 }
73
74 #[must_use]
76 pub fn display_font(mut self, font: &'a MonoFont<'a>) -> Self {
77 self.theme.typography.display = font;
78 self
79 }
80
81 #[must_use]
84 pub fn font(mut self, font: &'a MonoFont<'a>) -> Self {
85 self.theme.typography.body = font;
86 self
87 }
88
89 #[must_use]
91 pub fn dark(mut self, is_dark: bool) -> Self {
92 self.theme.is_dark = is_dark;
93 self
94 }
95
96 #[must_use]
98 pub fn build(self) -> Theme<'a, Rgb888> {
99 self.theme
100 }
101}