Skip to main content

euv_ui/component/notification/view/
struct.rs

1use super::*;
2
3/// One card in the [`euv_notification`] stack.
4///
5/// A notification carries a headline and a body line, plus an optional
6/// close button. The component is purely presentational: it renders the
7/// item it is given and reports the clicks, so the caller keeps
8/// ownership of the queue and of any auto-dismiss timing.
9#[derive(Clone, CustomDebug, Default)]
10pub struct EuvNotificationItem {
11    /// The notification headline, rendered in `c_euv_notification_title`.
12    pub title: &'static str,
13    /// The notification body, rendered in `c_euv_notification_text`.
14    pub text: &'static str,
15    /// The callback fired when the close button is clicked.
16    #[debug(skip)]
17    pub on_close: Option<Rc<dyn Fn()>>,
18    /// Whether the notification renders a close button.
19    ///
20    /// Defaults to `false`, but supplying an `on_close` callback implies a
21    /// dismissible notification, so the close button is rendered either way.
22    pub dismissible: bool,
23}
24
25/// Props for the [`euv_notification`] component.
26///
27/// The stack is always mounted, so a caller can push notifications into
28/// it without remounting the component.
29#[derive(Clone, CustomDebug, Default)]
30pub struct EuvNotificationProps {
31    /// The notifications rendered in the stack, top to bottom.
32    pub items: Vec<EuvNotificationItem>,
33}