pub trait CoverBuilder<R: Route>: Sized {
// Required methods
fn sheet(self) -> Self;
fn half_sheet(self) -> Self;
fn background(self, f: impl Fn(&R) -> Color + 'static) -> Self;
fn unrouted(self) -> Self;
}Expand description
Required Methods§
Sourcefn sheet(self) -> Self
fn sheet(self) -> Self
Prefer a native modal sheet. Backends without sheets retain their modal cover.
Sourcefn half_sheet(self) -> Self
fn half_sheet(self) -> Self
Present as a half-height sheet rising from the bottom edge, the window content above
it staying on show: an inspector over the canvas it describes, a transport over the
media it controls (docs/cover.md “Half sheet”). iOS presents a medium-detent sheet that
leaves the content interactive, Android a Material bottom sheet, the web, HarmonyOS and
the emulated desktop tiers a bottom-anchored half panel, and macOS its window sheet at
half the window’s height. Implies Cover::sheet.
Sourcefn background(self, f: impl Fn(&R) -> Color + 'static) -> Self
fn background(self, f: impl Fn(&R) -> Color + 'static) -> Self
The surface color painted edge-to-edge behind the content (under the status bar and
home indicator) while r is presented. Without it the platform’s default surface
color shows in the unsafe areas.
Sourcefn unrouted(self) -> Self
fn unrouted(self) -> Self
Keep this cover out of the app’s route space: navigate("<key>") never presents it, it
contributes nothing to current_route(), and nav_back() walks past it.
For a cover that is a control’s own panel rather than an app destination (a color picker’s chooser, a media scrubber’s fullscreen mode), presented and dismissed by the control, never linked to. Two reasons that matters:
- A routed cover claims route segments, and over the untyped
Route(String, whosefrom_keyaccepts anything) it claims every segment: mount one and the nextnavigate("settings")presents the cover with the key"settings"instead of going to settings. A piece that mounts a cover would be silently rewriting its host app’s navigation. - It is not a place.
current_route()naming a transient chooser makes a restored session reopen it, and a “share this screen” link point at a modal.
Interactive dismissal is unaffected: the cover still answers Android’s system back through
Event::NavBack on its own node, which never went through the
route adapter.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".