textiler_core/theme/theme_mode.rs
1use dark_light::Mode;
2
3/// The theme kind
4#[derive(Debug, Clone, PartialEq, Default)]
5pub enum ThemeMode {
6 /// Dark mode
7 Dark,
8 /// Light mode
9 Light,
10 /// Follow the system
11 #[default]
12 System,
13}
14
15impl ThemeMode {
16 /// Detects system mode if possible, but only has effect if
17 /// the mode is System
18 pub fn detect(self) -> ThemeMode {
19 match self {
20 ThemeMode::System => match dark_light::detect() {
21 Mode::Dark => ThemeMode::Dark,
22 Mode::Light => ThemeMode::Light,
23 Mode::Default => ThemeMode::Light,
24 },
25 other => other,
26 }
27 }
28}