use std::sync::OnceLock;
use ratatui::style::Color;
#[derive(Clone, Copy)]
pub struct Theme {
pub accent: Color,
pub highlight: Color,
pub muted: Color,
pub selected: Color,
pub success: Color,
pub danger: Color,
pub warning: Color,
pub text: Color,
pub surface: Color,
}
const DARK: Theme = Theme {
accent: Color::Rgb(167, 192, 128),
highlight: Color::Rgb(230, 152, 117),
muted: Color::Rgb(133, 146, 137),
selected: Color::Rgb(219, 188, 127),
success: Color::Rgb(167, 192, 128),
danger: Color::Rgb(230, 126, 128),
warning: Color::Rgb(219, 188, 127),
text: Color::Rgb(211, 198, 170),
surface: Color::Rgb(65, 75, 78),
};
const LIGHT: Theme = Theme {
accent: Color::Rgb(93, 121, 60),
highlight: Color::Rgb(245, 125, 38),
muted: Color::Rgb(124, 133, 120),
selected: Color::Rgb(223, 160, 0),
success: Color::Rgb(93, 121, 60),
danger: Color::Rgb(248, 85, 82),
warning: Color::Rgb(176, 133, 0),
text: Color::Rgb(92, 106, 114),
surface: Color::Rgb(228, 222, 203),
};
static THEME: OnceLock<Theme> = OnceLock::new();
pub fn init(is_light: bool) {
let _ = THEME.set(if is_light { LIGHT } else { DARK });
}
fn current() -> Theme {
*THEME.get_or_init(|| DARK)
}
pub fn accent() -> Color {
current().accent
}
pub fn highlight() -> Color {
current().highlight
}
pub fn muted() -> Color {
current().muted
}
pub fn selected() -> Color {
current().selected
}
pub fn success() -> Color {
current().success
}
pub fn danger() -> Color {
current().danger
}
pub fn warning() -> Color {
current().warning
}
pub fn text() -> Color {
current().text
}
pub fn surface() -> Color {
current().surface
}