Skip to main content

NavStack

Struct NavStack 

Source
pub struct NavStack<S: Binding<Vec<K>>, K: Route = String> { /* private fields */ }
Expand description

A push/pop navigation stack whose contents are an app-owned Signal<Vec<K>> (the path above the root). Day reconciles the native stack to the path; the native back button writes the pop back into it (docs/navigation.md).

The key type is any Route: String for raw keys, or a typed enum whose variants can carry data; the destination builder then receives the typed value, and an absolute navigate("…/item-42") parses each segment via Route::from_key (rejecting segments that don’t parse; String accepts everything).

ⓘ
let path = Signal::new(Vec::<Drill>::new());
nav_stack(path.clone(), home_view).destination(|d: &Drill| detail_view(d))
// push:  path.update(|p| p.push(Drill::Item { id: 42 }));

Implementations§

Source§

impl<K: Route, S: Binding<Vec<K>>> NavStack<S, K>

Source

pub fn title<M>(self, t: impl IntoText<M>) -> Self

Source

pub fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Self

Declare toolbar items on this stack’s root page chrome (docs/toolbars.md): the commands that act on what the root shows, and that have nothing to act on once a pushed page covers it. A pushed page declares its own with the same method on the piece it builds.

Takes one item, a list of them, or a closure that derives the list.

Source

