Struct ToastCard
pub struct ToastCard<'a> {Show 26 fields
pub title: &'a str,
pub body: &'a str,
pub caption: &'a str,
pub time: &'a str,
pub reply: bool,
pub reply_text: &'a str,
pub reply_focused: bool,
pub reply_hovered: bool,
pub kind: ToastKind,
pub icon: Option<Icon>,
pub person: Option<(&'a str, &'a str)>,
pub app_image: Option<&'a AppImage>,
pub alpha: f32,
pub closable: bool,
pub close_hovered: bool,
pub close_pressed: bool,
pub actionable: bool,
pub secondary_action: &'a str,
pub secondary_action_icon: Option<Icon>,
pub secondary_action_hovered: bool,
pub secondary_action_pressed: bool,
pub primary_action: &'a str,
pub primary_action_icon: Option<Icon>,
pub primary_action_hovered: bool,
pub primary_action_pressed: bool,
pub progress: Option<f32>,
}Expand description
Immediate-mode content for one notification / toast card, painted by
paint_card. Built fluently:
ToastCard::new("Slow network", ToastKind::Warning).body("retrying").
Fields§
§title: &'a strPrimary line — the summary. Semibold, text_primary.
body: &'a strOptional secondary line (dim). Empty = single-line card.
caption: &'a strOptional attribution caption above the title (e.g. the sending app’s
name), a dim Caption in sentence case. Empty = no caption.
time: &'a strHow long ago it arrived (“2 m ago”), on the attribution line at the
trailing edge, a dim Caption level with the caption. Empty = no
time.
reply: boolOffer an inline reply field under the text (the sender takes one,
inline-reply).
reply_text: &'a strWhat the person typed so far in the reply field.
reply_focused: boolWhether the reply field has the keyboard.
reply_hovered: boolHover state for the reply field.
kind: ToastKindSeverity — drives the leading icon and its colour.
icon: Option<Icon>What plain information leads with instead of a severity glyph, which only warnings, errors and successes carry: a glyph naming what the card is about…
person: Option<(&'a str, &'a str)>The person the card is from, as (name, identity): their avatar
leads the card, in their presence colour, ahead of any glyph. Plain
information with neither a person nor an icon leads with its text.
app_image: Option<&'a AppImage>The sending application’s own artwork, where a glyph cannot name it. A person’s avatar leads ahead of it; a severity glyph wins over it, so an alert never loses its state colour.
alpha: f32Enter/exit animation opacity in [0, 1]; 1.0 for a settled card.
closable: boolDraw a dismiss (X) button at the top-right and hand its rect back
via ToastCardHit so the caller keeps one hit-test on widget-owned
geometry.
close_hovered: boolHover state for the dismiss button, when the caller tracks the cursor.
close_pressed: boolWhether the shared pointer controller has armed this control.
actionable: boolDraw an “actionable” chevron at the trailing edge (the card carries activatable actions).
secondary_action: &'a strOptional left/secondary and right/primary actions. These use the same
immediate-mode Button painter as ordinary retained controls, so a
notification can ask for a decision without inventing a second button
language. Empty labels omit the action row entirely.
secondary_action_icon: Option<Icon>§secondary_action_hovered: bool§secondary_action_pressed: boolWhether the shared pointer controller has armed this control.
primary_action: &'a str§primary_action_icon: Option<Icon>§primary_action_hovered: bool§primary_action_pressed: boolWhether the shared pointer controller has armed this control.
progress: Option<f32>How far the work the card follows is, 0..=1: a determinate bar
under the text. None draws none.
Implementations§
§impl<'a> ToastCard<'a>
impl<'a> ToastCard<'a>
pub fn new(title: &'a str, kind: ToastKind) -> ToastCard<'a>
pub fn body(self, body: &'a str) -> ToastCard<'a>
pub fn progress(self, progress: f32) -> ToastCard<'a>
pub fn progress(self, progress: f32) -> ToastCard<'a>
Follow work progress (0..=1) done with a determinate bar.
pub fn icon(self, icon: Option<Icon>) -> ToastCard<'a>
pub fn icon(self, icon: Option<Icon>) -> ToastCard<'a>
Lead plain information with icon (see Self::icon).
pub fn person(self, name: &'a str, identity: &'a str) -> ToastCard<'a>
pub fn person(self, name: &'a str, identity: &'a str) -> ToastCard<'a>
Lead the card with the avatar of the person it is from.
pub fn app_image(self, image: Option<&'a AppImage>) -> ToastCard<'a>
pub fn app_image(self, image: Option<&'a AppImage>) -> ToastCard<'a>
Lead plain information with the sending application’s artwork.
pub fn caption(self, caption: &'a str) -> ToastCard<'a>
pub fn time(self, time: &'a str) -> ToastCard<'a>
pub fn time(self, time: &'a str) -> ToastCard<'a>
How long ago it arrived, at the attribution line’s trailing edge.
pub fn reply(self, text: &'a str, focused: bool) -> ToastCard<'a>
pub fn reply(self, text: &'a str, focused: bool) -> ToastCard<'a>
Offer an inline reply field under the text, holding text so far.
pub fn alpha(self, alpha: f32) -> ToastCard<'a>
pub fn closable(self, v: bool) -> ToastCard<'a>
pub fn close_hovered(self, v: bool) -> ToastCard<'a>
pub fn actionable(self, v: bool) -> ToastCard<'a>
pub fn action(self, label: &'a str, hovered: bool) -> ToastCard<'a>
pub fn action(self, label: &'a str, hovered: bool) -> ToastCard<'a>
One action, at the card’s trailing edge beside its text (“Undo”, “Open”).
pub fn actions(
self,
secondary: &'a str,
secondary_icon: Icon,
secondary_hovered: bool,
primary: &'a str,
primary_icon: Icon,
primary_hovered: bool,
) -> ToastCard<'a>
pub fn actions( self, secondary: &'a str, secondary_icon: Icon, secondary_hovered: bool, primary: &'a str, primary_icon: Icon, primary_hovered: bool, ) -> ToastCard<'a>
Add a standard two-choice action row. The secondary action is painted neutral on the left; the primary action is painted with the theme’s primary face on the right.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ToastCard<'a>
impl<'a> !RefUnwindSafe for ToastCard<'a>
impl<'a> Send for ToastCard<'a>
impl<'a> Sync for ToastCard<'a>
impl<'a> Unpin for ToastCard<'a>
impl<'a> UnsafeUnpin for ToastCard<'a>
impl<'a> !UnwindSafe for ToastCard<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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