♻️ Major code restructuring

This commit is contained in:
Manuel Cillero 2024-02-09 14:05:38 +01:00
parent a96e203bb3
commit fa66d628a0
221 changed files with 228 additions and 315 deletions

32
src/core/theme/all.rs Normal file
View file

@ -0,0 +1,32 @@
use crate::config;
use crate::core::theme::ThemeRef;
use crate::LazyStatic;
use std::sync::RwLock;
// THEMES ******************************************************************************************
pub static THEMES: LazyStatic<RwLock<Vec<ThemeRef>>> = LazyStatic::new(|| RwLock::new(Vec::new()));
// DEFAULT THEME ***********************************************************************************
pub static THEME: LazyStatic<ThemeRef> =
LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) {
Some(theme) => theme,
None => &crate::base::theme::Inception,
});
// THEME BY NAME ***********************************************************************************
pub fn theme_by_single_name(single_name: &str) -> Option<ThemeRef> {
let single_name = single_name.to_lowercase();
match THEMES
.read()
.unwrap()
.iter()
.find(|t| t.single_name().to_lowercase() == single_name)
{
Some(theme) => Some(*theme),
_ => None,
}
}