Skip to main content

CoverBuilder

Trait CoverBuilder 

Source
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

Builder methods of Cover, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.

Required Methods§

Source

fn sheet(self) -> Self

Prefer a native modal sheet. Backends without sheets retain their modal cover.

Source

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.

Source

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.

Source

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, whose from_key accepts anything) it claims every segment: mount one and the next navigate("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".

Implementors§

Source§

impl<R: Route, DecoratedInner: CoverBuilder<R> + Piece> CoverBuilder<R> for Decorated<DecoratedInner>

Source§

impl<S: Binding<Option<R>>, R: Route> CoverBuilder<R> for Cover<S, R>

Day API ↩ Guides· daybrite.dev