pub struct SnackBarQueue<T> { /* private fields */ }Expand description
A notification queue — pure, application-side (in the spirit of crate::form::Form).
Only one notification is visible at a time; the others wait. The application calls
tick on every frame (with the elapsed time) to expire the current
notification and present the next — Material-style auto-dismiss with no timer on the
widget side. dismiss closes the current one immediately (a click on
the action or the cross). Generic over the payload T (at minimum the text; often the
kind and the action message too).
Implementations§
Source§impl<T> SnackBarQueue<T>
impl<T> SnackBarQueue<T>
Sourcepub fn push(&mut self, item: T, seconds: f32)
pub fn push(&mut self, item: T, seconds: f32)
Adds a notification that will stay visible seconds seconds once at the front.
Sourcepub fn current(&self) -> Option<&T>
pub fn current(&self) -> Option<&T>
The notification currently visible (the front of the queue), if there is one.
Sourcepub fn tick(&mut self, dt: f32) -> bool
pub fn tick(&mut self, dt: f32) -> bool
Runs dt seconds down on the notification at the front; if its time is up, it is
removed (the next one starts its own countdown). Returns true if the visible
notification changed (an expiry) — useful to request another render.
Sourcepub fn start_leaving(&mut self)
pub fn start_leaving(&mut self)
Marks the current notification as leaving: the host can then play its exit
transition (a fade) before the application removes it (via dismiss).
Sourcepub fn is_leaving(&self) -> bool
pub fn is_leaving(&self) -> bool
Is the current notification leaving? (a disappearing fade is under way.)