Skip to main content

modal

Function modal 

Source
pub fn modal(
    id: impl Into<ElementId>,
    viewport: Size<Pixels>,
    card: AnyElement,
    on_dismiss: impl Fn(&MouseDownEvent, &mut Window, &mut App) + 'static,
) -> AnyElement
Expand description

Full-window modal: dim scrim + centered card with the dialog-in entrance. The scrim swallows clicks; the caller wires its own dismiss/confirm. viewport is the window size (an anchored layer sizes to its children, so the scrim needs explicit dimensions). The frost radius matches dialog_card’s 16px rounding. on_dismiss is the scrim press. It is a parameter rather than the caller’s .on_mouse_down_out, for the same reason sheet’s is: the scrim lives inside this deferred layer, so nothing outside can reach it. Without it a dialog could not be dismissed by clicking away from it by any caller — which is how this one shipped, and what it looked like was a dialog that only closed on its own buttons.