1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use crate::theme::ThemeProps;
use raui_core::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(PropsData, Debug, Clone, Serialize, Deserialize)]
#[props_data(raui_core::props::PropsData)]
#[prefab(raui_core::Prefab)]
pub struct ModalPaperProps {
#[serde(default = "ModalPaperProps::default_shadow_shown")]
pub shadow_shown: bool,
#[serde(default)]
pub shadow_variant: String,
}
impl ModalPaperProps {
fn default_shadow_shown() -> bool {
true
}
}
impl Default for ModalPaperProps {
fn default() -> Self {
Self {
shadow_shown: Self::default_shadow_shown(),
shadow_variant: Default::default(),
}
}
}
pub fn modal_paper(context: WidgetContext) -> WidgetNode {
let WidgetContext {
key,
props,
shared_props,
named_slots,
..
} = context;
unpack_named_slots!(named_slots => content);
let ModalPaperProps {
shadow_shown,
shadow_variant,
} = props.read_cloned_or_default();
let mut color = Color::transparent();
if shadow_shown {
if let Ok(props) = shared_props.read::<ThemeProps>() {
if let Some(c) = props.modal_shadow_variants.get(&shadow_variant) {
color = *c;
}
}
}
let shadow_image_props = ImageBoxProps {
material: ImageBoxMaterial::Color(ImageBoxColor {
color,
..Default::default()
}),
..Default::default()
};
widget! {
(#{key} portal_box {
content = (#{"container"} content_box [
(#{"shadow-barrier"} navigation_barrier {
content = (#{"shadow-image"} image_box: {shadow_image_props})
})
{content}
])
})
}
}