pub fn destination<P: Piece>(self, build: impl Fn(&K) -> P + 'static) -> Self

Build the view for a pushed key (&String for raw keys, the typed value otherwise).

Source

pub fn immersive(self, page: impl Fn(Option<&K>) -> bool + 'static) -> Self

Choose pages whose content extends behind the top system and navigation bars. The predicate receives None for the root and Some(key) for a destination, once when that page is created. UIKit keeps native navigation controls over the content; Android requires [android] edge-to-edge = true in Day.toml. Other toolkits ignore this presentation hint. Keep text and controls below the overlaid chrome. A merged stack’s root inherits its enclosing page’s presentation.

Source

pub fn on_back( self, guard: impl Fn(BackRequest) -> BackResponse + 'static, ) -> Self

Intercept the back affordance (docs/navigation.md). The guard runs for every native back gesture/button and nav_back while the stack is above its root; it returns BackResponse::Proceed to pop now or BackResponse::Handled to consume the back (stash the BackRequest and call BackRequest::proceed later). Programmatic path writes are never guarded. While a guard is armed the toolkit stops auto-popping on a native gesture and routes the back through Day instead (NavPatch::GuardTop).

Source

pub fn restore(self, key: impl Into<String>) -> Self

Remember the pushed path across launches (docs/navigation.md). On every change the path’s keys are /-joined and saved under key; at build the saved path is parsed back (each segment via Route::from_key) and restored, so the app reopens exactly where the user left off, including after an Android process death, unless a launch deep link is pending, which wins. day::launch installs the preferences as the store (docs/navigation.md); a saved path with a segment that no longer parses is ignored whole.

Trait Implementations§

Source§

impl<K: Route, S: Binding<Vec<K>>> NavStackBuilder<K> for NavStack<S, K>

Source§

fn title<M>(self, t: impl IntoText<M>) -> Self

Source§

fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Self

Declare toolbar items on this stack’s root page chrome (docs/toolbars.md): the commands that act on what the root shows, and that have nothing to act on once a pushed page covers it. A pushed page declares its own with the same method on the piece it builds. Read more
Source§

fn destination<P: Piece>(self, build: impl Fn(&K) -> P + 'static) -> Self

Build the view for a pushed key (&String for raw keys, the typed value otherwise).
Source§

fn immersive(self, page: impl Fn(Option<&K>) -> bool + 'static) -> Self

Choose pages whose content extends behind the top system and navigation bars. The predicate receives None for the root and Some(key) for a destination, once when that page is created. UIKit keeps native navigation controls over the content; Android requires [android] edge-to-edge = true in Day.toml. Other toolkits ignore this presentation hint. Keep text and controls below the overlaid chrome. A merged stack’s root inherits its enclosing page’s presentation.
Source§

fn on_back(self, guard: impl Fn(BackRequest) -> BackResponse + 'static) -> Self

Intercept the back affordance (docs/navigation.md). The guard runs for every native back gesture/button and nav_back while the stack is above its root; it returns BackResponse::Proceed to pop now or BackResponse::Handled to consume the back (stash the BackRequest and call BackRequest::proceed later). Programmatic path writes are never guarded. While a guard is armed the toolkit stops auto-popping on a native gesture and routes the back through Day instead (NavPatch::GuardTop).
Source§

fn restore(self, key: impl Into<String>) -> Self

Remember the pushed path across launches (docs/navigation.md). On every change the path’s keys are /-joined and saved under key; at build the saved path is parsed back (each segment via Route::from_key) and restored, so the app reopens exactly where the user left off, including after an Android process death, unless a launch deep link is pending, which wins. day::launch installs the preferences as the store (docs/navigation.md); a saved path with a segment that no longer parses is ignored whole.
Source§

impl<K: Route, S: Binding<Vec<K>>> Piece for NavStack<S, K>

Source§

fn build(self, cx: &mut BuildCx) -> RNode

Auto Trait Implementations§

§

impl<S, K = String> !RefUnwindSafe for NavStack<S, K>

§

impl<S, K = String> !Send for NavStack<S, K>

§

impl<S, K = String> !Sync for NavStack<S, K>

§

impl<S, K = String> !UnwindSafe for NavStack<S, K>

§

impl<S, K> Forget for NavStack<S, K>

§

impl<S, K> Freeze for NavStack<S, K>
where S: Freeze, Rc<dyn Fn(&K) -> AnyPiece>: Freeze, Rc<dyn Fn(Option<&K>) -> bool>: Freeze,

§

impl<S, K> Move for NavStack<S, K>

§

impl<S, K> Unpin for NavStack<S, K>
where S: Unpin, Rc<dyn Fn(&K) -> AnyPiece>: Unpin, Rc<dyn Fn(Option<&K>) -> bool>: Unpin,

§

impl<S, K> UnsafeUnpin for NavStack<S, K>
where S: UnsafeUnpin, Rc<dyn Fn(&K) -> AnyPiece>: UnsafeUnpin, Rc<dyn Fn(Option<&K>) -> bool>: 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<P> Decorate for P
where P: Piece,

Source§

fn id(self, id: ElementId) -> Decorated<Self>

Stable element identifier: a11y identifier + dayscript locator + lint uniqueness (§5.5). Read more
Source§

fn wrapper_id(self, id: ElementId) -> Decorated<Self>

Name the node that is outermost at this point in the chain: the padding box, the frame, the background, whichever wrapper the modifiers before it built. For a dayscript frame assertion on the wrapper rather than on the piece. Ordered, unlike id.
Source§

fn apply_if( self, cond: bool, f: impl FnOnce(Decorated<Self>) -> Decorated<Self>, ) -> Decorated<Self>

Apply f to the chain when cond holds, else continue unchanged (see Decorated::apply_if): nav(sel).apply_if(!primary, |n| n.local()). The closure receives the decorated piece, so forwarded builder methods and modifiers both chain inside it.
Source§

fn apply_some<T>( self, value: Option<T>, f: impl FnOnce(Decorated<Self>, T) -> Decorated<Self>, ) -> Decorated<Self>

Apply f with the value when there is one, else continue unchanged (see Decorated::apply_some): canvas(draw).apply_some(id, |c, id| c.id(id)).
Source§

fn id_of(self, id: impl Fn() -> ElementId + 'static) -> Decorated<Self>

Reactive element id: the id for rows inside a recycling list. A plain id is assigned once at build, but a recycled cell rebinds to different items over its life (and drag-to-reorder rebinds eagerly), so a static item-derived id keeps naming the first-bound item. This variant re-registers whenever the closure’s value changes; read your ItemSlot inside it: .id_of(move || day_core::id!(row_remove, slot.key())).
Source§

fn tweak(self, f: impl FnOnce(RNode) + 'static) -> Decorated<Self>

Apply a tweak: f runs once at mount, after the native widget exists, with the realized node (docs/tweaks.md). Reach the typed native handle through the compiled backend’s ext accessor (day_toolkit_appkit::with_native, day_toolkit_gtk::with_native, …), or apply a packaged day-tweak-* crate’s modifier instead of calling this directly. If the native change affects the widget’s intrinsic size, follow it with day_core::invalidate_size. Day may overwrite managed properties (title, value, enabled, frame, a11y) on its next patch; unmanaged properties are stable. Read more
Source§

fn selectable(self) -> Decorated<Self>

Make this piece’s text user-selectable, so the reader can select and copy it (docs/text.md). Most useful on a label: text is not selectable by default on any backend, matching each platform’s native behavior. Read more
Source§

fn cursor<M>(self, cursor: impl IntoReactive<Cursor, M>) -> Decorated<Self>

Shape the pointer while it is over this piece and its descendants (docs/cursor.md): a Cursor constant, a Signal<Cursor>, or a closure, so a canvas tool or a busy state moves the shape without rebuilding the piece. The nearest ancestor’s cursor wins, and Cursor::Default releases the piece back to the platform. capability(Cap::Cursor) says whether this toolkit draws the requested shapes, a nearest neighbor, or nothing; a touch-only host never shows one, which is correct rather than a failure.
Source§

fn layout_direction<M>( self, direction: impl IntoReactive<LayoutDirection, M>, ) -> Decorated<Self>

Lay this piece and everything inside it out in one reading direction, whatever the app’s is (docs/localization.md “Direction of a subtree”): LayoutDirection::Ltr for a phone number, a code sample or a media transport inside a right-to-left app, LayoutDirection::Rtl for a preview of Arabic content inside a left-to-right one. Read more
Source§

fn window_drag_region(self) -> Decorated<Self>

Let the user move the window by dragging this piece, as a title bar does (docs/window-chrome.md): what a custom title bar in a WindowChrome::Overlay or WindowChrome::Frameless window needs. The piece’s own background starts the drag, with the platform’s snapping and tiling; buttons and fields inside it keep their clicks; a double click does what the user’s title-bar setting says (zoom, minimize, nothing). capability(Cap::DragRegion); on a phone the piece is an ordinary view.
Source§

fn native_ref(self, r: &NativeRef) -> Decorated<Self>

Capture a NativeRef to this piece’s realized node for later imperative access (docs/tweaks.md). The ref clears automatically when the piece’s scope is disposed.
Source§

fn padding<M>(self, insets: impl IntoReactive<Insets, M>) -> Decorated<Self>

Space between the piece and its frame: points on all four sides, a Space step, an Insets, or a signal or closure of any of them. A reactive inset re-pads in place, so .padding(move || day::safe_area()) follows a rotation or a title bar that grows (docs/window-chrome.md “Safe area”).
Source§

fn max_width<M>(self, max: impl IntoReactive<f64, M>) -> Decorated<Self>

Cap this piece’s width at max points: the child is never PROPOSED more, so text wraps inside the cap (chat bubbles, readable columns) while narrower content hugs. Takes points, a Space step, a signal or a closure; a change re-lays the piece out without rebuilding it.
Source§

fn max_height<M>(self, max: impl IntoReactive<f64, M>) -> Decorated<Self>

Cap this piece’s height at max points, the vertical twin of Decorate::max_width: a scroll or another piece that takes the height it is offered stops at max, and still gets less where its parent has less to give. Reactive like Decorate::max_width.
Source§

fn min_width<M>(self, min: impl IntoReactive<f64, M>) -> Decorated<Self>

Never narrower than min points: a stretching control keeps a usable width, and a row that cannot give it that overflows, so a labeled row stacks the control under its label rather than squeezing it (docs/forms.md). Reactive like Decorate::max_width.
Source§

fn min_height<M>(self, min: impl IntoReactive<f64, M>) -> Decorated<Self>

Keep at least min points of height, expanding for taller content. Reactive like Decorate::max_width.
Source§

fn reserving<M>(self, sample: impl IntoText<M>) -> Decorated<Self>

Reserve at least the space sample needs, so this piece’s size stops changing with its content. Read more
Source§

fn frame<Mw, Mh>( self, width: impl IntoReactive<f64, Mw>, height: impl IntoReactive<f64, Mh>, ) -> Decorated<Self>

Source§

fn width<M>(self, width: impl IntoReactive<f64, M>) -> Decorated<Self>

Fix this piece’s width to width points while its height stays flexible (hugging its content or filling on the cross axis). The single-axis complement to Self::frame, e.g. a fixed-width sidebar pane in a row whose height fills the window.
Source§

fn height<M>(self, height: impl IntoReactive<f64, M>) -> Decorated<Self>

Fix this piece’s height to height points while its width stays flexible. The single-axis complement to Self::frame, e.g. a fixed-height header/toolbar bar that fills its width.
Source§

fn a11y( self, f: impl FnOnce(A11yBuilder) -> A11yBuilder + 'static, ) -> Decorated<Self>

Source§

fn on_tap(self, f: impl Fn() + 'static) -> Decorated<Self>

Fire when this piece is tapped (bounding-box; shapes override with path-precise testing). Read more
Source§

fn on_tap_at(self, f: impl Fn(Point) + 'static) -> Decorated<Self>

on_tap, told where: the point in the piece’s own coordinate space, origin at its top-leading corner. Read more
Source§

fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> Decorated<Self>

Bind this control’s keyboard focus to a signal (docs/focus.md), two-way like every other binding: native focus changes write the signal; writing the signal moves focus. Takes a Signal<bool> for one control, or (Signal<Option<K>>, K::Variant) binding one control of a group; writing false/None resigns focus (dismissing the soft keyboard on mobile). Focus applies asynchronously: a write is a request, resolved on the next turn, and the signal always ends up reflecting what the platform actually did.
Source§

fn on_key(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>

Handle the non-text keys (the arrows) that reach this piece while it has focus (docs/menus.md). Keys follow focus, so pair it with Decorate::focused or with a piece the user can click into: a canvas takes focus on a press, and only the focused piece hears the keys, so a nudge handler can never fire while a text field, a list or a sidebar is the one being typed into. Read more
Source§

fn on_key_up(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>

Handle the release of a key this piece heard go down (docs/menus.md “Keys”): the other half of held-key movement, where Decorate::on_key starts moving and this stops. Delivered where Cap::KeyPhases is supported; elsewhere it never fires, so step per press there instead.
Source§

fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Decorated<Self>

Declare toolbar items on the chrome this piece sits under (docs/toolbars.md). Read more
Source§

fn searchable(self, search: Search) -> Decorated<Self>

A search field for this navigation page (docs/search.md, “Page search”), drawn where the platform puts a page’s search: the window toolbar on a desktop, the page’s navigation bar on iOS (a UISearchController), its app bar on Android. It shows while this page does, and its text is the app’s query both ways. For a search the server runs, act on crate::Search::on_submit; for a local filter, read the query. Declare it on a nav_stack destination, as .toolbar(…) is declared; a whole navigation surface takes crate::Nav::searchable instead.
Source§

fn focusable(self) -> Decorated<Self>

Opt this piece into the platform’s focus system (docs/focus.md): the canvas contract for anything composed: it joins the key loop, takes focus on a press, reports through .focused(…), and hears the arrows through .on_key(…) while focused. A composed list column is the motivating case (docs/navigation.md). On a backend without the set_focusable duty the piece renders normally and never takes focus.
Source§

fn keyboard(self) -> Decorated<Self>

Take the whole keyboard while this piece is focused (docs/menus.md “The full route”): every key the platform delivers reaches Decorate::on_key, not only the arrows and digits. A key that types nothing is named by its web name, a key that types by its unmodified character, and what it typed rides in day_spec::KeyEvent::text: the character, or the whole string an input method committed (a dead-key accent, a Japanese phrase), delivered once, after the composition. Control chords arrive with day_spec::Modifiers::CONTROL set and no text; only the platform’s own command chords (⌘ on Apple platforms) stay with the menu. On a phone, focusing the piece raises the soft keyboard, the way focusing a text field does, and what it types arrives the same way. For a terminal, a code editor or a game that reads letters, on a canvas: Read more
Source§

fn drag_source( self, source: impl Fn(Point) -> Option<Offer> + 'static, ) -> Decorated<Self>

Offer data when a drag starts on this piece (docs/drag-and-drop.md “Offering data”): source gets the press point in the piece’s own coordinates and answers what to carry, or None to let the press be something else (a tap, a scroll).
Source§

fn drop_target(self, target: Target) -> Decorated<Self>

Accept drops through the platform’s native drag session (docs/drag-and-drop.md “Accepting drops”). The target is one value: its types, an optional acceptance policy, and what runs as a drag enters, leaves and drops. Read more
Source§

fn on_files_dropped(self, f: impl Fn(Vec<PathBuf>) + 'static) -> Decorated<Self>

Accept files dropped on this piece: f receives their local paths. The short form of Decorate::drop_target for the common case; use the full target for a hover highlight or another data type.
Source§

fn context_menu<M>(self, menu: impl ContextMenuContent<M>) -> Decorated<Self>

A context menu (docs/menus.md): shown on secondary-click / long-press, built from the same menu_item/sub_menu entries as everywhere else. Takes a fixed list, or a closure built when the menu is summoned (“Dynamic context menus”): with no argument, or with the summon point in this piece’s own coordinates, so a canvas can select what is under the pointer and offer commands for that selection. An empty result shows nothing. Read more
Source§

fn on_drag(self, f: impl Fn(Drag) + 'static) -> Decorated<Self>

Fire on each phase of a press-drag over this piece (docs/gestures.md “Gestures”). The Drag carries where the pointer is, how far it has come, and how fast it is moving; at Ended the velocity is the release velocity. Once the drag has begun it belongs to this piece: an enclosing scroll view does not take it over.
Source§

fn on_drag_along( self, axis: DragAxis, f: impl Fn(Drag) + 'static, ) -> Decorated<Self>

Decorate::on_drag for a drag that follows one axis, inside a scroll view that scrolls along the other: a horizontal swipe on a row of a vertical list. A pointer that sets off along axis is this piece’s drag; one that sets off across it scrolls, and the handler hears nothing of it. Read more
Source§

fn on_long_press(self, f: impl Fn(Point) + 'static) -> Decorated<Self>

Fire when a press is held still on this piece (docs/gestures.md “Long press”), with the press point in the piece’s coordinates. It fires while the pointer is still down, and the release that follows is not a tap, so .on_tap(..).on_long_press(..) are alternatives. Pair it with another route to the same command (a menu, a button): a long press is not discoverable.
Source§

fn on_double_tap(self, f: impl Fn() + 'static) -> Decorated<Self>

Fire on two taps in quick succession (docs/gestures.md “Double tap”). On a piece that also has Decorate::on_tap, a single tap waits out the double-tap interval and the two never both fire; with a double tap alone nothing waits.
Source§

fn on_double_tap_at(self, f: impl Fn(Point) + 'static) -> Decorated<Self>

on_double_tap, told where: the second tap’s point in the piece’s own coordinate space, origin at its top-leading corner. What a map or an image viewer zooms around.
Source§

fn on_pressed(self, f: impl Fn(bool) + 'static) -> Decorated<Self>

Follow the press on this piece: true at the pointer-down itself, false when the press ends (the release, the pointer leaving, or the platform taking the gesture away). Every true is followed by one false, so a handler that writes a Signal<bool> is a one-liner, and it never delays or cancels a tap or a drag on the same piece (docs/gestures.md “Press”). For styling, Decorate::interaction already tracks it.
Source§

fn on_touches(self, f: impl Fn(&[Touch]) + 'static) -> Decorated<Self>

Receive the raw contacts on this piece (docs/gestures.md “Touches”): every finger that is down, each with a stable id, plus the ones that lifted in this event. For a drawing surface, a multi-finger instrument or a recognizer of your own. Where the platform reports one pointer (day::gesture_support(GestureKind::Touches) is Emulated), the list holds that one contact with id 0.
Source§

fn hit_slop(self, slop: impl Into<Insets>) -> Decorated<Self>

Grow the area in which this piece takes pointer input by slop points on each edge, without moving or resizing it (docs/gestures.md “Hit slop”): a 12-point dot with .hit_slop(16.0) is a 44-point target. Layout and drawing do not change. Where Cap::HitSlop is unsupported the piece keeps its own bounds.
Source§

fn interaction(self, state: InteractionState) -> Decorated<Self>

Track this piece’s hover, press and focus in state (docs/gestures.md “State styling”), for reactive modifiers to read. See InteractionState.
Source§

fn enabled<M>(self, enabled: impl IntoReactive<bool, M>) -> Decorated<Self>

Enable or disable this piece and everything in it (docs/forms.md “Disabling a group”). While disabled, the controls inside are disabled the platform’s way (dimmed, out of the focus order, reported disabled to assistive technology) and no tap, drag, hover, press or key reaches a handler in the subtree. Takes a constant, a signal or a closure: Read more
Source§

fn on_pinch(self, f: impl Fn(Pinch) + 'static) -> Decorated<Self>

Fire on each phase of a pinch/magnify over this piece (docs/canvas.md “Zoom and pan”). Only backends with a native recognizer wired emit it; pair a zoom with visible controls.
Source§

fn on_rotate(self, f: impl Fn(Rotate) + 'static) -> Decorated<Self>

Fire on each phase of a two-finger rotation over this piece (docs/canvas.md “Zoom and pan”). Rotate::rotation is an Angle, cumulative within a gesture, positive clockwise; a trackpad tick arrives as a lone Changed. Pair it with a visible way back to north.
Source§

fn on_pan(self, f: impl Fn(Pan) + 'static) -> Decorated<Self>

Fire on each viewport-pan event over this piece (docs/canvas.md “Zoom and pan”): trackpad two-finger scroll, two-finger touch pan. delta is incremental; apply it as it arrives.
Source§

fn on_hover(self, f: impl Fn(Option<Point>) + 'static) -> Decorated<Self>

The pointer moving over this piece: Some(point) in its own coordinates while inside, None when it leaves (docs/canvas.md “Interaction”). Pointer-only; wire on_tap_at alongside it so a touch-only device can reach the same thing.
Source§

fn card(self) -> Decorated<Self>

The platform’s card around this piece: the grouped-content surface with Radius::M corners and a Space::M inset. Drawn by the toolkit, so it follows the appearance and never steals hit testing from the content.
Source§

fn background<M>(self, fill: impl IntoReactive<Paint, M>) -> Decorated<Self>

Fill the piece’s bounds with a Paint painted behind it: a message-bubble / card / badge surface. Takes a Color, a SystemColor, an Ink (Ink::adaptive(light, dark)), a gradient, or a signal or closure of any of them. An ink follows the appearance without a rebuild or a closure; a reactive source repaints when it changes. Wraps the piece in a native container that carries the fill, so it composes with Self::corner_radius for a rounded colored surface and with Self::padding for interior inset.
Source§

fn corner_radius<M>( self, radius: impl IntoReactive<Corner, M>, ) -> Decorated<Self>

Round the piece’s corners, clipping its background and content to the rounded rectangle. Takes points, a Radius step, a frame-relative Corner (Corner::CAPSULE for round ends), or a signal or closure of any of them; a change patches the view in place. Compose after Self::background for a rounded colored surface, or use alone to round a clipped child (an avatar image).
Source§

fn surface<M>(self, surface: impl IntoReactive<Surface, M>) -> Decorated<Self>

Put a styled native Surface behind the piece: fill (any Paint), rounded corners (all or some), a border and a shadow, all on one native view so the border follows the corners and the shadow takes their shape (docs/surfaces.md). Takes a surface, or a signal or closure of one; a change patches the view in place.
Source§

fn border<Mc, Mw>( self, color: impl IntoReactive<Ink, Mc>, width: impl IntoReactive<f64, Mw>, ) -> Decorated<Self>

A square line of color, width points wide, around the piece’s frame, inside it and over its content. Either argument may be a signal or a closure. For a border that follows rounded corners, use Self::surface.
Source§

fn shadow<M>(self, shadow: impl IntoReactive<Shadow, M>) -> Decorated<Self>

A shadow of the piece’s frame, drawn outside it by the toolkit. Takes a Shadow, or a signal or closure of one. For a rounded shadow, or one under a filled surface, use Self::surface.
Source§

fn opacity<M>(self, opacity: impl IntoReactive<f64, M>) -> Decorated<Self>

Animate/set the piece’s opacity (0.0 transparent … 1.0 opaque). Wrapped in a native layer so it composes with .background; the change animates when made inside with_animation or under a .animation ancestor (§8.4).
Source§

fn transform<M>(self, t: impl IntoReactive<Transform, M>) -> Decorated<Self>

Apply an animatable Transform (translate/scale/rotate about the center): the cheap movement/scaling channel that never triggers relayout (§8.4). Self::translation, Self::scale and Self::rotation are its one-property forms.
Source§

fn scale<M>(self, factor: impl IntoReactive<f64, M>) -> Decorated<Self>

Uniformly scale the piece by factor about its center (animatable). Convenience over Self::transform.
Source§

fn rotation<M>(self, angle: impl IntoReactive<Angle, M>) -> Decorated<Self>

Rotate the piece by angle clockwise about its center (animatable): .rotation(Angle::deg(15.0)).
Source§

fn translation<Mx, My>( self, x: impl IntoReactive<f64, Mx>, y: impl IntoReactive<f64, My>, ) -> Decorated<Self>

Translate the piece by (x, y) points without relayout (animatable). Layout still places the piece where it was; only what is drawn moves.
Source§

fn animation(self, anim: AnimSpec) -> Decorated<Self>

Attach an implicit animation (§8.4): changes to this piece’s (and its descendants’) animatable properties animate with anim even outside a with_animation. SwiftUI’s .animation. The ambient with_animation takes precedence when both apply.
Source§

fn modifier(self, m: impl Modifier) -> AnyPiece

Apply a Modifier (or, via the blanket impl, a plain FnOnce(AnyPiece) -> AnyPiece closure) to this piece. Pure composition: content.modifier(m) == m.apply(content.any()). Read more
Source§

fn overlay(self, over: impl Piece) -> Decorated<Self>

Draw over on top of this piece, centered, without affecting layout size: a badge / annotation overlay. self is the sizing content (bottom of the z-order); over is proposed self’s size and drawn on top. For an explicit alignment use Self::overlay_aligned; for a stack that sizes to the union of its children use zstack.
Source§

fn overlay_aligned(self, align: Alignment, over: impl Piece) -> Decorated<Self>

Self::overlay with an explicit Alignment for the annotation (e.g. a corner badge with Alignment::TopTrailing).
Source§

fn aspect_ratio<M>(self, ratio: impl IntoReactive<f64, M>) -> Decorated<Self>

Constrain this piece to a width / height ratio: the largest box of that shape which fits whatever the parent offers (SwiftUI’s .aspectRatio(_:contentMode: .fit)). Read more
Source§

fn aligned(self, alignment: Alignment) -> Decorated<Self>

Position this piece within its assigned space without stretching its content. Read more
Source§

fn grow(self, grow: impl Into<Grow>) -> Decorated<Self>

Expand to fill the space offered in the selected dimensions. Read more
Source§

fn grow_w(self) -> Decorated<Self>

👎Deprecated:

use .grow(Dimension::Width)

Source§

fn grow_h(self) -> Decorated<Self>

👎Deprecated:

use .grow(Dimension::Height)

Source§

fn grid_span(self, n: usize) -> Decorated<Self>

Span n columns (n ≥ 1) of the enclosing grid (docs/grid.md). Grid modifiers apply to the outermost layout node after wrapping modifiers, regardless of their chain position.
Source§

fn grid_align(self, a: Alignment) -> Decorated<Self>

Override this cell’s alignment within its cell rect of the enclosing grid (docs/grid.md). Like Decorated::grid_span, this applies outside wrapping modifiers regardless of its position in the chain.
Source§

fn defers_system_gestures(self, edges: Edges) -> Decorated<Self>

While this subtree is mounted, ask the OS to require a second swipe for its edge gestures on edges (docs/cover.md), the SwiftUI defersSystemGestures(on:) analogue. Put it on a game or drawing surface whose touches run to the screen edge, so a swipe up from the bottom doesn’t leave the app. iOS defers the chosen edges’ system gestures; Android enters swipe-to-reveal immersive mode while any subtree requests deferral; desktop backends no-op.
Source§

fn status_bar_hidden<M>( self, hidden: impl IntoReactive<bool, M>, ) -> Decorated<Self>

While this subtree is mounted and hidden is true, hide the system status bar, the SwiftUI statusBarHidden(_:) analogue (docs/cover.md). hidden is a constant, a Signal, or a closure, so a setting can turn it on and off in place. Put it on a page that wants the whole screen (a reader, a game, a photo viewer); the bar returns when the page unmounts. Any mounted request that answers true hides the bar. iOS, Android and HarmonyOS hide it (Cap::StatusBarHidden); desktop and web have none and ignore it.
Source§

fn interactive_dismiss_disabled(self) -> Decorated<Self>

While this subtree is mounted, the enclosing cover (or other modal surface) must not be dismissed interactively, the SwiftUI interactiveDismissDisabled() analogue (docs/cover.md). System back / sheet gestures are ignored; only programmatic writes (an explicit close control) dismiss it.
Source§

fn on_system_back<M>( self, enabled: impl IntoReactive<bool, M>, handler: impl Fn() + 'static, ) -> Decorated<Self>

While this subtree is mounted and enabled holds, a back nothing else takes runs handler instead of the platform’s default: Jetpack Compose’s BackHandler(enabled) (docs/navigation.md “Handling the system Back”). enabled is a constant, a Signal, or a closure, followed as it changes. Read more
Source§

fn any(self) -> AnyPiece

Erase to a single AnyPiece: for a Vec<AnyPiece>, a -> AnyPiece signature, or any other place one concrete type is required. AnyPiece::any is inherent and returns self, so erasing an already-erased piece costs nothing.
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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.