pub fn show_native_sheet(spec: SheetSpec) -> Presentation<SheetOutcome> ⓘExpand description
The app-facing native-presentation entry points over crate::present:
for an alert and for a sheet, an awaitable form and an events-as-signals
form — see the present submodule doc.
The app-facing native-presentation entry points over crate::present:
for an alert and for a sheet, an awaitable form and an events-as-signals
form — see the present submodule doc.
The app-facing native-presentation entry points over crate::present:
for an alert and for a sheet, an awaitable form and an events-as-signals
form — see the present submodule doc.
Present a native sheet and await its one outcome.
Resolves Ok(outcome) once the user (an action row, a swipe-down on a
dismissible sheet), SheetHandle::dismiss or the host going away ends
the sheet, or Err: an invalid spec, Busy (any other presentation is
live), no host to present over, or Unsupported — every platform but
iOS/iPadOS today (macOS and Android sheet arms are follow-up work). Take
Presentation::sheet_handle before awaiting to move or dismiss it.
iPad in regular width ignores detents: the system presents a centered
form sheet there; only an edge-attached sheet (iPhone, iPad in compact
width) rests at SheetSpec::detents. Never rely on detent parity.
let spec = SheetSpec::new(
SheetContent::new()
.with_title("Share draft")
.with_message("Pick where it goes.")
.with_action("copy", "Copy link", ActionRole::Default),
)
.with_theme(&theme)
.on_detent(move |detent| expanded.set(detent == Detent::Large));
let presentation = show_native_sheet(spec);
let handle = presentation.sheet_handle();
frust::spawn_local(async move {
if let Ok(SheetOutcome::Action(id)) = presentation.await {
last_action.set(Some(id));
}
});