mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-28 02:10:39 +02:00
Merge pull request #531 from Rudxain/feature/auto_theme
feat(theme): follow system theme by default
This commit is contained in:
commit
2bfdb10c01
3 changed files with 79 additions and 56 deletions
|
|
@ -1,5 +1,8 @@
|
|||
use crate::core::sync::{get_android_sdk, User};
|
||||
use crate::core::utils::DisplayablePath;
|
||||
use crate::core::{
|
||||
sync::{get_android_sdk, User},
|
||||
theme::Theme,
|
||||
};
|
||||
use crate::gui::views::settings::Settings;
|
||||
use crate::CACHE_DIR;
|
||||
use crate::CONFIG_DIR;
|
||||
|
|
@ -43,7 +46,7 @@ pub struct DeviceSettings {
|
|||
impl Default for GeneralSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
theme: String::from("Dark"),
|
||||
theme: Theme::default().to_string(),
|
||||
expert_mode: false,
|
||||
backup_folder: CACHE_DIR.join("backups"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
use dark_light;
|
||||
use iced::{color, Color};
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Eq, Copy, Clone)]
|
||||
/// Color scheme
|
||||
pub enum Theme {
|
||||
#[default]
|
||||
/// `Dark` or `Light`, according to `dark_light`
|
||||
Auto,
|
||||
/// `Dark`-ish and purple
|
||||
Lupin,
|
||||
/// white on black
|
||||
Dark,
|
||||
/// black on white
|
||||
Light,
|
||||
}
|
||||
|
||||
|
|
@ -39,62 +46,72 @@ pub struct ColorPalette {
|
|||
}
|
||||
|
||||
impl Theme {
|
||||
pub const ALL: [Self; 3] = [Self::Lupin, Self::Dark, Self::Light];
|
||||
pub const ALL: [Self; 4] = [Self::Auto, Self::Lupin, Self::Dark, Self::Light];
|
||||
|
||||
pub fn palette(self) -> ColorPalette {
|
||||
const DARK: ColorPalette = ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0x111111),
|
||||
foreground: color!(0x1C1C1C),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x5E4266),
|
||||
secondary: color!(0x386e50),
|
||||
surface: color!(0x828282),
|
||||
error: color!(0x992B2B),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0xBA84FC),
|
||||
secondary: color!(0x49eb7a),
|
||||
surface: color!(0xE0E0E0),
|
||||
error: color!(0xC13047),
|
||||
},
|
||||
};
|
||||
const LIGHT: ColorPalette = ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0xEEEEEE),
|
||||
foreground: color!(0xE0E0E0),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x818181),
|
||||
secondary: color!(0xF9D659),
|
||||
surface: color!(0x818181),
|
||||
error: color!(0x992B2B),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0x673AB7),
|
||||
secondary: color!(0x3797A4),
|
||||
surface: color!(0x000000),
|
||||
error: color!(0xC13047),
|
||||
},
|
||||
};
|
||||
const LUPIN: ColorPalette = ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0x282a36),
|
||||
foreground: color!(0x353746),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x58406F),
|
||||
secondary: color!(0x386e50),
|
||||
surface: color!(0xa2a4a3),
|
||||
error: color!(0xA13034),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0xbd94f9),
|
||||
secondary: color!(0x49eb7a),
|
||||
surface: color!(0xf4f8f3),
|
||||
error: color!(0xE63E6D),
|
||||
},
|
||||
};
|
||||
match self {
|
||||
Self::Dark => ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0x111111),
|
||||
foreground: color!(0x1C1C1C),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x5E4266),
|
||||
secondary: color!(0x386e50),
|
||||
surface: color!(0x828282),
|
||||
error: color!(0x992B2B),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0xBA84FC),
|
||||
secondary: color!(0x49eb7a),
|
||||
surface: color!(0xE0E0E0),
|
||||
error: color!(0xC13047),
|
||||
},
|
||||
},
|
||||
Self::Light => ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0xEEEEEE),
|
||||
foreground: color!(0xE0E0E0),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x818181),
|
||||
secondary: color!(0xF9D659),
|
||||
surface: color!(0x818181),
|
||||
error: color!(0x992B2B),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0x673AB7),
|
||||
secondary: color!(0x3797A4),
|
||||
surface: color!(0x000000),
|
||||
error: color!(0xC13047),
|
||||
},
|
||||
},
|
||||
Self::Lupin => ColorPalette {
|
||||
base: BaseColors {
|
||||
background: color!(0x282a36),
|
||||
foreground: color!(0x353746),
|
||||
},
|
||||
normal: NormalColors {
|
||||
primary: color!(0x58406F),
|
||||
secondary: color!(0x386e50),
|
||||
surface: color!(0xa2a4a3),
|
||||
error: color!(0xA13034),
|
||||
},
|
||||
bright: BrightColors {
|
||||
primary: color!(0xbd94f9),
|
||||
secondary: color!(0x49eb7a),
|
||||
surface: color!(0xf4f8f3),
|
||||
error: color!(0xE63E6D),
|
||||
},
|
||||
Self::Dark => DARK,
|
||||
Self::Light => LIGHT,
|
||||
Self::Lupin => LUPIN,
|
||||
Self::Auto => match dark_light::detect() {
|
||||
dark_light::Mode::Dark => DARK,
|
||||
dark_light::Mode::Light => LIGHT,
|
||||
// If the mode can't be detected, fall back to dark.
|
||||
dark_light::Mode::Default => DARK,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -109,6 +126,7 @@ impl std::fmt::Display for Theme {
|
|||
Self::Dark => "Dark",
|
||||
Self::Light => "Light",
|
||||
Self::Lupin => "Lupin",
|
||||
Self::Auto => "Auto (follow system theme)",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ pub fn string_to_theme(theme: &str) -> Theme {
|
|||
"Dark" => Theme::Dark,
|
||||
"Light" => Theme::Light,
|
||||
"Lupin" => Theme::Lupin,
|
||||
_ => Theme::Dark,
|
||||
// Auto uses `Display`, so it doesn't have a canonical repr
|
||||
t if t.starts_with("Auto") => Theme::Auto,
|
||||
_ => Theme::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue