pub struct Toast<Msg> { /* private fields */ }Expand description
A notification: a status marker and icon, a title, an optional body and action, and the shared three-cell close mark at the end of the title row.
A title too long for its row wraps, the lines after the first running under the action and the close mark to the right edge, so a narrow screen or a longer language never cuts it. The action and the mark stay on the first row.
Only a press on the close mark dismisses a toast; a press on the rest of it does nothing unless
on_press gives it a message, e.g. to open where the news came from.
Style keys: toast (bg, padding) with hover while the pointer is on a pressable toast,
toast-title, toast-body, toast-action with active on a raised toast and hover, and
close-mark (see tabs). The marker and icon use the success, warning,
danger and info colours; an animated icon uses spinner with the kind as its variant.
Implementations§
Source§impl<Msg> Toast<Msg>
impl<Msg> Toast<Msg>
Sourcepub fn body(self, body: impl Into<String>) -> Self
pub fn body(self, body: impl Into<String>) -> Self
A faint line of detail under the title, wrapped to the toast width.
Sourcepub fn action(self, label: impl Into<String>, message: Msg) -> Self
pub fn action(self, label: impl Into<String>, message: Msg) -> Self
A button on the title row; clicking it sends message and dismisses the toast.
Sourcepub fn duration(self, duration: Duration) -> Self
pub fn duration(self, duration: Duration) -> Self
How long the toast stays while the pointer is not on it. Default: 5 s, or 8 s with an action.
Sourcepub fn key(self, key: impl Into<String>) -> Self
pub fn key(self, key: impl Into<String>) -> Self
Names the toast: showing another toast with the same key replaces it, and
Command::dismiss_toast removes it.
Sourcepub fn icon_motion(self, animation: impl Into<AnimationName>) -> Self
pub fn icon_motion(self, animation: impl Into<AnimationName>) -> Self
Plays a one-cell Spinner animation in the icon cell instead of the kind’s icon, in
the kind’s colour, e.g. SpinnerStyle::Pulse while something
is still running. It takes a spinner style or the name of any
cell animation, such as one a theme defines. With reduced motion the
kind’s icon stands still instead. Replace the toast through its key with one
without animation when the work is done.
use qframe::prelude::*;
use qframe::widgets::{SpinnerStyle, Toast};
let running: Toast<()> = Toast::info("Deploying api-gateway").icon_motion(SpinnerStyle::Pulse).key("deploy");
let done: Toast<()> = Toast::success("Deployed api-gateway").key("deploy");
let _ = Command::batch([Command::toast(running), Command::toast(done)]);Source§impl<Msg: Clone + 'static> Toast<Msg>
impl<Msg: Clone + 'static> Toast<Msg>
Sourcepub fn on_press(self, message: Msg) -> Self
pub fn on_press(self, message: Msg) -> Self
Makes the toast pressable: a press anywhere on it but its action and close mark sends
message, e.g. to open the log or the page the news came from. The toast stays; only the
close mark dismisses it. While the pointer is on it the toast rises one tone.
use qframe::prelude::*;
use qframe::widgets::Toast;
#[derive(Clone)]
enum Msg {
OpenDeployLog,
}
let toast: Toast<Msg> = Toast::success("Deployed api-gateway").on_press(Msg::OpenDeployLog);
let _ = Command::toast(toast);Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Toast<Msg>
impl<Msg> !Send for Toast<Msg>
impl<Msg> !Sync for Toast<Msg>
impl<Msg> !UnwindSafe for Toast<Msg>
impl<Msg> Freeze for Toast<Msg>
impl<Msg> Unpin for Toast<Msg>
impl<Msg> UnsafeUnpin for Toast<Msg>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more