Skip to main content

SwipeToDismissSpec

Struct SwipeToDismissSpec 

Source
pub struct SwipeToDismissSpec {
    pub threshold_fraction: f32,
    pub key: Option<u64>,
    pub state: Option<SwipeDismissState>,
    pub direction: SwipeDismissDirection,
    pub edge_width: Option<f32>,
    pub collapse_after_dismiss: bool,
    pub reset_after_dismiss: bool,
    pub enabled: bool,
    /* private fields */
}
Expand description

Configuration for SwipeToDismiss.

Fields§

§threshold_fraction: f32

Fraction of the content width the offset must exceed on release for the row to dismiss (default 0.5). Clamped to (0, 1].

§key: Option<u64>

Identity of the wrapped content (e.g. the row’s database id). When a composition slot is reused for a DIFFERENT item — unkeyed lazy-list rows all shift up after a removal — the remembered swipe state must not leak onto the new item: without a key, the next row inherits the dismissed row’s displacement, revealed background and collapsed height (“items go shuffled, red boxes stick”).

Inside a keyed lazy list this is filled in from the item’s own key, so a row states its identity once, where the list already states it. Set it explicitly only for a row that is not a lazy item, or whose identity is not the one the list is keyed by.

§state: Option<SwipeDismissState>

Caller-owned swipe state, from rememberSwipeDismissState.

Supply one to read the swipe as it happens — a label that fades in with it, a count of what is about to go, an undo bar after it lands — or to return a row to rest from elsewhere on the screen. Left unset, the row owns its own state.

§direction: SwipeDismissDirection§edge_width: Option<f32>§collapse_after_dismiss: bool§reset_after_dismiss: bool

Whether the content returns to rest once on_dismiss has fired (default false).

A dismissed ROW is about to be removed by its host, so it stays off screen and the host drops it. A full-content NAVIGATION dismissal is not that: the gesture means “go up one level”, and the host may legitimately answer by staying composed – back out of a pause overlay and the game underneath resumes in the same root composable. Left off screen, that content never comes back, and since SwipeToDismissBox owns its state internally the application has no handle to call SwipeDismissState::reset on. The screen is then blank, taps land on nothing, and further back gestures neither redraw nor leave.

§enabled: bool

Implementations§

Source§

impl SwipeToDismissSpec

Source

pub fn new() -> SwipeToDismissSpec

Source

pub fn with_key(self, key: u64) -> SwipeToDismissSpec

Declares the identity of the wrapped content. When the key changes, the swipe state resets to rest — the new item starts untouched.

A row inside a keyed lazy list already has an identity and does not need this.

Source

pub fn with_state(self, state: SwipeDismissState) -> SwipeToDismissSpec

Uses caller-owned swipe state, so the swipe can be read and reset from outside the row.

Source

pub fn with_threshold_fraction(self, fraction: f32) -> SwipeToDismissSpec

Sets the dismiss threshold as a fraction of the content width.

Source

pub fn with_background( self, background: impl FnMut(SwipeDismissSide) + 'static, ) -> SwipeToDismissSpec

Sets the background content revealed behind the swiped row. The closure receives the SwipeDismissSide the row is currently being swiped toward, so it can align its label/icon to the revealed edge.

Source

pub fn with_direction( self, direction: SwipeDismissDirection, ) -> SwipeToDismissSpec

Source

pub fn from_edge(self, width: f32) -> SwipeToDismissSpec

Source

pub fn with_reset_after_dismiss(self, reset: bool) -> SwipeToDismissSpec

Source

pub fn with_collapse_after_dismiss(self, collapse: bool) -> SwipeToDismissSpec

Source

pub fn with_enabled(self, enabled: bool) -> SwipeToDismissSpec

Trait Implementations§

Source§

impl Clone for SwipeToDismissSpec

Source§

fn clone(&self) -> SwipeToDismissSpec

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
Source§

impl Default for SwipeToDismissSpec

Source§

fn default() -> SwipeToDismissSpec

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more