Skip to main content

euv_ui/component/message/view/
struct.rs

1use super::*;
2
3/// One toast in the [`euv_message`] stack.
4///
5/// A message is a short line of text with an optional action and an
6/// optional close button. The component is purely presentational: it
7/// renders the item it is given and reports the clicks, so the caller
8/// keeps ownership of the queue and of any auto-dismiss timing.
9#[derive(Clone, CustomDebug, Default)]
10pub struct EuvMessageItem {
11    /// The message body, rendered in `c_euv_message_text`.
12    pub text: &'static str,
13    /// The label of the optional action button.
14    ///
15    /// An empty label renders no action button at all.
16    pub action_label: &'static str,
17    /// The callback fired when the action button is clicked.
18    #[debug(skip)]
19    pub on_action: Option<Rc<dyn Fn()>>,
20    /// The callback fired when the close button is clicked.
21    #[debug(skip)]
22    pub on_close: Option<Rc<dyn Fn()>>,
23    /// Whether the message renders a close button.
24    ///
25    /// Defaults to `false`, but supplying an `on_close` callback implies a
26    /// dismissible message, so the close button is rendered either way.
27    pub dismissible: bool,
28}
29
30/// Props for the [`euv_message`] component.
31///
32/// The stack is always mounted, so a caller can push messages into it
33/// without remounting the component.
34#[derive(Clone, CustomDebug, Default)]
35pub struct EuvMessageProps {
36    /// The messages rendered in the stack, top to bottom.
37    pub items: Vec<EuvMessageItem>,
38}