🚚 Now we have ComponentsInRegions
This commit is contained in:
parent
6ec9287113
commit
cf335081f7
3 changed files with 11 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ mod definition;
|
||||||
pub use definition::{ThemeRef, ThemeTrait};
|
pub use definition::{ThemeRef, ThemeTrait};
|
||||||
|
|
||||||
mod regions;
|
mod regions;
|
||||||
pub(crate) use regions::ComponentsRegions;
|
pub(crate) use regions::ComponentsInRegions;
|
||||||
pub use regions::{add_component_in, Region};
|
pub use regions::{add_component_in, Region};
|
||||||
|
|
||||||
pub(crate) mod all;
|
pub(crate) mod all;
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,18 @@ use crate::{Handle, LazyStatic, SmartDefault};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
static THEME_REGIONS: LazyStatic<RwLock<HashMap<Handle, ComponentsRegions>>> =
|
static THEME_REGIONS: LazyStatic<RwLock<HashMap<Handle, ComponentsInRegions>>> =
|
||||||
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
LazyStatic::new(|| RwLock::new(HashMap::new()));
|
||||||
|
|
||||||
static COMMON_REGIONS: LazyStatic<RwLock<ComponentsRegions>> =
|
static COMMON_REGIONS: LazyStatic<RwLock<ComponentsInRegions>> =
|
||||||
LazyStatic::new(|| RwLock::new(ComponentsRegions::default()));
|
LazyStatic::new(|| RwLock::new(ComponentsInRegions::default()));
|
||||||
|
|
||||||
#[derive(SmartDefault)]
|
#[derive(SmartDefault)]
|
||||||
pub struct ComponentsRegions(HashMap<&'static str, AnyComponents>);
|
pub struct ComponentsInRegions(HashMap<&'static str, AnyComponents>);
|
||||||
|
|
||||||
impl ComponentsRegions {
|
impl ComponentsInRegions {
|
||||||
pub fn new(region: &'static str, arc: ArcAnyComponent) -> Self {
|
pub fn new(region: &'static str, arc: ArcAnyComponent) -> Self {
|
||||||
let mut regions = ComponentsRegions::default();
|
let mut regions = ComponentsInRegions::default();
|
||||||
regions.add_component_in(region, arc);
|
regions.add_component_in(region, arc);
|
||||||
regions
|
regions
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ pub fn add_component_in(region: Region, arc: ArcAnyComponent) {
|
||||||
if let Some(r) = regions.get_mut(&theme.handle()) {
|
if let Some(r) = regions.get_mut(&theme.handle()) {
|
||||||
r.add_component_in(region, arc);
|
r.add_component_in(region, arc);
|
||||||
} else {
|
} else {
|
||||||
regions.insert(theme.handle(), ComponentsRegions::new(region, arc));
|
regions.insert(theme.handle(), ComponentsInRegions::new(region, arc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub use actix_web::Result as ResultPage;
|
||||||
use crate::base::action;
|
use crate::base::action;
|
||||||
use crate::core::component::{AnyComponents, ArcAnyComponent, ComponentTrait};
|
use crate::core::component::{AnyComponents, ArcAnyComponent, ComponentTrait};
|
||||||
use crate::core::component::{Context, ContextOp};
|
use crate::core::component::{Context, ContextOp};
|
||||||
use crate::core::theme::ComponentsRegions;
|
use crate::core::theme::ComponentsInRegions;
|
||||||
use crate::html::{html, Markup, DOCTYPE};
|
use crate::html::{html, Markup, DOCTYPE};
|
||||||
use crate::html::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
use crate::html::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
||||||
use crate::locale::L10n;
|
use crate::locale::L10n;
|
||||||
|
|
@ -24,7 +24,7 @@ pub struct Page {
|
||||||
context : Context,
|
context : Context,
|
||||||
body_classes: OptionClasses,
|
body_classes: OptionClasses,
|
||||||
skip_to : OptionId,
|
skip_to : OptionId,
|
||||||
regions : ComponentsRegions,
|
regions : ComponentsInRegions,
|
||||||
template : String,
|
template : String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ impl Page {
|
||||||
context : Context::new(request),
|
context : Context::new(request),
|
||||||
body_classes: OptionClasses::default(),
|
body_classes: OptionClasses::default(),
|
||||||
skip_to : OptionId::default(),
|
skip_to : OptionId::default(),
|
||||||
regions : ComponentsRegions::default(),
|
regions : ComponentsInRegions::default(),
|
||||||
template : "default".to_owned(),
|
template : "default".to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue