pub struct Notice<M> { /* private fields */ }Expand description
A notification to show on screen, from Widget::notices.
It says what the notification is, not how it looks: the host lays out the notification, places it and
animates it in and out. Its key is how the host tells notices apart from one view to the
next: a notice that keeps its key and changes its text is updated in place, and one whose key
is gone from the list leaves the screen.
Implementations§
Source§impl<M> Notice<M>
impl<M> Notice<M>
pub fn new(key: u64, summary: impl Into<String>) -> Self
Sourcepub fn app_icon(self, app_id: impl Into<String>) -> Self
pub fn app_icon(self, app_id: impl Into<String>) -> Self
The app’s icon, by app id, like app_icon, or a file:// URL to a picture of it.
Sourcepub fn icon(self, icon: Icon) -> Self
pub fn icon(self, icon: Icon) -> Self
A symbol as its icon, drawn in the text’s tone, for what’s about the device rather than
an app: a battery running low, a network that dropped. It wins over
app_icon.
Sourcepub fn image(self, url: impl Into<String>) -> Self
pub fn image(self, url: impl Into<String>) -> Self
A picture of its own, by URL, like a cover: an avatar, a screenshot. The host shows it
beside the text, or under it, full width, if it’s wide.
Sourcepub fn pixels(self, pixels: Pixels) -> Self
pub fn pixels(self, pixels: Pixels) -> Self
A picture of its own, as its pixels: what an app sent as bytes rather than a file. It wins
over image.
Sourcepub fn time(self, time: SystemTime) -> Self
pub fn time(self, time: SystemTime) -> Self
When it arrived. The host says how long ago, beside where it’s from.
Sourcepub fn thread(self, key: impl Into<String>) -> Self
pub fn thread(self, key: impl Into<String>) -> Self
The conversation it’s part of: a chat, a session. The host stacks notices of the same app and thread that come one after another into one, the newest in full.
Sourcepub fn thread_name(self, name: impl Into<String>) -> Self
pub fn thread_name(self, name: impl Into<String>) -> Self
What to call its thread, beside the app’s name: the chat, the session.
Sourcepub fn progress(self, fraction: f32) -> Self
pub fn progress(self, fraction: f32) -> Self
How far along what it’s about is, from 0.0 to 1.0: a download, a copy.
Sourcepub fn choices(self, choices: Choices<M>) -> Self
pub fn choices(self, choices: Choices<M>) -> Self
Options to pick from (Choices), above the reply field and the actions.
Sourcepub fn step(self, index: usize, count: usize, on_back: Option<M>) -> Self
pub fn step(self, index: usize, count: usize, on_back: Option<M>) -> Self
It’s question index (from 0) of count, asked one at a time on the same notice. The host
shows where it is, and slides the content along when index changes. on_back goes to
the one before.
Sourcepub fn body(self, text: impl Into<String>) -> Self
pub fn body(self, text: impl Into<String>) -> Self
Plain text under the summary. The host wraps it and cuts it off after a few lines.
pub fn urgency(self, urgency: Urgency) -> Self
Sourcepub fn action(self, label: impl Into<String>, message: M) -> Self
pub fn action(self, label: impl Into<String>, message: M) -> Self
A button on the notification that sends message. The first one is the main action.
Sourcepub fn on_press(self, message: M) -> Self
pub fn on_press(self, message: M) -> Self
Sent on a click on the notification itself, outside its buttons.
Sourcepub fn on_dismiss(self, message: M) -> Self
pub fn on_dismiss(self, message: M) -> Self
Sent when its close button is clicked. Without it, it has none.
Sourcepub fn expires(self, after: Duration, message: M) -> Self
pub fn expires(self, after: Duration, message: M) -> Self
Sent once it has been on screen for after. The host doesn’t count while the pointer is
on it or it’s waiting to be shown. Without it, it stays
until it leaves the list.