Showing
1 changed file
with
30 additions
and
15 deletions
| @@ -21,10 +21,7 @@ import '../bottom_sheet_route.dart'; | @@ -21,10 +21,7 @@ import '../bottom_sheet_route.dart'; | ||
| 21 | 21 | ||
| 22 | const double _behind_widget_visible_height = 10; | 22 | const double _behind_widget_visible_height = 10; |
| 23 | 23 | ||
| 24 | -const BorderRadius _default_border_radius = BorderRadius.only( | ||
| 25 | - topLeft: Radius.circular(12), | ||
| 26 | - topRight: Radius.circular(12), | ||
| 27 | -); | 24 | +const Radius _default_top_radius = Radius.circular(12); |
| 28 | 25 | ||
| 29 | /// Cupertino Bottom Sheet Container | 26 | /// Cupertino Bottom Sheet Container |
| 30 | /// | 27 | /// |
| @@ -34,10 +31,10 @@ const BorderRadius _default_border_radius = BorderRadius.only( | @@ -34,10 +31,10 @@ const BorderRadius _default_border_radius = BorderRadius.only( | ||
| 34 | class _CupertinoBottomSheetContainer extends StatelessWidget { | 31 | class _CupertinoBottomSheetContainer extends StatelessWidget { |
| 35 | final Widget child; | 32 | final Widget child; |
| 36 | final Color backgroundColor; | 33 | final Color backgroundColor; |
| 37 | - final BorderRadius borderRadius; | 34 | + final Radius topRadius; |
| 38 | 35 | ||
| 39 | const _CupertinoBottomSheetContainer( | 36 | const _CupertinoBottomSheetContainer( |
| 40 | - {Key key, this.child, this.backgroundColor, this.borderRadius}) | 37 | + {Key key, this.child, this.backgroundColor, @required this.topRadius}) |
| 41 | : super(key: key); | 38 | : super(key: key); |
| 42 | 39 | ||
| 43 | @override | 40 | @override |
| @@ -52,7 +49,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -52,7 +49,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | ||
| 52 | return Padding( | 49 | return Padding( |
| 53 | padding: EdgeInsets.only(top: topPadding), | 50 | padding: EdgeInsets.only(top: topPadding), |
| 54 | child: ClipRRect( | 51 | child: ClipRRect( |
| 55 | - borderRadius: borderRadius, | 52 | + borderRadius: BorderRadius.vertical(top: topRadius), |
| 56 | child: Container( | 53 | child: Container( |
| 57 | decoration: | 54 | decoration: |
| 58 | BoxDecoration(color: _backgroundColor, boxShadow: [shadow]), | 55 | BoxDecoration(color: _backgroundColor, boxShadow: [shadow]), |
| @@ -74,7 +71,6 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -74,7 +71,6 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 74 | Color backgroundColor, | 71 | Color backgroundColor, |
| 75 | double elevation, | 72 | double elevation, |
| 76 | ShapeBorder shape, | 73 | ShapeBorder shape, |
| 77 | - BorderRadius borderRadius = _default_border_radius, | ||
| 78 | Clip clipBehavior, | 74 | Clip clipBehavior, |
| 79 | Color barrierColor, | 75 | Color barrierColor, |
| 80 | bool expand = false, | 76 | bool expand = false, |
| @@ -83,6 +79,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -83,6 +79,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 83 | bool bounce = true, | 79 | bool bounce = true, |
| 84 | bool isDismissible, | 80 | bool isDismissible, |
| 85 | bool enableDrag = true, | 81 | bool enableDrag = true, |
| 82 | + Radius topRadius = _default_top_radius, | ||
| 86 | }) async { | 83 | }) async { |
| 87 | assert(context != null); | 84 | assert(context != null); |
| 88 | assert(builder != null); | 85 | assert(builder != null); |
| @@ -103,7 +100,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -103,7 +100,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 103 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( | 100 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( |
| 104 | child: child, | 101 | child: child, |
| 105 | backgroundColor: backgroundColor, | 102 | backgroundColor: backgroundColor, |
| 106 | - borderRadius: borderRadius, | 103 | + topRadius: topRadius, |
| 107 | ), | 104 | ), |
| 108 | secondAnimationController: secondAnimation, | 105 | secondAnimationController: secondAnimation, |
| 109 | expanded: expand, | 106 | expanded: expand, |
| @@ -115,11 +112,14 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -115,11 +112,14 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
| 115 | isDismissible: isDismissible ?? expand == false ? true : false, | 112 | isDismissible: isDismissible ?? expand == false ? true : false, |
| 116 | modalBarrierColor: barrierColor ?? Colors.black12, | 113 | modalBarrierColor: barrierColor ?? Colors.black12, |
| 117 | enableDrag: enableDrag, | 114 | enableDrag: enableDrag, |
| 115 | + topRadius: topRadius, | ||
| 118 | )); | 116 | )); |
| 119 | return result; | 117 | return result; |
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | 120 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { |
| 121 | + final Radius topRadius; | ||
| 122 | + | ||
| 123 | CupertinoModalBottomSheetRoute({ | 123 | CupertinoModalBottomSheetRoute({ |
| 124 | ScrollWidgetBuilder builder, | 124 | ScrollWidgetBuilder builder, |
| 125 | WidgetWithChildBuilder containerBuilder, | 125 | WidgetWithChildBuilder containerBuilder, |
| @@ -134,6 +134,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -134,6 +134,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 134 | bool enableDrag = true, | 134 | bool enableDrag = true, |
| 135 | @required bool expanded, | 135 | @required bool expanded, |
| 136 | RouteSettings settings, | 136 | RouteSettings settings, |
| 137 | + this.topRadius = _default_top_radius, | ||
| 137 | }) : assert(expanded != null), | 138 | }) : assert(expanded != null), |
| 138 | assert(isDismissible != null), | 139 | assert(isDismissible != null), |
| 139 | assert(enableDrag != null), | 140 | assert(enableDrag != null), |
| @@ -180,18 +181,25 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -180,18 +181,25 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 180 | Widget getPreviousRouteTransition(BuildContext context, | 181 | Widget getPreviousRouteTransition(BuildContext context, |
| 181 | Animation<double> secondaryAnimation, Widget child) { | 182 | Animation<double> secondaryAnimation, Widget child) { |
| 182 | return _CupertinoModalTransition( | 183 | return _CupertinoModalTransition( |
| 183 | - secondaryAnimation: secondaryAnimation, body: child); | 184 | + secondaryAnimation: secondaryAnimation, |
| 185 | + body: child, | ||
| 186 | + topRadius: topRadius, | ||
| 187 | + ); | ||
| 184 | } | 188 | } |
| 185 | } | 189 | } |
| 186 | 190 | ||
| 187 | class _CupertinoModalTransition extends StatelessWidget { | 191 | class _CupertinoModalTransition extends StatelessWidget { |
| 188 | final Animation<double> secondaryAnimation; | 192 | final Animation<double> secondaryAnimation; |
| 193 | + final Radius topRadius; | ||
| 189 | 194 | ||
| 190 | final Widget body; | 195 | final Widget body; |
| 191 | 196 | ||
| 192 | - const _CupertinoModalTransition( | ||
| 193 | - {Key key, @required this.secondaryAnimation, @required this.body}) | ||
| 194 | - : super(key: key); | 197 | + const _CupertinoModalTransition({ |
| 198 | + Key key, | ||
| 199 | + @required this.secondaryAnimation, | ||
| 200 | + @required this.body, | ||
| 201 | + @required this.topRadius, | ||
| 202 | + }) : super(key: key); | ||
| 195 | 203 | ||
| 196 | @override | 204 | @override |
| 197 | Widget build(BuildContext context) { | 205 | Widget build(BuildContext context) { |
| @@ -218,7 +226,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -218,7 +226,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
| 218 | final scale = 1 - progress / 10; | 226 | final scale = 1 - progress / 10; |
| 219 | final radius = progress == 0 | 227 | final radius = progress == 0 |
| 220 | ? 0.0 | 228 | ? 0.0 |
| 221 | - : (1 - progress) * startRoundCorner + progress * 12; | 229 | + : (1 - progress) * startRoundCorner + progress * topRadius.x; |
| 222 | return Stack( | 230 | return Stack( |
| 223 | children: <Widget>[ | 231 | children: <Widget>[ |
| 224 | Container(color: Colors.black), | 232 | Container(color: Colors.black), |
| @@ -260,8 +268,11 @@ class CupertinoScaffold extends StatefulWidget { | @@ -260,8 +268,11 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 260 | context.dependOnInheritedWidgetOfExactType<_CupertinoScaffold>(); | 268 | context.dependOnInheritedWidgetOfExactType<_CupertinoScaffold>(); |
| 261 | 269 | ||
| 262 | final Widget body; | 270 | final Widget body; |
| 271 | + final Radius topRadius; | ||
| 263 | 272 | ||
| 264 | - const CupertinoScaffold({Key key, this.body}) : super(key: key); | 273 | + const CupertinoScaffold( |
| 274 | + {Key key, this.body, this.topRadius = _default_top_radius}) | ||
| 275 | + : super(key: key); | ||
| 265 | 276 | ||
| 266 | @override | 277 | @override |
| 267 | State<StatefulWidget> createState() => _CupertinoScaffoldState(); | 278 | State<StatefulWidget> createState() => _CupertinoScaffoldState(); |
| @@ -276,6 +287,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -276,6 +287,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 276 | bool bounce = true, | 287 | bool bounce = true, |
| 277 | bool isDismissible, | 288 | bool isDismissible, |
| 278 | bool enableDrag = true, | 289 | bool enableDrag = true, |
| 290 | + Radius topRadius = _default_top_radius, | ||
| 279 | }) async { | 291 | }) async { |
| 280 | assert(context != null); | 292 | assert(context != null); |
| 281 | assert(builder != null); | 293 | assert(builder != null); |
| @@ -296,6 +308,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -296,6 +308,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 296 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( | 308 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( |
| 297 | child: child, | 309 | child: child, |
| 298 | backgroundColor: backgroundColor, | 310 | backgroundColor: backgroundColor, |
| 311 | + topRadius: topRadius, | ||
| 299 | ), | 312 | ), |
| 300 | expanded: expand, | 313 | expanded: expand, |
| 301 | barrierLabel: barrierLabel, | 314 | barrierLabel: barrierLabel, |
| @@ -303,6 +316,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -303,6 +316,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 303 | isDismissible: isDismissible ?? expand == false ? true : false, | 316 | isDismissible: isDismissible ?? expand == false ? true : false, |
| 304 | modalBarrierColor: barrierColor ?? Colors.black12, | 317 | modalBarrierColor: barrierColor ?? Colors.black12, |
| 305 | enableDrag: enableDrag, | 318 | enableDrag: enableDrag, |
| 319 | + topRadius: topRadius, | ||
| 306 | )); | 320 | )); |
| 307 | return result; | 321 | return result; |
| 308 | } | 322 | } |
| @@ -333,6 +347,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold> | @@ -333,6 +347,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold> | ||
| 333 | child: _CupertinoModalTransition( | 347 | child: _CupertinoModalTransition( |
| 334 | secondaryAnimation: animationController, | 348 | secondaryAnimation: animationController, |
| 335 | body: widget.body, | 349 | body: widget.body, |
| 350 | + topRadius: widget.topRadius, | ||
| 336 | ), | 351 | ), |
| 337 | ); | 352 | ); |
| 338 | } | 353 | } |
-
Please register or login to post a comment