Merge pull request #2482 from HansMuller/dismiss_action

Support undo in the leave-behind demo
This commit is contained in:
Hans Muller
2016-03-08 15:44:50 -08:00
6 changed files with 26 additions and 11 deletions

View File

@@ -58,7 +58,7 @@ class Dismissable extends StatefulComponent {
this.child,
this.background,
this.secondaryBackground,
this.onResized,
this.onResize,
this.onDismissed,
this.direction: DismissDirection.horizontal
}) : super(key: key) {
@@ -79,7 +79,7 @@ class Dismissable extends StatefulComponent {
final Widget secondaryBackground;
/// Called when the widget changes size (i.e., when contracting before being dismissed).
final VoidCallback onResized;
final VoidCallback onResize;
/// Called when the widget has been dismissed, after finishing resizing.
final DismissDirectionCallback onDismissed;
@@ -263,12 +263,11 @@ class _DismissableState extends State<Dismissable> {
void _handleResizeProgressChanged() {
if (_resizeController.isCompleted) {
if (config.onDismissed != null) {
if (config.onDismissed != null)
config.onDismissed(_dismissDirection);
}
} else {
if (config.onResized != null)
config.onResized();
if (config.onResize != null)
config.onResize();
}
}

View File

@@ -13,7 +13,7 @@ DismissDirection dismissDirection = DismissDirection.horizontal;
DismissDirection reportedDismissDirection;
List<int> dismissedItems = <int>[];
void handleOnResized(int item) {
void handleOnResize(int item) {
expect(dismissedItems.contains(item), isFalse);
}
@@ -28,7 +28,7 @@ Widget buildDismissableItem(int item) {
key: new ValueKey<int>(item),
direction: dismissDirection,
onDismissed: (DismissDirection direction) { handleOnDismissed(direction, item); },
onResized: () { handleOnResized(item); },
onResize: () { handleOnResize(item); },
child: new Container(
width: itemExtent,
height: itemExtent,