#[allow(unused)]
use crate::*;
use pax_engine::api::{Duration, Opacity, Property};
use pax_engine::pax;
use pax_runtime::api::NodeContext;
#[pax]
#[engine_import_path("pax_engine")]
#[inlined(<Group/>)]
pub struct Router {}
#[pax]
#[engine_import_path("pax_engine")]
#[route_branch(path = "path", default = "default")]
#[inlined(
<Group width=100% height=100% anchor_x=0% anchor_y=0%>
for i in 0..self._projected_children_count {
slot(i)
}
</Group>
@settings {
@mount: on_mount
}
)]
pub struct Route {
pub path: Property<String>,
pub r#default: Property<bool>,
pub _projected_children_count: Property<usize>,
}
#[pax]
#[engine_import_path("pax_engine")]
#[custom(Default)]
#[route_branch(path = "path", default = "default", modal = true)]
#[inlined(
<Group width=100% height=100% anchor_x=0% anchor_y=0%>
<Group width=100% height=100% anchor_x=0% anchor_y=0%>
for i in 0..self._projected_children_count {
slot(i)
}
</Group>
<EventBlocker
width=100%
height=100%
background=rgba(0, 0, 0, 255)
opacity={self.scrim_opacity}
@in=@timeline {
duration: {self.duration},
opacity: {
0: 0, Linear,
100%: {$base},
},
}
@out=@timeline {
duration: {self.duration},
opacity: {
0: {$base}, Linear,
100%: 0,
},
}
/>
</Group>
@settings {
@mount: on_mount
}
)]
pub struct RouteModal {
pub path: Property<String>,
pub r#default: Property<bool>,
pub duration: Property<Duration>,
pub scrim_opacity: Property<Opacity>,
pub _projected_children_count: Property<usize>,
}
#[pax]
#[engine_import_path("pax_engine")]
#[custom(Default)]
#[route_branch(path = "path", default = "default", modal = true)]
#[inlined(
<Group width=100% height=100% anchor_x=0% anchor_y=0%>
<Group
id=card_shell
width=100%
height=100%
anchor_x=0%
anchor_y=0%
@in=@timeline {
duration: {self.duration},
x: {
0: {self.edge == RouteCardEdge::Leading ? $base - 100% : self.edge == RouteCardEdge::Trailing ? $base + 100% : $base}, OutQuad,
100%: {$base},
},
y: {
0: {self.edge == RouteCardEdge::Top ? $base - 100% : self.edge == RouteCardEdge::Bottom ? $base + 100% : $base}, OutQuad,
100%: {$base},
},
}
@out=@timeline {
duration: {self.duration},
x: {
0: {$base}, OutQuad,
100%: {self.edge == RouteCardEdge::Leading ? $base - 100% : self.edge == RouteCardEdge::Trailing ? $base + 100% : $base},
},
y: {
0: {$base}, OutQuad,
100%: {self.edge == RouteCardEdge::Top ? $base - 100% : self.edge == RouteCardEdge::Bottom ? $base + 100% : $base},
},
}
>
for i in 0..self._projected_children_count {
slot(i)
}
</Group>
<EventBlocker
width=100%
height=100%
background=rgba(0, 0, 0, 255)
opacity={self.scrim_opacity}
@in=@timeline {
duration: {self.duration},
opacity: {
0: 0, Linear,
100%: {$base},
},
}
@out=@timeline {
duration: {self.duration},
opacity: {
0: {$base}, Linear,
100%: 0,
},
}
/>
</Group>
@settings {
@mount: on_mount
}
)]
pub struct RouteCard {
pub path: Property<String>,
pub r#default: Property<bool>,
pub edge: Property<RouteCardEdge>,
pub duration: Property<Duration>,
pub scrim_opacity: Property<Opacity>,
pub curve: Property<RouteCardCurve>,
pub _projected_children_count: Property<usize>,
}
#[pax]
#[engine_import_path("pax_engine")]
pub enum RouteCardEdge {
Leading,
#[default]
Trailing,
Top,
Bottom,
}
#[pax]
#[engine_import_path("pax_engine")]
pub enum RouteCardCurve {
Linear,
Hold,
InQuad,
#[default]
OutQuad,
InOutQuad,
InBack,
OutBack,
InOutBack,
}
impl Route {
pub fn on_mount(&mut self, ctx: &NodeContext) {
let projected_children_count = ctx.projected_children_count.clone();
let deps = [projected_children_count.untyped()];
self._projected_children_count
.replace_with(Property::computed(
move || projected_children_count.get(),
&deps,
));
}
}
impl Default for RouteModal {
fn default() -> Self {
Self {
path: Property::default(),
r#default: Property::new(false),
duration: Property::new(Duration::Frames(18.into())),
scrim_opacity: Property::new(Opacity::Alpha(0.3.into())),
_projected_children_count: Property::new(0),
}
}
}
impl RouteModal {
pub fn on_mount(&mut self, ctx: &NodeContext) {
let projected_children_count = ctx.projected_children_count.clone();
let deps = [projected_children_count.untyped()];
self._projected_children_count
.replace_with(Property::computed(
move || projected_children_count.get(),
&deps,
));
}
}
impl Default for RouteCard {
fn default() -> Self {
Self {
path: Property::default(),
r#default: Property::new(false),
edge: Property::new(RouteCardEdge::Trailing),
duration: Property::new(Duration::Frames(18.into())),
scrim_opacity: Property::new(Opacity::Alpha(0.3.into())),
curve: Property::new(RouteCardCurve::OutQuad),
_projected_children_count: Property::new(0),
}
}
}
impl RouteCard {
pub fn on_mount(&mut self, ctx: &NodeContext) {
let projected_children_count = ctx.projected_children_count.clone();
let deps = [projected_children_count.untyped()];
self._projected_children_count
.replace_with(Property::computed(
move || projected_children_count.get(),
&deps,
));
}
}