pub struct Nav<S, K = String>{ /* private fields */ }Implementations§
Sourcepub fn refreshable<M>(
self,
refreshing: impl IntoReactive<bool, M>,
action: impl Fn() + 'static,
) -> Nav<S, K>
pub fn refreshable<M>( self, refreshing: impl IntoReactive<bool, M>, action: impl Fn() + 'static, ) -> Nav<S, K>
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.
Sourcepub fn sections(self, sections: Sections) -> Nav<S, K>
pub fn sections(self, sections: Sections) -> Nav<S, K>
Collapsible sidebar sections (docs/navigation.md), as a Sections value:
nav(sel).sections(Sections::restored("nav.sections").on_change(f)).
Sourcepub fn section_id<M>(
self,
id: impl Into<String>,
title: impl IntoText<M>,
content: impl NavContent<K>,
) -> Nav<S, K>
pub fn section_id<M>( self, id: impl Into<String>, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Nav<S, K>
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).
Sourcepub fn reorder_items(
self,
eligible: impl Fn(&K) -> bool + 'static,
moved: impl Fn(K, K) + 'static,
) -> Nav<S, K>
pub fn reorder_items( self, eligible: impl Fn(&K) -> bool + 'static, moved: impl Fn(K, K) + 'static, ) -> Nav<S, K>
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.
Sourcepub fn regroup_items(
self,
drag: impl Fn(&K) -> NavDrag + 'static,
dropped: impl Fn(NavDrop<K>) + 'static,
) -> Nav<S, K>
pub fn regroup_items( self, drag: impl Fn(&K) -> NavDrag + 'static, dropped: impl Fn(NavDrop<K>) + 'static, ) -> Nav<S, K>
Like Self::reorder_items, but rows may also cross section headers: drag a feed from
one collection’s section into another’s (docs/navigation.md “Moving rows between
sections”). drag says how each row drags, re-asked whenever the rows change:
NavDrag::Reorder rows move within their section and into others,
NavDrag::Regroup rows only into others (their own section keeps the app’s sorted
order), and a section holding a NavDrag::Fixed row takes no drop at all. Rows above
the first header form one unnamed section. dropped gets the moved key, the
destination section’s section_id and the row it now sits before; a drop back where
the row started reports nothing. Apply the move to the app’s data, which brings the new
rows back. Declaring this and Self::reorder_items on one nav keeps the later one;
collapsible Self::sections take precedence over both. Probe Cap::NavReorder.
Sourcepub fn retain_selection_when(
self,
keep: impl Fn(&K) -> bool + 'static,
) -> Nav<S, K>
pub fn retain_selection_when( self, keep: impl Fn(&K) -> bool + 'static, ) -> Nav<S, K>
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.
Sourcepub fn icon_progress(
self,
progress: impl Fn() -> Vec<(K, Option<f64>)> + 'static,
) -> Nav<S, K>
pub fn icon_progress( self, progress: impl Fn() -> Vec<(K, Option<f64>)> + 'static, ) -> Nav<S, K>
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.
pub fn style(self, style: NavStyle) -> Nav<S, K>
Sourcepub fn title<M>(self, t: impl IntoText<M>) -> Nav<S, K>
pub fn title<M>(self, t: impl IntoText<M>) -> Nav<S, K>
The sidebar / window title (Sidebar style).
Sourcepub fn section<M>(
self,
title: impl IntoText<M>,
content: impl NavContent<K>,
) -> Nav<S, K>
pub fn section<M>( self, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Nav<S, K>
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)))Sourcepub fn header<P>(self, build: impl FnOnce() -> P + 'static) -> Nav<S, K>where
P: Piece,
pub fn header<P>(self, build: impl FnOnce() -> P + 'static) -> Nav<S, K>where
P: Piece,
An optional piece shown above the sidebar list (a logo, app name…).
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.
Sourcepub fn presentation(self, presentation: NavPresentation) -> Nav<S, K>
pub fn presentation(self, presentation: NavPresentation) -> Nav<S, K>
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.
Sourcepub fn content_list(self, list: ContentList<K>) -> Nav<S, K>
pub fn content_list(self, list: ContentList<K>) -> Nav<S, K>
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)),
)Sourcepub fn item<M, P>(
self,
key: impl Into<K>,
title: impl IntoText<M>,
build: impl Fn() -> P + 'static,
) -> Nav<S, K>where
P: Piece,
pub fn item<M, P>(
self,
key: impl Into<K>,
title: impl IntoText<M>,
build: impl Fn() -> P + 'static,
) -> Nav<S, K>where
P: Piece,
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.
Sourcepub fn items(self, content: impl NavContent<K>) -> Nav<S, K>
pub fn items(self, content: impl NavContent<K>) -> Nav<S, K>
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),
))Sourcepub fn destination<P>(self, build: impl Fn(&K) -> P + 'static) -> Nav<S, K>where
P: Piece,
pub fn destination<P>(self, build: impl Fn(&K) -> P + 'static) -> Nav<S, K>where
P: Piece,
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.
Sourcepub fn local(self) -> Nav<S, K>
pub fn local(self) -> Nav<S, K>
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).
Sourcepub fn restore(self, key: impl Into<String>) -> Nav<S, K>
pub fn restore(self, key: impl Into<String>) -> Nav<S, K>
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.
Sourcepub fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Nav<S, K>
pub fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Nav<S, K>
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))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.
Sourcepub fn searchable(self, search: Search) -> Nav<S, K>
pub fn searchable(self, search: Search) -> Nav<S, K>
Trait Implementations§
Source§fn refreshable<M>(
self,
refreshing: impl IntoReactive<bool, M>,
action: impl Fn() + 'static,
) -> Nav<S, K>
fn refreshable<M>( self, refreshing: impl IntoReactive<bool, M>, action: impl Fn() + 'static, ) -> Nav<S, K>
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) -> Nav<S, K>
fn sections(self, sections: Sections) -> Nav<S, K>
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>,
) -> Nav<S, K>
fn section_id<M>( self, id: impl Into<String>, title: impl IntoText<M>, content: impl NavContent<K>, ) -> Nav<S, K>
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,
) -> Nav<S, K>
fn reorder_items( self, eligible: impl Fn(&K) -> bool + 'static, moved: impl Fn(K, K) + 'static, ) -> Nav<S, K>
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 regroup_items(
self,
drag: impl Fn(&K) -> NavDrag + 'static,
dropped: impl Fn(NavDrop<K>) + 'static,
) -> Nav<S, K>
fn regroup_items( self, drag: impl Fn(&K) -> NavDrag + 'static, dropped: impl Fn(NavDrop<K>) + 'static, ) -> Nav<S, K>
Self::reorder_items, but rows may also cross section headers: drag a feed from
one collection’s section into another’s (docs/navigation.md “Moving rows between
sections”). drag says how each row drags, re-asked whenever the rows change:
NavDrag::Reorder rows move within their section and into others,
NavDrag::Regroup rows only into others (their own section keeps the app’s sorted
order), and a section holding a NavDrag::Fixed row takes no drop at all. Rows above
the first header form one unnamed section. dropped gets the moved key, the
destination section’s section_id and the row it now sits before; a drop back where
the row started reports nothing. Apply the move to the app’s data, which brings the new
rows back. Declaring this and Self::reorder_items on one nav keeps the later one;
collapsible Self::sections take precedence over both. Probe Cap::NavReorder.Source§fn retain_selection_when(self, keep: impl Fn(&K) -> bool + 'static) -> Nav<S, K>
fn retain_selection_when(self, keep: impl Fn(&K) -> bool + 'static) -> Nav<S, K>
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,
) -> Nav<S, K>
fn icon_progress( self, progress: impl Fn() -> Vec<(K, Option<f64>)> + 'static, ) -> Nav<S, K>
.items.fn style(self, style: NavStyle) -> Nav<S, K>
Source§fn title<M>(self, t: impl IntoText<M>) -> Nav<S, K>
fn title<M>(self, t: impl IntoText<M>) -> Nav<S, K>
Source§fn header<P>(self, build: impl FnOnce() -> P + 'static) -> Nav<S, K>where
P: Piece,
fn header<P>(self, build: impl FnOnce() -> P + 'static) -> Nav<S, K>where
P: Piece,
Self::header, this slot applies to sidebar navigation, not tab/rail chrome.Source§fn presentation(self, presentation: NavPresentation) -> Nav<S, K>
fn presentation(self, presentation: NavPresentation) -> Nav<S, K>
Source§fn content_list(self, list: ContentList<K>) -> Nav<S, K>
fn content_list(self, list: ContentList<K>) -> Nav<S, K>
ContentList value: Read moreSource§fn item<M, P>(
self,
key: impl Into<K>,
title: impl IntoText<M>,
build: impl Fn() -> P + 'static,
) -> Nav<S, K>where
P: Piece,
fn item<M, P>(
self,
key: impl Into<K>,
title: impl IntoText<M>,
build: impl Fn() -> P + 'static,
) -> Nav<S, K>where
P: Piece,
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>) -> Nav<S, K>
fn items(self, content: impl NavContent<K>) -> Nav<S, K>
Source§fn destination<P>(self, build: impl Fn(&K) -> P + 'static) -> Nav<S, K>where
P: Piece,
fn destination<P>(self, build: impl Fn(&K) -> P + 'static) -> Nav<S, K>where
P: Piece,
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) -> Nav<S, K>
fn local(self) -> Nav<S, K>
current_route nor intercepts navigate/deep links. Read moreSource§fn restore(self, key: impl Into<String>) -> Nav<S, K>
fn restore(self, key: impl Into<String>) -> Nav<S, K>
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>) -> Nav<S, K>
fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Nav<S, K>
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<P> Decorate for Pwhere
P: Piece,
impl<P> Decorate for Pwhere
P: Piece,
Source§fn id(self, id: ElementId) -> Decorated<Self>
fn id(self, id: ElementId) -> Decorated<Self>
Source§fn wrapper_id(self, id: ElementId) -> Decorated<Self>
fn wrapper_id(self, id: ElementId) -> Decorated<Self>
id.Source§fn apply_if(
self,
cond: bool,
f: impl FnOnce(Decorated<Self>) -> Decorated<Self>,
) -> Decorated<Self>
fn apply_if( self, cond: bool, f: impl FnOnce(Decorated<Self>) -> Decorated<Self>, ) -> Decorated<Self>
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>
fn apply_some<T>( self, value: Option<T>, f: impl FnOnce(Decorated<Self>, T) -> Decorated<Self>, ) -> Decorated<Self>
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>
fn id_of(self, id: impl Fn() -> ElementId + 'static) -> Decorated<Self>
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>
fn tweak(self, f: impl FnOnce(RNode) + 'static) -> Decorated<Self>
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 moreSource§fn selectable(self) -> Decorated<Self>
fn selectable(self) -> Decorated<Self>
Source§fn cursor<M>(self, cursor: impl IntoReactive<Cursor, M>) -> Decorated<Self>
fn cursor<M>(self, cursor: impl IntoReactive<Cursor, M>) -> Decorated<Self>
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>
fn layout_direction<M>( self, direction: impl IntoReactive<LayoutDirection, M>, ) -> Decorated<Self>
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 moreSource§fn window_drag_region(self) -> Decorated<Self>
fn window_drag_region(self) -> Decorated<Self>
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>
fn native_ref(self, r: &NativeRef) -> Decorated<Self>
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 max_width<M>(self, max: impl IntoReactive<f64, M>) -> Decorated<Self>
fn max_width<M>(self, max: impl IntoReactive<f64, M>) -> Decorated<Self>
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>
fn max_height<M>(self, max: impl IntoReactive<f64, M>) -> Decorated<Self>
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>
fn min_width<M>(self, min: impl IntoReactive<f64, M>) -> Decorated<Self>
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>
fn min_height<M>(self, min: impl IntoReactive<f64, M>) -> Decorated<Self>
min points of height, expanding for taller content. Reactive like
Decorate::max_width.Source§fn reserving<M>(self, sample: impl IntoText<M>) -> Decorated<Self>
fn reserving<M>(self, sample: impl IntoText<M>) -> Decorated<Self>
sample needs, so this piece’s size stops changing with its
content. Read morefn 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>
fn width<M>(self, width: impl IntoReactive<f64, M>) -> Decorated<Self>
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>
fn height<M>(self, height: impl IntoReactive<f64, M>) -> Decorated<Self>
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.fn a11y( self, f: impl FnOnce(A11yBuilder) -> A11yBuilder + 'static, ) -> Decorated<Self>
Source§fn on_tap(self, f: impl Fn() + 'static) -> Decorated<Self>
fn on_tap(self, f: impl Fn() + 'static) -> Decorated<Self>
Source§fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> Decorated<Self>
fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> Decorated<Self>
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>
fn on_key(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>
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 moreSource§fn on_key_up(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>
fn on_key_up(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>
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>
fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Decorated<Self>
Source§fn searchable(self, search: Search) -> Decorated<Self>
fn searchable(self, search: Search) -> Decorated<Self>
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>
fn focusable(self) -> Decorated<Self>
.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>
fn keyboard(self) -> Decorated<Self>
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 moreSource§fn drag_source(
self,
source: impl Fn(Point) -> Option<Offer> + 'static,
) -> Decorated<Self>
fn drag_source( self, source: impl Fn(Point) -> Option<Offer> + 'static, ) -> Decorated<Self>
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>
fn drop_target(self, target: Target) -> Decorated<Self>
Source§fn on_files_dropped(self, f: impl Fn(Vec<PathBuf>) + 'static) -> Decorated<Self>
fn on_files_dropped(self, f: impl Fn(Vec<PathBuf>) + 'static) -> Decorated<Self>
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.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 moreSource§fn on_drag(self, f: impl Fn(Drag) + 'static) -> Decorated<Self>
fn on_drag(self, f: impl Fn(Drag) + 'static) -> Decorated<Self>
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>
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 moreSource§fn on_long_press(self, f: impl Fn(Point) + 'static) -> Decorated<Self>
fn on_long_press(self, f: impl Fn(Point) + 'static) -> Decorated<Self>
.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>
fn on_double_tap(self, f: impl Fn() + 'static) -> Decorated<Self>
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>
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>
fn on_pressed(self, f: impl Fn(bool) + 'static) -> Decorated<Self>
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>
fn on_touches(self, f: impl Fn(&[Touch]) + 'static) -> Decorated<Self>
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>
fn hit_slop(self, slop: impl Into<Insets>) -> Decorated<Self>
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>
fn interaction(self, state: InteractionState) -> Decorated<Self>
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>
fn enabled<M>(self, enabled: impl IntoReactive<bool, M>) -> Decorated<Self>
Source§fn on_pinch(self, f: impl Fn(Pinch) + 'static) -> Decorated<Self>
fn on_pinch(self, f: impl Fn(Pinch) + 'static) -> Decorated<Self>
Source§fn on_rotate(self, f: impl Fn(Rotate) + 'static) -> Decorated<Self>
fn on_rotate(self, f: impl Fn(Rotate) + 'static) -> Decorated<Self>
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>
fn on_pan(self, f: impl Fn(Pan) + 'static) -> Decorated<Self>
delta is incremental; apply it
as it arrives.Source§fn on_hover(self, f: impl Fn(Option<Point>) + 'static) -> Decorated<Self>
fn on_hover(self, f: impl Fn(Option<Point>) + 'static) -> Decorated<Self>
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>
fn card(self) -> Decorated<Self>
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>
fn background<M>(self, fill: impl IntoReactive<Paint, M>) -> Decorated<Self>
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>
fn corner_radius<M>( self, radius: impl IntoReactive<Corner, M>, ) -> Decorated<Self>
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>
fn surface<M>(self, surface: impl IntoReactive<Surface, M>) -> Decorated<Self>
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>
fn border<Mc, Mw>( self, color: impl IntoReactive<Ink, Mc>, width: impl IntoReactive<f64, Mw>, ) -> Decorated<Self>
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>
fn shadow<M>(self, shadow: impl IntoReactive<Shadow, M>) -> Decorated<Self>
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>
fn opacity<M>(self, opacity: impl IntoReactive<f64, M>) -> Decorated<Self>
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>
fn transform<M>(self, t: impl IntoReactive<Transform, M>) -> Decorated<Self>
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>
fn scale<M>(self, factor: impl IntoReactive<f64, M>) -> Decorated<Self>
factor about its center (animatable). Convenience over
Self::transform.Source§fn rotation<M>(self, angle: impl IntoReactive<Angle, M>) -> Decorated<Self>
fn rotation<M>(self, angle: impl IntoReactive<Angle, M>) -> Decorated<Self>
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>
fn translation<Mx, My>( self, x: impl IntoReactive<f64, Mx>, y: impl IntoReactive<f64, My>, ) -> Decorated<Self>
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>
fn animation(self, anim: AnimSpec) -> Decorated<Self>
anim even outside a with_animation. SwiftUI’s
.animation. The ambient with_animation takes precedence when both apply.Source§fn overlay(self, over: impl Piece) -> Decorated<Self>
fn overlay(self, over: impl Piece) -> Decorated<Self>
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>
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>
fn aspect_ratio<M>(self, ratio: impl IntoReactive<f64, M>) -> Decorated<Self>
width / height ratio: the largest box of that shape which
fits whatever the parent offers (SwiftUI’s .aspectRatio(_:contentMode: .fit)). Read moreSource§fn aligned(self, alignment: Alignment) -> Decorated<Self>
fn aligned(self, alignment: Alignment) -> Decorated<Self>
Source§fn grow(self, grow: impl Into<Grow>) -> Decorated<Self>
fn grow(self, grow: impl Into<Grow>) -> Decorated<Self>
Source§fn grid_span(self, n: usize) -> Decorated<Self>
fn grid_span(self, n: usize) -> Decorated<Self>
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>
fn grid_align(self, a: Alignment) -> Decorated<Self>
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>
fn defers_system_gestures(self, edges: Edges) -> Decorated<Self>
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.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>
fn interactive_dismiss_disabled(self) -> Decorated<Self>
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>
fn on_system_back<M>( self, enabled: impl IntoReactive<bool, M>, handler: impl Fn() + 'static, ) -> Decorated<Self>
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 moreimpl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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