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: f32Fraction 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: boolWhether 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: boolImplementations§
Source§impl SwipeToDismissSpec
impl SwipeToDismissSpec
pub fn new() -> SwipeToDismissSpec
Sourcepub fn with_key(self, key: u64) -> SwipeToDismissSpec
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.
Sourcepub fn with_state(self, state: SwipeDismissState) -> SwipeToDismissSpec
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.
Sourcepub fn with_threshold_fraction(self, fraction: f32) -> SwipeToDismissSpec
pub fn with_threshold_fraction(self, fraction: f32) -> SwipeToDismissSpec
Sets the dismiss threshold as a fraction of the content width.
Sourcepub fn with_background(
self,
background: impl FnMut(SwipeDismissSide) + 'static,
) -> SwipeToDismissSpec
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.
pub fn with_direction( self, direction: SwipeDismissDirection, ) -> SwipeToDismissSpec
pub fn from_edge(self, width: f32) -> SwipeToDismissSpec
pub fn with_reset_after_dismiss(self, reset: bool) -> SwipeToDismissSpec
pub fn with_collapse_after_dismiss(self, collapse: bool) -> SwipeToDismissSpec
pub fn with_enabled(self, enabled: bool) -> SwipeToDismissSpec
Trait Implementations§
Source§impl Clone for SwipeToDismissSpec
impl Clone for SwipeToDismissSpec
Source§fn clone(&self) -> SwipeToDismissSpec
fn clone(&self) -> SwipeToDismissSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for SwipeToDismissSpec
impl Default for SwipeToDismissSpec
Source§fn default() -> SwipeToDismissSpec
fn default() -> SwipeToDismissSpec
Auto Trait Implementations§
impl !RefUnwindSafe for SwipeToDismissSpec
impl !Send for SwipeToDismissSpec
impl !Sync for SwipeToDismissSpec
impl !UnwindSafe for SwipeToDismissSpec
impl Freeze for SwipeToDismissSpec
impl Unpin for SwipeToDismissSpec
impl UnsafeUnpin for SwipeToDismissSpec
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.