Showing
1 changed file
with
25 additions
and
5 deletions
| @@ -72,6 +72,8 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -72,6 +72,8 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 72 | Color barrierColor, | 72 | Color barrierColor, |
| 73 | bool expand = false, | 73 | bool expand = false, |
| 74 | AnimationController secondAnimation, | 74 | AnimationController secondAnimation, |
| 75 | + Curve routeAnimationCurve, | ||
| 76 | + Curve modalAnimationCurve, | ||
| 75 | bool useRootNavigator = false, | 77 | bool useRootNavigator = false, |
| 76 | bool bounce = true, | 78 | bool bounce = true, |
| 77 | bool isDismissible, | 79 | bool isDismissible, |
| @@ -107,11 +109,15 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -107,11 +109,15 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 107 | isDismissible: isDismissible ?? expand == false ? true : false, | 109 | isDismissible: isDismissible ?? expand == false ? true : false, |
| 108 | modalBarrierColor: barrierColor ?? Colors.black12, | 110 | modalBarrierColor: barrierColor ?? Colors.black12, |
| 109 | enableDrag: enableDrag, | 111 | enableDrag: enableDrag, |
| 112 | + routeAnimationCurve: routeAnimationCurve, | ||
| 113 | + modalAnimationCurve: modalAnimationCurve, | ||
| 110 | )); | 114 | )); |
| 111 | return result; | 115 | return result; |
| 112 | } | 116 | } |
| 113 | 117 | ||
| 114 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | 118 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { |
| 119 | + final Curve modalAnimationCurve; | ||
| 120 | + | ||
| 115 | CupertinoModalBottomSheetRoute({ | 121 | CupertinoModalBottomSheetRoute({ |
| 116 | ScrollWidgetBuilder builder, | 122 | ScrollWidgetBuilder builder, |
| 117 | WidgetWithChildBuilder containerBuilder, | 123 | WidgetWithChildBuilder containerBuilder, |
| @@ -120,12 +126,14 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -120,12 +126,14 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 120 | ShapeBorder shape, | 126 | ShapeBorder shape, |
| 121 | Clip clipBehavior, | 127 | Clip clipBehavior, |
| 122 | AnimationController secondAnimationController, | 128 | AnimationController secondAnimationController, |
| 129 | + Curve routeAnimationCurve, | ||
| 123 | Color modalBarrierColor, | 130 | Color modalBarrierColor, |
| 124 | bool bounce = true, | 131 | bool bounce = true, |
| 125 | bool isDismissible = true, | 132 | bool isDismissible = true, |
| 126 | bool enableDrag = true, | 133 | bool enableDrag = true, |
| 127 | @required bool expanded, | 134 | @required bool expanded, |
| 128 | RouteSettings settings, | 135 | RouteSettings settings, |
| 136 | + this.modalAnimationCurve, | ||
| 129 | }) : assert(expanded != null), | 137 | }) : assert(expanded != null), |
| 130 | assert(isDismissible != null), | 138 | assert(isDismissible != null), |
| 131 | assert(enableDrag != null), | 139 | assert(enableDrag != null), |
| @@ -140,6 +148,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -140,6 +148,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 140 | enableDrag: enableDrag, | 148 | enableDrag: enableDrag, |
| 141 | expanded: expanded, | 149 | expanded: expanded, |
| 142 | settings: settings, | 150 | settings: settings, |
| 151 | + animationCurve: routeAnimationCurve, | ||
| 143 | ); | 152 | ); |
| 144 | 153 | ||
| 145 | @override | 154 | @override |
| @@ -172,18 +181,25 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -172,18 +181,25 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 172 | Widget getPreviousRouteTransition(BuildContext context, | 181 | Widget getPreviousRouteTransition(BuildContext context, |
| 173 | Animation<double> secondaryAnimation, Widget child) { | 182 | Animation<double> secondaryAnimation, Widget child) { |
| 174 | return _CupertinoModalTransition( | 183 | return _CupertinoModalTransition( |
| 175 | - secondaryAnimation: secondaryAnimation, body: child); | 184 | + secondaryAnimation: secondaryAnimation, |
| 185 | + body: child, | ||
| 186 | + animationCurve: modalAnimationCurve, | ||
| 187 | + ); | ||
| 176 | } | 188 | } |
| 177 | } | 189 | } |
| 178 | 190 | ||
| 179 | class _CupertinoModalTransition extends StatelessWidget { | 191 | class _CupertinoModalTransition extends StatelessWidget { |
| 180 | final Animation<double> secondaryAnimation; | 192 | final Animation<double> secondaryAnimation; |
| 193 | + final Curve animationCurve; | ||
| 181 | 194 | ||
| 182 | final Widget body; | 195 | final Widget body; |
| 183 | 196 | ||
| 184 | - const _CupertinoModalTransition( | ||
| 185 | - {Key key, @required this.secondaryAnimation, @required this.body}) | ||
| 186 | - : super(key: key); | 197 | + const _CupertinoModalTransition({ |
| 198 | + Key key, | ||
| 199 | + @required this.secondaryAnimation, | ||
| 200 | + @required this.body, | ||
| 201 | + this.animationCurve, | ||
| 202 | + }) : super(key: key); | ||
| 187 | 203 | ||
| 188 | @override | 204 | @override |
| 189 | Widget build(BuildContext context) { | 205 | Widget build(BuildContext context) { |
| @@ -196,7 +212,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -196,7 +212,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
| 196 | 212 | ||
| 197 | final curvedAnimation = CurvedAnimation( | 213 | final curvedAnimation = CurvedAnimation( |
| 198 | parent: secondaryAnimation, | 214 | parent: secondaryAnimation, |
| 199 | - curve: Curves.easeOut, | 215 | + curve: animationCurve ?? Curves.easeOut, |
| 200 | ); | 216 | ); |
| 201 | 217 | ||
| 202 | return AnnotatedRegion<SystemUiOverlayStyle>( | 218 | return AnnotatedRegion<SystemUiOverlayStyle>( |
| @@ -261,6 +277,8 @@ class CupertinoScaffold extends StatefulWidget { | @@ -261,6 +277,8 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 261 | static Future<T> showCupertinoModalBottomSheet<T>({ | 277 | static Future<T> showCupertinoModalBottomSheet<T>({ |
| 262 | @required BuildContext context, | 278 | @required BuildContext context, |
| 263 | @required ScrollWidgetBuilder builder, | 279 | @required ScrollWidgetBuilder builder, |
| 280 | + Curve routeAnimationCurve, | ||
| 281 | + Curve modalAnimationCurve, | ||
| 264 | Color backgroundColor, | 282 | Color backgroundColor, |
| 265 | Color barrierColor, | 283 | Color barrierColor, |
| 266 | bool expand = false, | 284 | bool expand = false, |
| @@ -295,6 +313,8 @@ class CupertinoScaffold extends StatefulWidget { | @@ -295,6 +313,8 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 295 | isDismissible: isDismissible ?? expand == false ? true : false, | 313 | isDismissible: isDismissible ?? expand == false ? true : false, |
| 296 | modalBarrierColor: barrierColor ?? Colors.black12, | 314 | modalBarrierColor: barrierColor ?? Colors.black12, |
| 297 | enableDrag: enableDrag, | 315 | enableDrag: enableDrag, |
| 316 | + routeAnimationCurve: routeAnimationCurve, | ||
| 317 | + modalAnimationCurve: modalAnimationCurve, | ||
| 298 | )); | 318 | )); |
| 299 | return result; | 319 | return result; |
| 300 | } | 320 | } |
-
Please register or login to post a comment