use gdk4::RGBA;

use crate::themes::NewsflashTheme;

#[derive(Debug, Clone, Copy)]
pub struct ThemeInfo {
    pub name: &'static str,
    pub foreground: RGBA,
    pub background: RGBA,
    pub accent: Option<RGBA>,
    pub is_dark: bool,
}

impl ThemeInfo {
    const ADWAITA_LIGHT: ThemeInfo = ThemeInfo {
        name: "adwaita-light",
        foreground: RGBA::new(0.113, 0.121, 0.109, 1.0),
        background: RGBA::new(0.980, 0.980, 0.980, 1.0),
        accent: None,
        is_dark: false,
    };
    const ADWAITA_DARK: ThemeInfo = ThemeInfo {
        name: "adwaita-dark",
        foreground: RGBA::new(1.0, 1.0, 1.0, 0.9),
        background: RGBA::new(0.133, 0.133, 0.149, 1.0),
        accent: None,
        is_dark: true,
    };
    const SPRING: ThemeInfo = ThemeInfo {
        name: "spring",
        foreground: RGBA::new(0.250, 0.368, 0.501, 1.0),
        background: RGBA::new(0.972, 1.0, 0.949, 1.0),
        accent: Some(RGBA::new(0.2, 0.65, 0.4, 1.0)),
        is_dark: false,
    };
    const MIDNIGHT: ThemeInfo = ThemeInfo {
        name: "midnight",
        foreground: RGBA::new(1.0, 1.0, 1.0, 0.6),
        background: RGBA::new(0.137, 0.207, 0.250, 1.0),
        accent: Some(RGBA::new(0.160, 0.470, 0.650, 1.0)),
        is_dark: true,
    };
    const PARCHMENT: ThemeInfo = ThemeInfo {
        name: "parchment",
        foreground: RGBA::new(0.0, 0.0, 0.0, 0.8),
        background: RGBA::new(0.980, 0.949, 0.882, 1.0),
        accent: Some(RGBA::new(0.60, 0.250, 0.058, 1.0)),
        is_dark: false,
    };
    const GRUVBOX: ThemeInfo = ThemeInfo {
        name: "gruvbox",
        foreground: RGBA::new(0.984, 0.945, 0.780, 0.8),
        background: RGBA::new(0.156, 0.156, 0.156, 1.0),
        accent: Some(RGBA::new(0.407, 0.615, 0.415, 1.0)),
        is_dark: true,
    };
    const ZORIN: ThemeInfo = ThemeInfo {
        name: "zorin",
        foreground: RGBA::new(0.741, 0.901, 0.984, 1.0),
        background: RGBA::new(0.117, 0.145, 0.160, 1.0),
        accent: Some(RGBA::new(0.949, 0.984, 1.0, 1.0)),
        is_dark: true,
    };

    pub fn get(theme: &NewsflashTheme) -> Self {
        match theme {
            NewsflashTheme::Default => {
                if libadwaita::StyleManager::default().is_dark() {
                    Self::ADWAITA_DARK
                } else {
                    Self::ADWAITA_LIGHT
                }
            }
            NewsflashTheme::Spring => Self::SPRING,
            NewsflashTheme::Midnight => Self::MIDNIGHT,
            NewsflashTheme::Parchment => Self::PARCHMENT,
            NewsflashTheme::Gruvbox => Self::GRUVBOX,
            NewsflashTheme::Zorin => Self::ZORIN,
        }
    }
}
