notification-center
Builds DescriptionList List NotificationCenter Timeline


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn notification_center(_window: &mut Window, cx: &mut App) -> AnyElement {
if !cx.has_global::<SceneNotifications>() {
let centre = cx.new(|cx| NotificationCenter::new("scene.notifications", cx));
centre.update(cx, |centre, cx| {
centre.record(
Notification::new("scene.notify.exported", "Theme exported to disk")
.tone(Tone::Success)
.at("9:41")
.read(true),
cx,
);
centre.record(
Notification::new("scene.notify.stale", "Refreshing the model catalog failed")
.tone(Tone::Warning)
.detail("The last verified catalog is still shown.")
.at("9:44"),
cx,
);
centre.record(
Notification::new(
"scene.notify.refused",
"The host refused to publish this run",
)
.tone(Tone::Warning)
.detail("Approval is required for this workspace.")
.at("9:46")
.action("Request approval", |_, _| {}),
cx,
);
});
cx.set_global(SceneNotifications { centre });
}
let centre = cx.global::<SceneNotifications>().centre.clone();
let theme = cx.theme().clone();
stack(&theme)
.w(px(520.0))
// The same three reports the toast scene shows, after their toasts
// have gone.
.child(caption(
&theme,
"what the toasts said, still here once they timed out",
))
.child(centre)
.into_any_element()
}