💄 Change to THEME_DEFAULT name & improve regions
This commit is contained in:
parent
2cd1d1332c
commit
470223e684
4 changed files with 28 additions and 18 deletions
|
|
@ -10,7 +10,7 @@ pub static THEMES: LazyStatic<RwLock<Vec<ThemeRef>>> = LazyStatic::new(|| RwLock
|
|||
|
||||
// DEFAULT THEME ***********************************************************************************
|
||||
|
||||
pub static THEME: LazyStatic<ThemeRef> =
|
||||
pub static THEME_DEFAULT: LazyStatic<ThemeRef> =
|
||||
LazyStatic::new(|| match theme_by_single_name(&config::SETTINGS.app.theme) {
|
||||
Some(theme) => theme,
|
||||
None => &crate::base::theme::Inception,
|
||||
|
|
|
|||
|
|
@ -39,23 +39,33 @@ impl ComponentsInRegions {
|
|||
}
|
||||
}
|
||||
|
||||
pub enum Region {
|
||||
pub enum InRegion {
|
||||
Content,
|
||||
Named(&'static str),
|
||||
OfTheme(ThemeRef, &'static str),
|
||||
OfTheme(&'static str, ThemeRef),
|
||||
}
|
||||
|
||||
pub fn add_component_in(region: Region, arc: ArcAnyComponent) {
|
||||
match region {
|
||||
Region::Named(name) => {
|
||||
COMMON_REGIONS.write().unwrap().add_component_in(name, arc);
|
||||
}
|
||||
Region::OfTheme(theme, region) => {
|
||||
let mut regions = THEME_REGIONS.write().unwrap();
|
||||
if let Some(r) = regions.get_mut(&theme.type_id()) {
|
||||
r.add_component_in(region, arc);
|
||||
} else {
|
||||
regions.insert(theme.type_id(), ComponentsInRegions::new(region, arc));
|
||||
impl InRegion {
|
||||
pub fn add_component(&self, arc: ArcAnyComponent) -> &Self {
|
||||
match self {
|
||||
InRegion::Content => {
|
||||
COMMON_REGIONS
|
||||
.write()
|
||||
.unwrap()
|
||||
.add_component_in("content", arc);
|
||||
}
|
||||
InRegion::Named(name) => {
|
||||
COMMON_REGIONS.write().unwrap().add_component_in(name, arc);
|
||||
}
|
||||
InRegion::OfTheme(region, theme) => {
|
||||
let mut regions = THEME_REGIONS.write().unwrap();
|
||||
if let Some(r) = regions.get_mut(&theme.type_id()) {
|
||||
r.add_component_in(region, arc);
|
||||
} else {
|
||||
regions.insert(theme.type_id(), ComponentsInRegions::new(region, arc));
|
||||
}
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue