pub struct DialogView<State: 'static> { /* private fields */ }Expand description
A declarative basic M3 dialog: a centered panel over the host’s scrim. See the module docs.
Implementations§
Source§impl<State: 'static> DialogView<State>
impl<State: 'static> DialogView<State>
Sourcepub fn title(self, title: impl Into<String>) -> Self
pub fn title(self, title: impl Into<String>) -> Self
Set the dialog title (headlineSmallEmphasized, onSurface).
Sourcepub fn body(self, body: impl Into<String>) -> Self
pub fn body(self, body: impl Into<String>) -> Self
Set the dialog supporting text (bodyMedium, onSurfaceVariant).
Sourcepub fn actions<M>(self, actions: impl ViewSeq<State, M>) -> Self
pub fn actions<M>(self, actions: impl ViewSeq<State, M>) -> Self
Replace the trailing action row with actions (app-provided buttons,
in reading order — the last one sits closest to the trailing edge).
Sourcepub fn action(self, action: impl View<State>) -> Self
pub fn action(self, action: impl View<State>) -> Self
Append one action button to the trailing action row.
Sourcepub fn dismissable(self, dismissable: bool) -> Self
pub fn dismissable(self, dismissable: bool) -> Self
Whether the user can dismiss this dialog at all — the scrim tap,
Escape, and an Android back press (default true; see
crate::overlay::modal::OverlayModalView::dismissable). false
disables all three; only an app-provided action still dismisses it.
Sourcepub fn on_dismiss<F: Fn(&mut State) + 'static>(self, on_dismiss: F) -> Self
pub fn on_dismiss<F: Fn(&mut State) + 'static>(self, on_dismiss: F) -> Self
Observe a scrim-tap/Escape/back dismissal. show_dialog already
wires the pop for you (via OverlayModalContent::on_modal_dismiss);
this is for a caller that wants to react to it too (or that mounts a
DialogView directly in a Stack, with no navigator involved).
Sourcepub fn dismiss_handle(self, dismiss: ModalDismiss) -> Self
pub fn dismiss_handle(self, dismiss: ModalDismiss) -> Self
Install the app-triggered staged-dismiss handle, so a Cancel/Confirm
action closes the dialog through the same exit ramp the scrim tap,
Escape, and a back press take — rather than a raw
controller.pop(), which dismisses on the spot with no ramp. See
ModalDismiss; mint the handle outside show_dialog’s page
builder.
Trait Implementations§
Source§impl<State: 'static> OverlayModalContent<State> for DialogView<State>
impl<State: 'static> OverlayModalContent<State> for DialogView<State>
Source§fn on_modal_dismiss(self, on_dismiss: Rc<dyn Fn(&mut State)>) -> Self
fn on_modal_dismiss(self, on_dismiss: Rc<dyn Fn(&mut State)>) -> Self
Source§fn modal_dismissable(&self) -> bool
fn modal_dismissable(&self) -> bool
BackPolicy.Source§impl<State: 'static> View<State> for DialogView<State>
impl<State: 'static> View<State> for DialogView<State>
Source§type Element = OverlayModalWidget
type Element = OverlayModalWidget
Source§fn build(&self, ctx: &mut BuildCtx<'_>) -> OverlayModalWidget
fn build(&self, ctx: &mut BuildCtx<'_>) -> OverlayModalWidget
Source§fn rebuild(
&self,
prev: &Self,
element: &mut OverlayModalWidget,
ctx: &mut BuildCtx<'_>,
) -> ChangeFlags
fn rebuild( &self, prev: &Self, element: &mut OverlayModalWidget, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags
prev (the previous view of the same type) against the live
element, mutating it in place and reporting what changed.Auto Trait Implementations§
impl<State> !RefUnwindSafe for DialogView<State>
impl<State> !Send for DialogView<State>
impl<State> !Sync for DialogView<State>
impl<State> !UnwindSafe for DialogView<State>
impl<State> Freeze for DialogView<State>
impl<State> Unpin for DialogView<State>
impl<State> UnsafeUnpin for DialogView<State>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
impl<State, V> ViewSeq<State, One> for Vwhere
State: 'static,
V: View<State>,
Source§fn extend_views(self, out: &mut Vec<AnyView<State>>)
fn extend_views(self, out: &mut Vec<AnyView<State>>)
out — erasing each
with AnyView::new (a no-op for an element already an AnyView).