polyhorn_ui/components/
modal.rs

1use crate::events::EventListener;
2
3/// Renders its children in a system-provided modal window.
4#[derive(Clone)]
5pub struct Modal {
6    /// Controls the visibility of this modal. Changing this value will animate
7    /// the visibility of the modal window with a system-provided transition.
8    /// Note that is preferred over unmounting the modal entirely, at least
9    /// until the `on_dismiss` event is emitted, because the modal will not be
10    /// able to animate its dismissal while unmounting already.
11    pub visible: bool,
12
13    /// Event listener that is invoked after the modal is dismissed (and its
14    /// animation has completed). This event will be emitted even when the
15    /// modal's visibility is programmatically and directly changed through the
16    /// `visible` property.
17    pub on_dismiss: EventListener<()>,
18}
19
20impl Default for Modal {
21    fn default() -> Self {
22        Modal {
23            visible: true,
24            on_dismiss: Default::default(),
25        }
26    }
27}