Skip to main content

NavigatorView

Struct NavigatorView 

Source
pub struct NavigatorView<State>
where State: 'static,
{ /* private fields */ }
Expand description

A declarative navigator. See the module docs.

Implementations§

Source§

impl<State> NavigatorView<State>
where State: 'static,

Source

pub fn transition(self, spec: TransitionSpec) -> NavigatorView<State>

Set the default page transition applied to every push/replace that does not carry its own push_with/ replace_with override.

Source

pub fn pop_swipe(self, enabled: bool) -> NavigatorView<State>

Explicitly enable or disable the interactive edge-swipe back gesture, outranking both platform_pop_swipe and the preset-derived default (on for PageTransition::IosPush, off otherwise). The gesture pops the top page with a left-edge drag: drag progress reverses the popped page’s transition, and release completes or cancels the pop by progress/velocity. A page may still narrow this further with PushOptions::pop_swipe (the highest-ranked slot) or refuse it outright via a non-Pop BackPolicy (see NavigatorWidget::swipe_armable).

Source

pub fn platform_pop_swipe(self, enabled: bool) -> NavigatorView<State>

Set the platform-derived edge-swipe default — ranked below an explicit pop_swipe override and above the preset-derived fallback. frust-widgets carries no cfg(target_os) of its own; this is the plain setter the facade calls (crates/frust/src/lib.rs) with cfg!(target_os = "ios"), so an app using frust::navigator gets an iOS-on / Android-and-desktop-off default with zero app-side wiring.

Source

pub fn on_root_visibility( self, f: impl Fn(PageVisibility) + 'static, ) -> NavigatorView<State>

Observe the root page’s PageVisibility — the same seam PushOptions::on_visibility gives a pushed page, for the one page that has no PushOptions. Fired once with Current on the navigator’s first build, then on every change (e.g. Covered when an opaque page is pushed over it).

Read PushOptions::on_visibility’s doc for the full contract: no &mut State, no duplicate values, and — importantly — no on_cleanup on cover; the root page stays mounted with its widget state intact.

The callback is captured at the navigator’s first build (like the root page’s builder itself) and is not refreshed on later rebuilds.

Source

pub fn cull_covered_builds(self, enabled: bool) -> NavigatorView<State>

Skip re-running the builder (and the child reconcile) for pages that are Covered.

Default false — the shipped behaviour, where every retained page reconciles every frame whether covered or not. Making covered builds stop is a real behaviour change (an app may rely on a covered page’s builder running against live state), so it is strictly opt-in.

Two ordering rules hold when enabled, and neither needs a wake mechanism:

  • A revealed page rebuilds in the same pass that revealed it. Ops are applied — and a settled transition finalized — before the per-page reconcile loop in NavigatorView::rebuild, so by the time the loop asks visibility_of the revealed page is no longer Covered. There is no cross-frame gap to bridge.
  • The frame on which a page becomes Covered still rebuilds it. The cull decision reads the page’s visibility as of the previous reconcile, so a page gets exactly one final reconcile after its on_visibility(Covered) fires — a page staging teardown UI on cover can still render it.
Source

pub fn root_route(self, location: Location) -> NavigatorView<State>

Stamp the ROOT page’s route identity — see PushOptions::route, the pushed-page equivalent.

Source

pub fn on_route_change( self, f: impl Fn(&RouteStack) + 'static, ) -> NavigatorView<State>

Observe this navigator’s route-state, navigator-wide: fired from NavigatorWidget::publish_state only when the published RouteStack actually changes (an unchanged stack across N rebuilds fires it zero times) — never with &mut State (it fires from a rebuild), exactly like PushOptions::on_visibility’s contract. The facade’s reactive route-observer bridges this into signals (see docs/WIDGETS_ARCHITECTURE.md’s reactive-free note): capture a plain Rc<Cell<_>> here, don’t reach for app state.

Trait Implementations§

Source§

impl<State> View<State> for NavigatorView<State>
where State: 'static,

Source§

type Element = NavigatorWidget<State>

The retained widget this view produces.
Source§

fn build(&self, ctx: &mut BuildCtx<'_>) -> NavigatorWidget<State>

Materialise a fresh widget for this view.
Source§

fn rebuild( &self, _prev: &NavigatorView<State>, element: &mut NavigatorWidget<State>, ctx: &mut BuildCtx<'_>, ) -> ChangeFlags

Reconcile prev (the previous view of the same type) against the live element, mutating it in place and reporting what changed.
Source§

fn teardown(&self, element: &mut NavigatorWidget<State>, ctx: &mut BuildCtx<'_>)

Tear down element when this view is being removed. Read more
Source§

fn message(&self, _element: &mut Self::Element, _state: &mut State)

Deliver an event message to this view, mutating application state. Read more

Auto Trait Implementations§

§

impl<State> !RefUnwindSafe for NavigatorView<State>

§

impl<State> !Send for NavigatorView<State>

§

impl<State> !Sync for NavigatorView<State>

§

impl<State> !UnwindSafe for NavigatorView<State>

§

impl<State> Freeze for NavigatorView<State>
where NavigatorController<State>: Freeze, Rc<dyn Fn() -> AnyView<State>>: Freeze,

§

impl<State> Unpin for NavigatorView<State>
where NavigatorController<State>: Unpin, Rc<dyn Fn() -> AnyView<State>>: Unpin,

§

impl<State> UnsafeUnpin for NavigatorView<State>
where NavigatorController<State>: UnsafeUnpin, Rc<dyn Fn() -> AnyView<State>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more