@@ -134,6 +134,7 @@ class SlideActionListDelegate extends SlideActionDelegate {
134
134
/// The slide actions.
135
135
final List <Widget > actions;
136
136
137
+ /// The number of actions.
137
138
@override
138
139
int get actionCount => actions? .length ?? 0 ;
139
140
@@ -156,6 +157,7 @@ class _SlidableScope extends InheritedWidget {
156
157
bool updateShouldNotify (_SlidableScope oldWidget) => oldWidget.state != state;
157
158
}
158
159
160
+ /// The data used by a [Slidable] .
159
161
class SlidableData extends InheritedWidget {
160
162
SlidableData ({
161
163
Key key,
@@ -174,17 +176,35 @@ class SlidableData extends InheritedWidget {
174
176
@required Widget child,
175
177
}) : super (key: key, child: child);
176
178
179
+ /// The type of slide action that is currently been showed by the [Slidable] .
177
180
final SlideActionType actionType;
181
+
182
+ /// The rendering mode in which the [Slidable] is.
178
183
final SlidableRenderingMode renderingMode;
184
+
185
+ /// The total extent of all the actions
179
186
final double totalActionsExtent;
187
+
188
+ /// The offset threshold the item has to be dragged in order to be considered
189
+ /// dismissed.
180
190
final double dismissThreshold;
191
+
192
+ /// Indicates whether the [Slidable] can be dismissed.
181
193
final bool dismissible;
182
194
183
195
/// The current actions that have to be shown.
184
196
final SlideActionDelegate actionDelegate;
197
+
198
+ /// Animation for the whole movement.
185
199
final Animation <double > overallMoveAnimation;
200
+
201
+ /// Animation for the actions.
186
202
final Animation <double > actionsMoveAnimation;
203
+
204
+ /// Dismiss animation.
187
205
final Animation <double > dismissAnimation;
206
+
207
+ /// The slidable.
188
208
final Slidable slidable;
189
209
190
210
/// Relative ratio between one slide action and the extent of the child.
@@ -193,16 +213,31 @@ class SlidableData extends InheritedWidget {
193
213
/// The direction in which this widget can be slid.
194
214
final Axis direction;
195
215
216
+ /// Indicates whether the primary actions are currently shown.
196
217
bool get showActions => actionType == SlideActionType .primary;
218
+
219
+ /// The number of actions.
197
220
int get actionCount => actionDelegate? .actionCount ?? 0 ;
221
+
222
+ /// If the [actionType] is [SlideActionType.primary] returns 1, -1 otherwise.
198
223
double get actionSign => actionType == SlideActionType .primary ? 1.0 : - 1.0 ;
224
+
225
+ /// Indicates wheter the direction is horizontal.
199
226
bool get directionIsXAxis => direction == Axis .horizontal;
227
+
228
+ /// The alignment of the actions.
200
229
Alignment get alignment => Alignment (
201
230
directionIsXAxis ? - actionSign : 0.0 ,
202
231
directionIsXAxis ? 0.0 : - actionSign,
203
232
);
233
+
234
+ /// If the [direction] is horizontal, returns the [totalActionsExtent]
235
+ /// otherwise null.
204
236
double get actionPaneWidthFactor =>
205
237
directionIsXAxis ? totalActionsExtent : null ;
238
+
239
+ /// If the [direction] is vertical, returns the [totalActionsExtent]
240
+ /// otherwise null.
206
241
double get actionPaneHeightFactor =>
207
242
directionIsXAxis ? null : totalActionsExtent;
208
243
@@ -238,6 +273,7 @@ class SlidableData extends InheritedWidget {
238
273
);
239
274
}
240
275
276
+ /// Creates a [FractionallyAlignedSizedBox] related to the current direction and showed actions.
241
277
FractionallyAlignedSizedBox createFractionallyAlignedSizedBox ({
242
278
Widget child,
243
279
double extentFactor,
@@ -262,14 +298,16 @@ class SlidableData extends InheritedWidget {
262
298
return List .generate (
263
299
actionCount,
264
300
(int index) => actionDelegate.build (
265
- context,
266
- index,
267
- actionsMoveAnimation,
268
- SlidableRenderingMode .slide,
269
- ),
301
+ context,
302
+ index,
303
+ actionsMoveAnimation,
304
+ SlidableRenderingMode .slide,
305
+ ),
270
306
);
271
307
}
272
308
309
+ /// Whether the framework should notify widgets that inherit from this widget.
310
+ @override
273
311
bool updateShouldNotify (SlidableData oldWidget) =>
274
312
(oldWidget.actionType != actionType) ||
275
313
(oldWidget.renderingMode != renderingMode) ||
@@ -288,19 +326,29 @@ class SlidableData extends InheritedWidget {
288
326
/// A controller that keep tracks of the active [SlidableState] and close
289
327
/// the previous one.
290
328
class SlidableController {
329
+ /// Creates a controller that keep tracks of the active [SlidableState] and close
330
+ /// the previous one.
291
331
SlidableController ({
292
332
this .onSlideAnimationChanged,
293
333
this .onSlideIsOpenChanged,
294
334
});
295
335
336
+ /// Function called when the animation changed.
296
337
final ValueChanged <Animation <double >> onSlideAnimationChanged;
338
+
339
+ /// Function called when the [Slidable] open status changed.
297
340
final ValueChanged <bool > onSlideIsOpenChanged;
341
+
298
342
bool _isSlideOpen;
299
343
300
344
Animation <double > _slideAnimation;
301
345
302
346
SlidableState _activeState;
347
+
348
+ /// The state of the active [Slidable] .
303
349
SlidableState get activeState => _activeState;
350
+
351
+ /// Changes the state of the active [Slidable] .
304
352
set activeState (SlidableState value) {
305
353
_activeState? ._flingAnimationController ();
306
354
@@ -559,8 +607,11 @@ class SlidableState extends State<Slidable>
559
607
double get _totalActionsExtent => widget.actionExtentRatio * (_actionCount);
560
608
561
609
double get _dismissThreshold {
562
- if (widget.dismissal == null ) return _kDismissThreshold;
563
- else return widget.dismissal.dismissThresholds[actionType] ?? _kDismissThreshold;
610
+ if (widget.dismissal == null )
611
+ return _kDismissThreshold;
612
+ else
613
+ return widget.dismissal.dismissThresholds[actionType] ??
614
+ _kDismissThreshold;
564
615
}
565
616
566
617
bool get _dismissible => widget.dismissal != null && _dismissThreshold < 1.0 ;
@@ -716,8 +767,9 @@ class SlidableState extends State<Slidable>
716
767
if (_dismissible && ! widget.dismissal.dragDismissible) {
717
768
// If the widget is not dismissible by dragging, clamp drag result
718
769
// so the widget doesn't slide past [_totalActionsExtent].
719
- _overallMoveController.value = (_dragExtent.abs () / _overallDragAxisExtent)
720
- .clamp (0.0 , _totalActionsExtent);
770
+ _overallMoveController.value =
771
+ (_dragExtent.abs () / _overallDragAxisExtent)
772
+ .clamp (0.0 , _totalActionsExtent);
721
773
} else {
722
774
_overallMoveController.value =
723
775
_dragExtent.abs () / _overallDragAxisExtent;
0 commit comments