use gtk::gdk;
#[cfg(feature = "serde")]
use serde::Deserialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ThemeColorVariant {
Light,
Dark,
}
impl ThemeColorVariant {
pub fn current(display: &gdk::Display) -> Self {
if adw::StyleManager::for_display(display).is_dark() {
Self::Dark
} else {
Self::Light
}
}
}
#[cfg_attr(feature = "serde", derive(Deserialize))]
#[derive(Debug, Clone)]
pub struct ThemeColor {
light: String,
dark: String,
}
impl ThemeColor {
pub fn new(light: &str, dark: &str) -> Self {
Self {
light: light.into(),
dark: dark.into(),
}
}
pub fn get(&self, variant: ThemeColorVariant) -> String {
match variant {
ThemeColorVariant::Light => &self.light,
ThemeColorVariant::Dark => &self.dark,
}
.clone()
}
}