Skip to main content

Delete

Struct Delete 

Source
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

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Delete

Source§

fn clone(&self) -> Delete

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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