pub struct Delete { /* private fields */ }Expand description
Swipe-to-delete for a list() (docs/list.md): the handler that applies a committed delete,
the label the platform puts on its affordance, an optional per-row guard, and whether the
gesture is offered right now. A list is deletable exactly when it carries one of these
(list(..).deletable(Delete::new(f))).
The platform’s delete gesture does the work (the iOS trailing swipe action, Android’s
ItemTouchHelper swipe, ArkUI’s ListItem swipe action) where the backend supports it
(probe Cap::ListDelete). The desktop toolkits answer Unsupported, so a list that must be
editable everywhere pairs this with an explicit control (a menu item or a button).
Implementations§
Source§impl Delete
impl Delete
Sourcepub fn new(deleted: impl Fn(usize) + 'static) -> Delete
pub fn new(deleted: impl Fn(usize) + 'static) -> Delete
deleted(index) runs after a committed delete: row index is gone. Apply the same
removal to the backing data (v.remove(index)), and persist it if the change should
survive a relaunch. Runs on the main thread at the next event drain, never inside the
native swipe callback.
Sourcepub fn label<M>(self, text: impl IntoText<M>) -> Delete
pub fn label<M>(self, text: impl IntoText<M>) -> Delete
The word the platform puts on its delete affordance (res::str::delete()). Resolved in
the locale current when the list builds. Left unset, each backend falls back to a trash
glyph rather than shipping an English word into every locale.
Sourcepub fn guard(self, g: impl Fn(usize) -> bool + 'static) -> Delete
pub fn guard(self, g: impl Fn(usize) -> bool + 'static) -> Delete
Protect individual rows: called synchronously before the affordance is offered, so a row
that answers false shows no delete action rather than one that fails on use. Keep it
pure; it runs inside the platform’s swipe callback.
Sourcepub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Delete
pub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Delete
Whether the gesture is offered right now (default true): a constant or a reactive
bool, read when the platform asks whether a row may be deleted.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Delete
impl !Send for Delete
impl !Sync for Delete
impl !UnwindSafe for Delete
impl Freeze for Delete
impl Unpin for Delete
impl UnsafeUnpin for Delete
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<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