pub struct DraggableScrollableController { /* private fields */ }Expand description
Controls a DraggableScrollableSheet.
Draggable scrollable controllers are typically stored as member variables in
State objects and are reused in each State::build. Controllers can only
be used to control one sheet at a time. A controller can be reused with a
new sheet if the previous sheet has been disposed.
The controller’s methods cannot be used until after the controller has been
passed into a DraggableScrollableSheet and the sheet has run init_state.
A DraggableScrollableController is a
Listenable. It notifies its listeners whenever an
attached sheet changes sizes. It does not notify its listeners when a sheet is first
attached or when an attached sheet’s parameters change without affecting the sheet’s
current size. It does not fire when pixels changes without
size changing. For example, if the constraints provided to an attached
sheet change.
Implementations§
Source§impl DraggableScrollableController
impl DraggableScrollableController
Sourcepub fn new(app: &mut App) -> Ref<DraggableScrollableController>
pub fn new(app: &mut App) -> Ref<DraggableScrollableController>
Creates a controller for DraggableScrollableSheet.
Sourcepub fn size(self: Handle<Self>, app: &App) -> f64
pub fn size(self: Handle<Self>, app: &App) -> f64
Get the current size (as a fraction of the parent height) of the attached sheet.
Sourcepub fn pixels(self: Handle<Self>, app: &App) -> f64
pub fn pixels(self: Handle<Self>, app: &App) -> f64
Get the current pixel height of the attached sheet.
Sourcepub fn size_to_pixels(self: Handle<Self>, app: &App, size: f64) -> f64
pub fn size_to_pixels(self: Handle<Self>, app: &App, size: f64) -> f64
Convert a sheet’s size (fractional value of parent container height) to pixels.
Sourcepub fn is_attached(self: Handle<Self>, app: &App) -> bool
pub fn is_attached(self: Handle<Self>, app: &App) -> bool
Whether a DraggableScrollableController has attached itself to a
DraggableScrollableSheet.
If this is false, then members that interact with the ScrollPosition,
such as size_to_pixels, size,
animate_to, and jump_to, must not be called.
Sourcepub fn pixels_to_size(self: Handle<Self>, app: &App, pixels: f64) -> f64
pub fn pixels_to_size(self: Handle<Self>, app: &App, pixels: f64) -> f64
Convert a sheet’s pixel height to size (fractional value of parent container height).
Sourcepub fn animate_to(
self: Handle<Self>,
app: &mut App,
size: f64,
duration: Duration,
curve: Rc<dyn Curve>,
) -> CompleterFuture<()> ⓘ
pub fn animate_to( self: Handle<Self>, app: &mut App, size: f64, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ
Animates the attached sheet from its current size to the given size, a
fractional value of the parent container’s height.
Any active sheet animation is canceled. If the sheet’s internal scrollable is currently animating (e.g. responding to a user fling), that animation is canceled as well.
An animation will be interrupted whenever the user attempts to scroll manually, whenever another activity is started, or when the sheet hits its max or min size (e.g. if you animate to 1 but the max size is .8, the animation will stop playing when it reaches .8).
The duration must not be zero. To jump to a particular value without an
animation, use jump_to.
The sheet will not snap after calling animate_to even if
DraggableScrollableSheet::snap is true. Snapping only occurs after user drags.
The returned future completes when the animation ends. An interrupted animation is stopped as canceled, so its future never completes — as Dart’s does not.
Sourcepub fn jump_to(self: Handle<Self>, app: &mut App, size: f64)
pub fn jump_to(self: Handle<Self>, app: &mut App, size: f64)
Jumps the attached sheet from its current size to the given size, a
fractional value of the parent container’s height.
If size is outside of the attached sheet’s min or max child size,
jump_to will jump the sheet to the nearest valid size instead.
Any active sheet animation is canceled. If the sheet’s inner scrollable is currently animating (e.g. responding to a user fling), that animation is canceled as well.
The sheet will not snap after calling jump_to even if
DraggableScrollableSheet::snap is true. Snapping only occurs after user drags.
Sourcepub fn reset(self: Handle<Self>, app: &mut App)
pub fn reset(self: Handle<Self>, app: &mut App)
Reset the attached sheet to its initial size (see
DraggableScrollableSheet::initial_child_size).
Trait Implementations§
Source§impl ChangeNotifier for DraggableScrollableController
impl ChangeNotifier for DraggableScrollableController
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.