Skip to main content

aethermap_gui/
theme.rs

1use iced::{Color, Theme};
2use iced::theme::Palette;
3
4pub const ACCENT: Color = Color::from_rgb(
5    0x30 as f32 / 255.0,
6    0x70 as f32 / 255.0,
7    0xf0 as f32 / 255.0,
8);
9
10pub const DARK_BACKGROUND: Color = Color::from_rgb(
11    0x1a as f32 / 255.0,
12    0x1a as f32 / 255.0,
13    0x1a as f32 / 255.0,
14);
15
16pub const DARK_SURFACE: Color = Color::from_rgb(
17    0x24 as f32 / 255.0,
18    0x24 as f32 / 255.0,
19    0x24 as f32 / 255.0,
20);
21
22pub const LIGHT_BACKGROUND: Color = Color::from_rgb(
23    0xf2 as f32 / 255.0,
24    0xf2 as f32 / 255.0,
25    0xf2 as f32 / 255.0,
26);
27
28pub const LIGHT_SURFACE: Color = Color::from_rgb(1.0, 1.0, 1.0);
29
30pub fn aether_dark() -> Theme {
31    Theme::custom(
32        String::from("Aether Dark"),
33        Palette {
34            background: DARK_BACKGROUND,
35            text: Color::WHITE,
36            primary: ACCENT,
37            success: Color::from_rgb(0.0, 1.0, 0.0),
38            danger: Color::from_rgb(1.0, 0.0, 0.0),
39        },
40    )
41}
42
43pub fn aether_light() -> Theme {
44    Theme::custom(
45        String::from("Aether Light"),
46        Palette {
47            background: LIGHT_BACKGROUND,
48            text: Color::BLACK,
49            primary: ACCENT,
50            success: Color::from_rgb(0.0, 0.8, 0.0),
51            danger: Color::from_rgb(0.8, 0.0, 0.0),
52        },
53    )
54}
55
56pub mod container_styles {
57    use iced::widget::container;
58    use iced::{border, Color, Theme};
59
60    pub fn card(theme: &Theme) -> container::Appearance {
61        let palette = theme.palette();
62        container::Appearance {
63            text_color: Some(palette.text),
64            background: Some(if palette.background == super::DARK_BACKGROUND {
65                super::DARK_SURFACE.into()
66            } else if palette.background == super::LIGHT_BACKGROUND {
67                super::LIGHT_SURFACE.into()
68            } else {
69                palette.background.into()
70            }),
71            border: border::Border {
72                color: Color::from_rgba(0.5, 0.5, 0.5, 0.1),
73                width: 1.0,
74                radius: 10.0.into(),
75            },
76            ..Default::default()
77        }
78    }
79}