oxytail-base 0.1.2

Building block for creating oxytail themes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub mod themes;
pub mod widgets;

use std::sync::OnceLock;

use themes::ThemeStyling;

pub static GLOBAL_THEME: OnceLock<Box<dyn ThemeStyling + Send + Sync>> = OnceLock::new();

pub(crate) fn get_current_theme() -> &'static Box<dyn ThemeStyling + Send + Sync> {
    GLOBAL_THEME.get().expect("Oxytail widget received no theme while trying to render. Did you forget to run `init_theme(theme)`")
}

pub fn init_theme(theme: impl ThemeStyling + Send + Sync + 'static) {
    GLOBAL_THEME.get_or_init(|| Box::new(theme));
}