🚚 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};
|
||||
|
||||
mod regions;
|
||||
pub(crate) use regions::ComponentsRegions;
|
||||
pub(crate) use regions::ComponentsInRegions;
|
||||
pub use regions::{add_component_in, Region};
|
||||
|
||||
pub(crate) mod all;
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@ use crate::{Handle, LazyStatic, SmartDefault};
|
|||
use std::collections::HashMap;
|
||||
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()));
|
||||
|
||||
static COMMON_REGIONS: LazyStatic<RwLock<ComponentsRegions>> =
|
||||
LazyStatic::new(|| RwLock::new(ComponentsRegions::default()));
|
||||
static COMMON_REGIONS: LazyStatic<RwLock<ComponentsInRegions>> =
|
||||
LazyStatic::new(|| RwLock::new(ComponentsInRegions::default()));
|
||||
|
||||
#[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 {
|
||||
let mut regions = ComponentsRegions::default();
|
||||
let mut regions = ComponentsInRegions::default();
|
||||
regions.add_component_in(region, arc);
|
||||
regions
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ pub fn add_component_in(region: Region, arc: ArcAnyComponent) {
|
|||
if let Some(r) = regions.get_mut(&theme.handle()) {
|
||||
r.add_component_in(region, arc);
|
||||
} 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::core::component::{AnyComponents, ArcAnyComponent, ComponentTrait};
|
||||
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::{ClassesOp, Favicon, OptionClasses, OptionId, OptionTranslated};
|
||||
use crate::locale::L10n;
|
||||
|
|
@ -24,7 +24,7 @@ pub struct Page {
|
|||
context : Context,
|
||||
body_classes: OptionClasses,
|
||||
skip_to : OptionId,
|
||||
regions : ComponentsRegions,
|
||||
regions : ComponentsInRegions,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ impl Page {
|
|||
context : Context::new(request),
|
||||
body_classes: OptionClasses::default(),
|
||||
skip_to : OptionId::default(),
|
||||
regions : ComponentsRegions::default(),
|
||||
regions : ComponentsInRegions::default(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue