Skip to main content

Nav

Struct Nav 

Source
pub struct Nav<S: Binding<K>, K: Route = String> { /* private fields */ }

Implementations§

Source§

impl<K: Route, S: Binding<K>> Nav<S, K>

Source

pub fn refreshable<M>( self, refreshing: impl IntoReactive<bool, M>, action: impl Fn() + 'static, ) -> Self

Add the platform’s pull-to-refresh control to the sidebar rows (docs/navigation.md). UIKit uses UIRefreshControl, Android SwipeRefreshLayout. Other toolkits can ignore this affordance, so retain a Refresh command for keyboard/accessibility users. refreshing is app-owned: set it synchronously when accepting a request and clear it on completion, failure or cancellation. Repeated pulls while busy are ignored. A declined request stops the indicator immediately. Programmatic state writes never call action. The handler and state bindings live only as long as this navigation.

Source

pub fn sections(self, sections: Sections) -> Self

Collapsible sidebar sections (docs/navigation.md), as a Sections value: nav(sel).sections(Sections::restored("nav.sections").on_change(f)).

Source

pub fn section_id<M>( self, id: impl Into<String>, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Self

A section with a persistent identity independent of its localized title or first row, heading content (one item, a tuple, an Option, a nav_items block, or a mix).

Source

pub fn reorder_items( self, eligible: impl Fn(&K) -> bool + 'static, moved: impl Fn(K, K) + 'static, ) -> Self

Enable dragging within contiguous runs of eligible sidebar items. Fixed items and section headers cannot be crossed. The callback receives the moved key and the key whose position it takes (indices refer to the order before removal). Uses the shared list reorder driver where Cap::NavReorder supports it; otherwise retains the native navigation widget. UIKit navigation remains fixed even though content lists support dragging. Tab/rail chrome remains fixed. Persist the order in the callback’s backing data.

Source

pub fn retain_selection_when(self, keep: impl Fn(&K) -> bool + 'static) -> Self

Preserve the current destination when its row disappears and keep returns true. Useful for filtered sidebars: reading a feed’s last unread article can hide its row without closing the article. The native sidebar then has no highlighted row. Return false for deleted records to retain the normal selection-reset behavior. Evaluated when the item list changes; pair with Self::destination for dynamic keys.

Source

pub fn icon_progress( self, progress: impl Fn() -> Vec<(K, Option<f64>)> + 'static, ) -> Self

Progress over leading icons, without rebuilding rows or changing label geometry. Return active route keys with None while connecting/unknown-length, or Some(0..=1) for a known fraction. Omit finished keys. AppKit/UIKit animate in the compositor; other toolkits currently leave icons unchanged. Bind separately from .items.

Source

pub fn style(self, style: NavStyle) -> Self

Source

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

The sidebar / window title (Sidebar style).

Source

pub fn section<M>( self, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Self

A section: content (one item, a tuple, an Option, a nav_items block, or a mix) under a header. Backends without grouped rows ignore the header and show one flat list, so a section is a grouping hint, never a source of items the user cannot otherwise reach.

ⓘ
nav(sel)
    .section(res::str::smart_feeds(), (
        item("today", res::str::today()).icon(res::images::today).page(today_page),
        item("unread", res::str::unread()).icon(res::images::unread).page(unread_page),
    ))
    .section(res::str::feeds(), nav_items(move || st.feeds.get(), |f| item(f.id, f.name)))
Source

pub fn header<P: Piece>(self, build: impl FnOnce() -> P + 'static) -> Self

An optional piece shown above the sidebar list (a logo, app name…).

Source

pub fn footer<P: Piece>(self, build: impl FnOnce() -> P + 'static) -> Self

An optional piece pinned below the sidebar list, outside its scroll area. It belongs to the root page: stacked destinations do not carry it along. Like Self::header, this slot applies to sidebar navigation, not tab/rail chrome.

Source

pub fn presentation(self, presentation: NavPresentation) -> Self

Pin the presentation instead of letting the window’s size decide (docs/size-classes.md).

Leave this unset (the default) and the nav shows sidebar+detail on a window wide enough for both and stacks on one that is not, re-presenting live as the window is resized or the device rotated. Pin it when the content only works one way: a settings sidebar whose detail is meaningless alone, a wizard that must stay a stack.

A pin is still a preference. A toolkit with no split container (the phones today) stacks whatever is asked for, exactly as it does for the automatic case.

Source

pub fn content_list(self, list: ContentList<K>) -> Self

A content-list pane between the sidebar and the detail, the Mail shape (docs/navigation.md), as a ContentList value:

ⓘ
nav(scene.section).content_list(
    ContentList::new(pages::items::item_list_pane)
        .width(320.0)
        .only_for(|s: &Section| matches!(s, Section::Items))
        .detail_visible(scene.detail_open)
        .detail_title(move || pages::items::detail_title(scene)),
)
Source

pub fn item<M, P: Piece>( self, key: impl Into<K>, title: impl IntoText<M>, build: impl Fn() -> P + 'static, ) -> Self

Add one destination: item(key, title).page(build) in one call. key addresses it (navigate / deep link / dayscript); title is its label; build runs when the item is first shown. For a typed nav over Option<Section> pass the bare Section::X. For an icon, a badge or a tint, build the item value and add it with items.

Source

pub fn items(self, content: impl NavContent<K>) -> Self

Add items (docs/navigation.md): one item, a tuple of them, an Option, a Vec, a data-driven nav_items block, or a mix. Static items and blocks may be mixed in any order; the final list is their declaration order.

ⓘ
nav(sel).items((
    item("home", res::str::home()).icon(res::images::home).page(home_page),
    nav_items(move || rooms.get(), |r| item(r.id.clone(), r.name.clone())),
    prefs.nav_item(Section::Settings),
))
Source

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

Build the page for a key whose item has no page of its own (the rows of a data-driven block). Mirrors NavStack::destination; unused for a nav whose items all carry a page.

Source

pub fn local(self) -> Self

Use this nav as a local widget: its selection is not part of the app route, so it neither adds a segment to current_route nor intercepts navigate/deep links.

Reach for this when a page already routes and you embed a second one-of-N control in it (a filter tab strip, a secondary sidebar). Two routing selectors at the same level both feed current_route(), so you’d get section/childA/childB and navigate("childB") would be ambiguous; mark all but the primary one .local(). A nav nested one level deeper (a Tabs inside a Sidebar section) is a different case and should stay routed: its key belongs in the cascade. In debug builds, two routed one-of-N surfaces at the same level log a warning naming this fix (docs/navigation.md).

Source

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

Remember the selected item across launches (docs/navigation.md). The selected key is saved under key on every change and restored at build (so the app reopens on the tab/section the user last had) unless a launch deep link is pending, which wins. day::launch installs the preferences as the store (docs/navigation.md); a stale saved key (its item no longer exists) is ignored. Works whether or not the nav is routed.

Source

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

Declare toolbar items on this host’s chrome (docs/toolbars.md): the sidebar column where the presentation has one, and the root list when it has collapsed to a stack.

This is where a command that acts on the list belongs: “add an item”, “sort”, “filter”. A command that acts on whatever page is open belongs on the page instead, declared with the same method on the piece that page builds, and then it comes and goes with that page rather than riding a list it cannot act on.

Takes one item, a list of them, or a closure that derives the list and re-runs whenever its reactive reads change.

ⓘ
nav(section)
    .toolbar(toolbar_button(day_core::id!(add), tr("add")).icon(Symbol::Add).action(add_item))
Source

pub fn no_sidebar_toggle(self) -> Self

Do not draw the platform’s own show/hide-sidebar affordance on this host’s chrome. It is on by default for a sidebar presentation, since every desktop expects one and the toolkit owns both the button and the behavior; this is for a window that should not offer it.

Source

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

Make this surface searchable (docs/search.md), as a Search value:

ⓘ
nav(section)
    .style(NavStyle::Sidebar)
    .searchable(Search::new(query).prompt(res::str::search()).reveal(SearchReveal::OnPull))
    .items(nav_items(move || destinations().filter(|d| matches_query(d, &query.get())), destination_row))

Trait Implementations§

Source§

impl<K: Route, S: Binding<K>> NavBuilder<K> for Nav<S, K>

Source§

fn refreshable<M>( self, refreshing: impl IntoReactive<bool, M>, action: impl Fn() + 'static, ) -> Self

Add the platform’s pull-to-refresh control to the sidebar rows (docs/navigation.md). UIKit uses UIRefreshControl, Android SwipeRefreshLayout. Other toolkits can ignore this affordance, so retain a Refresh command for keyboard/accessibility users. refreshing is app-owned: set it synchronously when accepting a request and clear it on completion, failure or cancellation. Repeated pulls while busy are ignored. A declined request stops the indicator immediately. Programmatic state writes never call action. The handler and state bindings live only as long as this navigation.
Source§

fn sections(self, sections: Sections) -> Self

Collapsible sidebar sections (docs/navigation.md), as a Sections value: nav(sel).sections(Sections::restored("nav.sections").on_change(f)).
Source§

fn section_id<M>( self, id: impl Into<String>, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Self

A section with a persistent identity independent of its localized title or first row, heading content (one item, a tuple, an Option, a nav_items block, or a mix).
Source§

fn reorder_items( self, eligible: impl Fn(&K) -> bool + 'static, moved: impl Fn(K, K) + 'static, ) -> Self

Enable dragging within contiguous runs of eligible sidebar items. Fixed items and section headers cannot be crossed. The callback receives the moved key and the key whose position it takes (indices refer to the order before removal). Uses the shared list reorder driver where Cap::NavReorder supports it; otherwise retains the native navigation widget. UIKit navigation remains fixed even though content lists support dragging. Tab/rail chrome remains fixed. Persist the order in the callback’s backing data.
Source§

fn retain_selection_when(self, keep: impl Fn(&K) -> bool + 'static) -> Self

Preserve the current destination when its row disappears and keep returns true. Useful for filtered sidebars: reading a feed’s last unread article can hide its row without closing the article. The native sidebar then has no highlighted row. Return false for deleted records to retain the normal selection-reset behavior. Evaluated when the item list changes; pair with Self::destination for dynamic keys.
Source§

fn icon_progress( self, progress: impl Fn() -> Vec<(K, Option<f64>)> + 'static, ) -> Self

Progress over leading icons, without rebuilding rows or changing label geometry. Return active route keys with None while connecting/unknown-length, or Some(0..=1) for a known fraction. Omit finished keys. AppKit/UIKit animate in the compositor; other toolkits currently leave icons unchanged. Bind separately from .items.
Source§

fn style(self, style: NavStyle) -> Self

Source§

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

The sidebar / window title (Sidebar style).
Source§

fn section<M>( self, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Self

A section: content (one item, a tuple, an Option, a nav_items block, or a mix) under a header. Backends without grouped rows ignore the header and show one flat list, so a section is a grouping hint, never a source of items the user cannot otherwise reach. Read more
Source§

fn header<P: Piece>(self, build: impl FnOnce() -> P + 'static) -> Self

An optional piece shown above the sidebar list (a logo, app name…).
Source§

fn footer<P: Piece>(self, build: impl FnOnce() -> P + 'static) -> Self

An optional piece pinned below the sidebar list, outside its scroll area. It belongs to the root page: stacked destinations do not carry it along. Like Self::header, this slot applies to sidebar navigation, not tab/rail chrome.
Source§

fn presentation(self, presentation: NavPresentation) -> Self

Pin the presentation instead of letting the window’s size decide (docs/size-classes.md). Read more
Source§

fn content_list(self, list: ContentList<K>) -> Self

A content-list pane between the sidebar and the detail, the Mail shape (docs/navigation.md), as a ContentList value: Read more
Source§

fn item<M, P: Piece>( self, key: impl Into<K>, title: impl IntoText<M>, build: impl Fn() -> P + 'static, ) -> Self

Add one destination: item(key, title).page(build) in one call. key addresses it (navigate / deep link / dayscript); title is its label; build runs when the item is first shown. For a typed nav over Option<Section> pass the bare Section::X. For an icon, a badge or a tint, build the item value and add it with items.
Source§

fn items(self, content: impl NavContent<K>) -> Self

Add items (docs/navigation.md): one item, a tuple of them, an Option, a Vec, a data-driven nav_items block, or a mix. Static items and blocks may be mixed in any order; the final list is their declaration order. Read more
Source§

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

Build the page for a key whose item has no page of its own (the rows of a data-driven block). Mirrors NavStack::destination; unused for a nav whose items all carry a page.
Source§

fn local(self) -> Self

Use this nav as a local widget: its selection is not part of the app route, so it neither adds a segment to current_route nor intercepts navigate/deep links. Read more
Source§

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

Remember the selected item across launches (docs/navigation.md). The selected key is saved under key on every change and restored at build (so the app reopens on the tab/section the user last had) unless a launch deep link is pending, which wins. day::launch installs the preferences as the store (docs/navigation.md); a stale saved key (its item no longer exists) is ignored. Works whether or not the nav is routed.
Source§

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

Declare toolbar items on this host’s chrome (docs/toolbars.md): the sidebar column where the presentation has one, and the root list when it has collapsed to a stack. Read more
Source§

fn no_sidebar_toggle(self) -> Self

Do not draw the platform’s own show/hide-sidebar affordance on this host’s chrome. It is on by default for a sidebar presentation, since every desktop expects one and the toolkit owns both the button and the behavior; this is for a window that should not offer it.
Source§

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

Make this surface searchable (docs/search.md), as a Search value: Read more
Source§

impl<K: Route, S: Binding<K>> Piece for Nav<S, K>

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<S, K> Freeze for Nav<S, K>
where S: Freeze,

§

impl<S, K> Unpin for Nav<S, K>
where S: Unpin, K: Unpin,

§

impl<S, K> UnsafeUnpin for Nav<S, K>
where S: 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_appkit::with_native, day_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 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(self, insets: impl IntoInsets) -> Decorated<Self>

Source§

fn max_width(self, max: f64) -> 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.
Source§

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

Source§

fn reserving(self, sample: impl Into<String>) -> Decorated<Self>

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

fn frame(self, width: f64, height: f64) -> Decorated<Self>

Source§

fn width(self, width: f64) -> 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(self, height: f64) -> 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 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 drag_source( self, source: impl Fn(Point) -> Option<Offer> + 'static, ) -> Decorated<Self>

Attach a context menu, shown with the platform’s native affordance on secondary-click (desktop) or long-press (mobile). Items are built with menu_item/sub_menu/menu_role/ menu_separator. Passing an empty Vec removes any menu.
Source§

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

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>

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

Fill the piece’s bounds with a solid color painted behind it: a message-bubble / card / badge surface. Accepts a constant Color, a Signal<Color>, or a Fn() -> Color; a reactive color repaints the surface when its source 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. The platform’s card around this piece: the grouped-content surface with rounded corners and a Space::M inset (see Decorated::card).
Source§

fn background<M>(self, color: impl IntoReactive<Color, M>) -> Decorated<Self>

Source§

fn corner_radius(self, radius: f64) -> Decorated<Self>

Round the piece’s corners to radius points, clipping its background and content to the rounded rectangle. Compose after Self::background for a rounded colored surface, or use alone to round a clipped child (e.g. an avatar image).
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). Prefer this over .offset for animated motion.
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, degrees: impl IntoReactive<f64, M>) -> Decorated<Self>

Rotate the piece by degrees clockwise about its center (animatable).
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): the animation-friendly sibling of .offset.
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(self, ratio: f64) -> 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 grow(self) -> Decorated<Self>

Expand to fill the available space on both axes (a filling pane / card that stretches to its container). Wraps the piece in a layout-only node carrying grow Flex: the stack offers it the space and it fills; no native backing, so this is a pure layout change.
Source§

fn grow_w(self) -> Decorated<Self>

Expand to fill the available horizontal space.
Source§

fn grow_h(self) -> Decorated<Self>

Expand to fill the available vertical space.
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). Apply last (outermost), like Decorated::grid_span.
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 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.
§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Day API ↩ Guides· daybrite.dev