2. Let the drawer own its transition
Now enable the drawer's built-in side-slide and fade preset. We do not add a timer, delay the reducer or hold a view handle until an animation completes. The stable drawer ID lets Fission associate the entering and exiting surface with the same retained widget.
A local reduced-motion switch makes both paths easy to exercise. It sets DrawerMotion::None for this panel, not a second implementation of the inspection. Fission's broader MotionPreference::Reduced environment setting also resolves declared motion immediately; WidgetMotion::Off only disables defaults on widgets whose motion was left unset.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
fission_component! {
pub InspectionInstructions<()> {
state {
instructions_open: bool = false,
reduce_panel_motion: bool = false,
filter_checked: bool = false,
}
}
view(inspection, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
} =>
Container(SafeArea(child: Scroll(child:
Container(Column(gap: tokens.spacing.m, children: [
Text(cx.tr("inspection.title")).size(tokens.typography.heading1_size),
Text(cx.tr("inspection.context")).color(tokens.colors.text_secondary),
Checkbox(
label: Some(cx.tr("inspection.filter_checked")),
checked: inspection.filter_checked,
bind(on_toggle): to(inspection.filter_checked),
),
Text(cx.tr(if inspection.filter_checked {
"inspection.checked"
} else {
"inspection.pending"
})),
FormControl(
label: Some(cx.tr("inspection.reduce_motion")),
child: Switch(
checked: inspection.reduce_panel_motion,
bind(on_toggle): to(inspection.reduce_panel_motion),
),
),
Button(
child: Text(cx.tr("inspection.open")),
key: "open-instructions",
on_press: reduce { inspection.instructions_open = true; },
).semantics_identifier("inspection.instructions.open"),
Drawer(
id: WidgetId::explicit("inspection.instructions"),
side: DrawerSide::Right,
is_open: inspection.instructions_open,
motion: Some(if inspection.reduce_panel_motion { DrawerMotion::None } else { DrawerMotion::Default }),
on_dismiss: reduce { inspection.instructions_open = false; },
dismiss_semantics_identifier: "inspection.instructions.dismiss".to_string(),
content: SafeArea(child: Scroll(child:
Container(Column(gap: tokens.spacing.m, children: [
Text(cx.tr("inspection.instructions.title"))
.size(tokens.typography.heading2_size),
Text(cx.tr("inspection.instructions.one")),
Text(cx.tr("inspection.instructions.two")),
Text(cx.tr("inspection.instructions.three")),
Button(
child: Text(cx.tr("inspection.close")),
key: "close-instructions",
on_press: reduce { inspection.instructions_open = false; },
).semantics_identifier("inspection.instructions.close"),
])).padding_all(tokens.spacing.l),
)),
),
]))
.padding_all(tokens.spacing.l)
.width_length(Length::percent(100.0))
.max_width(720.0),
)))
.height_length(Length::vh(100.0))
}
{"id":"fission-tabs-1"}
Compare the panel with its reduced-motion switch on and off. Open and dismiss it repeatedly before the transition completes. The underlying filter check must not change, and you should not have to wait for motion before using the controls.
Show the app previewHide the app preview
Show the app preview
Hide the app preview