pub struct List<T, K>where
T: 'static,
K: 'static,{ /* private fields */ }Expand description
A native recycling list: the platform widget owns scrolling + cell reuse; Day builds each
visible row once and rebinds it (a slot-write into its ItemSlot) as cells recycle.
Shares the ItemSlot row contract with each; migrating is a one-word change.
Implementations§
Source§impl<T, K> List<T, K>
impl<T, K> List<T, K>
Sourcepub fn row_height(self, h: RowHeight) -> List<T, K>
pub fn row_height(self, h: RowHeight) -> List<T, K>
Row sizing: Uniform(h) (fastest) or Automatic (self-sizing).
Sourcepub fn on_select(self, f: impl Fn(K) + 'static) -> List<T, K>
pub fn on_select(self, f: impl Fn(K) + 'static) -> List<T, K>
Called with the selected row’s key when the native list reports a selection.
Sourcepub fn multi_select(self, on: bool) -> List<T, K>
pub fn multi_select(self, on: bool) -> List<T, K>
Allow selecting several rows at once, where the toolkit supports it (docs/list.md has
the matrix; single-selection backends fall back to one row at a time). Every selection
change calls Self::on_selection with the FULL set of selected keys.
Sourcepub fn on_selection(self, f: impl Fn(Vec<K>) + 'static) -> List<T, K>
pub fn on_selection(self, f: impl Fn(Vec<K>) + 'static) -> List<T, K>
Called with the full set of selected keys (row order, empty = cleared) whenever the
selection changes — the multi-select analogue of Self::on_select. Also fired by
single-selection backends with a one-element (or empty) set.
Sourcepub fn selected_rows(
self,
rows: impl Fn() -> Vec<usize> + 'static,
) -> List<T, K>
pub fn selected_rows( self, rows: impl Fn() -> Vec<usize> + 'static, ) -> List<T, K>
Reactively sync the native selection to rows (row indices; empty clears). Re-runs
whenever the closure’s tracked reads change; the toolkit applies the sync without
re-emitting a selection event — drive it from app state to build “Clear selection”.
Sourcepub fn scroll_to_end(self, trigger: Trigger) -> List<T, K>
pub fn scroll_to_end(self, trigger: Trigger) -> List<T, K>
Scroll the list so its LAST row is fully visible whenever trigger fires — e.g. a chat
timeline sticking to the newest message. Fire it with day_reactive::Trigger::notify
after appending. No-op while the list is empty. The scroll targets the native list
(NSTableView/UITableView/GtkListView/QListView/RecyclerView), so it respects the
platform’s own scroll physics.
Sourcepub fn stick_to_bottom(self, on: bool) -> List<T, K>
pub fn stick_to_bottom(self, on: bool) -> List<T, K>
Best-effort auto-stick: after a data reload, scroll to the end so freshly appended rows stay
visible. Convenience over Self::scroll_to_end for feeds that always follow the newest
row; for finer control (only stick when the user is already near the bottom) drive
scroll_to_end from your own logic instead. Off by default.
Sourcepub fn scroll_to_row(self, sig: Signal<Option<usize>>) -> List<T, K>
pub fn scroll_to_row(self, sig: Signal<Option<usize>>) -> List<T, K>
Programmatic scroll-to-row (docs/list.md): set the signal to Some(row) and the native
list scrolls that row into view, realizing it if it was virtualized away — the row rail’s
counterpart to scroll(...).scroll_target(...). The signal is left as written; setting
the same row again re-fires.
Sourcepub fn reorderable(self, on: bool) -> List<T, K>
pub fn reorderable(self, on: bool) -> List<T, K>
Let the user drag rows into a new order with the platform’s native mechanism — the
macOS drop gap, the iOS long-press lift, Android’s ItemTouchHelper — where the backend
supports it (probe Cap::ListReorder; docs/list.md has the matrix). Pair with
on_reorder so the app’s data follows the move, and optionally
reorder_guard to veto or retarget drops.
Sourcepub fn on_reorder(self, f: impl Fn(usize, usize) + 'static) -> List<T, K>
pub fn on_reorder(self, f: impl Fn(usize, usize) + 'static) -> List<T, K>
A committed move: row from now sits at row to. Apply the same rotation to the backing
data (let it = v.remove(from); v.insert(to, it);) — and persist it if the order should
survive a relaunch. Runs on the main thread at the next event drain, never inside the
native drop callback.
Sourcepub fn reorder_guard(
self,
g: impl Fn(usize, usize) -> Reorder + 'static,
) -> List<T, K>
pub fn reorder_guard( self, g: impl Fn(usize, usize) -> Reorder + 'static, ) -> List<T, K>
Veto or override drops while the drag is live: called synchronously from the native
validate hook with (from, proposed_to). Return Reorder::Deny to refuse,
Reorder::Retarget to accept at a different index (a “pinned rows” pattern), or
Reorder::Allow to accept as proposed (the default when no guard is set). Keep it
pure — read state, decide, return; it runs inside the platform’s drag callback.
Trait Implementations§
Auto Trait Implementations§
impl<T, K> Freeze for List<T, K>
impl<T, K> !RefUnwindSafe for List<T, K>
impl<T, K> !Send for List<T, K>
impl<T, K> !Sync for List<T, K>
impl<T, K> Unpin for List<T, K>
impl<T, K> UnsafeUnpin for List<T, K>
impl<T, K> !UnwindSafe for List<T, K>
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: impl Into<String>) -> AnyPiece
fn id(self, id: impl Into<String>) -> AnyPiece
Source§fn id_of(self, id: impl Fn() -> String + 'static) -> AnyPiece
fn id_of(self, id: impl Fn() -> String + 'static) -> AnyPiece
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 || format!("row-remove-{}", slot.key())).Source§fn id_keyed(self, prefix: &'static str, key: impl Display) -> AnyPiece
fn id_keyed(self, prefix: &'static str, key: impl Display) -> AnyPiece
prefix:key (§5.5).Source§fn tweak(self, f: impl FnOnce(RNode) + 'static) -> AnyPiece
fn tweak(self, f: impl FnOnce(RNode) + 'static) -> AnyPiece
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.Source§fn selectable(self) -> AnyPiece
fn selectable(self) -> AnyPiece
label: text is NOT selectable by default
on any backend, matching each platform’s native behavior. Applied to the piece’s own
widget, so on a container it makes all the text within it selectable. Read moreSource§fn native_ref(self, r: &NativeRef) -> AnyPiece
fn native_ref(self, r: &NativeRef) -> AnyPiece
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.fn padding(self, insets: impl IntoInsets) -> AnyPiece
Source§fn max_width(self, max: f64) -> AnyPiece
fn max_width(self, max: f64) -> AnyPiece
max points: the child is never PROPOSED more, so text
wraps inside the cap (chat bubbles, readable columns) while narrower content hugs.fn frame(self, width: f64, height: f64) -> AnyPiece
Source§fn width(self, width: f64) -> AnyPiece
fn width(self, width: f64) -> AnyPiece
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) -> AnyPiece
fn height(self, height: f64) -> AnyPiece
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) -> AnyPiece
Source§fn on_tap(self, f: impl Fn() + 'static) -> AnyPiece
fn on_tap(self, f: impl Fn() + 'static) -> AnyPiece
Source§fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> AnyPiece
fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> AnyPiece
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.menu_item/sub_menu/menu_role/
menu_separator. Passing an empty Vec removes any menu.Source§fn on_drag(self, f: impl Fn(Drag) + 'static) -> AnyPiece
fn on_drag(self, f: impl Fn(Drag) + 'static) -> AnyPiece
Source§fn background<M>(self, color: impl IntoReactive<Color, M>) -> AnyPiece
fn background<M>(self, color: impl IntoReactive<Color, M>) -> AnyPiece
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.Source§fn corner_radius(self, radius: f64) -> AnyPiece
fn corner_radius(self, radius: f64) -> AnyPiece
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>) -> AnyPiece
fn opacity<M>(self, opacity: impl IntoReactive<f64, M>) -> AnyPiece
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>) -> AnyPiece
fn transform<M>(self, t: impl IntoReactive<Transform, M>) -> AnyPiece
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>) -> AnyPiece
fn scale<M>(self, factor: impl IntoReactive<f64, M>) -> AnyPiece
factor about its center (animatable). Convenience over
Self::transform.Source§fn rotation<M>(self, degrees: impl IntoReactive<f64, M>) -> AnyPiece
fn rotation<M>(self, degrees: impl IntoReactive<f64, M>) -> AnyPiece
degrees clockwise about its center (animatable).Source§fn translation<Mx, My>(
self,
x: impl IntoReactive<f64, Mx>,
y: impl IntoReactive<f64, My>,
) -> AnyPiece
fn translation<Mx, My>( self, x: impl IntoReactive<f64, Mx>, y: impl IntoReactive<f64, My>, ) -> AnyPiece
x, y) points WITHOUT relayout (animatable) — the
animation-friendly sibling of .offset.Source§fn animation(self, anim: AnimSpec) -> AnyPiece
fn animation(self, anim: AnimSpec) -> AnyPiece
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
fn modifier(self, m: impl Modifier) -> AnyPiece
Modifier — or, via the blanket impl, a plain FnOnce(AnyPiece) -> AnyPiece
closure — to this piece. Pure composition: content.modifier(m) == m.apply(content.any()).Source§fn overlay(self, over: impl Piece) -> AnyPiece
fn overlay(self, over: impl Piece) -> AnyPiece
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) -> AnyPiece
fn overlay_aligned(self, align: Alignment, over: impl Piece) -> AnyPiece
Self::overlay with an explicit Alignment for the annotation (e.g. a corner badge with
Alignment::TopTrailing).Source§fn grow(self) -> AnyPiece
fn grow(self) -> AnyPiece
Flex — the stack
offers it the space and it fills; no native backing, so this is a pure layout change.Source§fn grid_span(self, n: usize) -> AnyPiece
fn grid_span(self, n: usize) -> AnyPiece
n columns (n ≥ 1) of the enclosing grid (docs/grid.md). Grid modifiers set
facts on the node the grid sees: apply them LAST (outermost), like .grow_w() — an
outer wrapper would hide the facts from the grid.Source§fn grid_align(self, a: Alignment) -> AnyPiece
fn grid_align(self, a: Alignment) -> AnyPiece
grid
(docs/grid.md). Apply LAST (outermost), like Self::grid_span.Source§fn defers_system_gestures(self, edges: Edges) -> AnyPiece
fn defers_system_gestures(self, edges: Edges) -> AnyPiece
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 interactive_dismiss_disabled(self) -> AnyPiece
fn interactive_dismiss_disabled(self) -> AnyPiece
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.fn any(self) -> AnyPiece
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