Merge branch 'master' of https://github.com/jamesblasco/modal_bottom_sheet
Showing
2 changed files
with
19 additions
and
3 deletions
@@ -97,6 +97,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { | @@ -97,6 +97,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { | ||
97 | label: _getRouteLabel(), | 97 | label: _getRouteLabel(), |
98 | explicitChildNodes: true, | 98 | explicitChildNodes: true, |
99 | child: ModalBottomSheet( | 99 | child: ModalBottomSheet( |
100 | + closeProgressThreshold: widget.closeProgressThreshold, | ||
100 | expanded: widget.route.expanded, | 101 | expanded: widget.route.expanded, |
101 | containerBuilder: widget.route.containerBuilder, | 102 | containerBuilder: widget.route.containerBuilder, |
102 | animationController: widget.route._animationController!, | 103 | animationController: widget.route._animationController!, |
@@ -22,6 +22,7 @@ import '../bottom_sheet_route.dart'; | @@ -22,6 +22,7 @@ import '../bottom_sheet_route.dart'; | ||
22 | const double _behind_widget_visible_height = 10; | 22 | const double _behind_widget_visible_height = 10; |
23 | 23 | ||
24 | const Radius _default_top_radius = Radius.circular(12); | 24 | const Radius _default_top_radius = Radius.circular(12); |
25 | +const BoxShadow _default_box_shadow = BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5); | ||
25 | 26 | ||
26 | /// Cupertino Bottom Sheet Container | 27 | /// Cupertino Bottom Sheet Container |
27 | /// | 28 | /// |
@@ -32,20 +33,23 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -32,20 +33,23 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | ||
32 | final Widget child; | 33 | final Widget child; |
33 | final Color? backgroundColor; | 34 | final Color? backgroundColor; |
34 | final Radius topRadius; | 35 | final Radius topRadius; |
36 | + final BoxShadow? shadow; | ||
35 | 37 | ||
36 | const _CupertinoBottomSheetContainer({ | 38 | const _CupertinoBottomSheetContainer({ |
37 | Key? key, | 39 | Key? key, |
38 | required this.child, | 40 | required this.child, |
39 | this.backgroundColor, | 41 | this.backgroundColor, |
40 | required this.topRadius, | 42 | required this.topRadius, |
43 | + this.shadow, | ||
41 | }) : super(key: key); | 44 | }) : super(key: key); |
42 | 45 | ||
46 | + | ||
43 | @override | 47 | @override |
44 | Widget build(BuildContext context) { | 48 | Widget build(BuildContext context) { |
45 | final topSafeAreaPadding = MediaQuery.of(context).padding.top; | 49 | final topSafeAreaPadding = MediaQuery.of(context).padding.top; |
46 | final topPadding = _behind_widget_visible_height + topSafeAreaPadding; | 50 | final topPadding = _behind_widget_visible_height + topSafeAreaPadding; |
47 | 51 | ||
48 | - final shadow = | 52 | + final _shadow = shadow ?? _default_box_shadow; |
49 | BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5); | 53 | BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5); |
50 | final _backgroundColor = | 54 | final _backgroundColor = |
51 | backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor; | 55 | backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor; |
@@ -55,7 +59,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -55,7 +59,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | ||
55 | borderRadius: BorderRadius.vertical(top: topRadius), | 59 | borderRadius: BorderRadius.vertical(top: topRadius), |
56 | child: Container( | 60 | child: Container( |
57 | decoration: | 61 | decoration: |
58 | - BoxDecoration(color: _backgroundColor, boxShadow: [shadow]), | 62 | + BoxDecoration(color: _backgroundColor, boxShadow: [_shadow]), |
59 | width: double.infinity, | 63 | width: double.infinity, |
60 | child: MediaQuery.removePadding( | 64 | child: MediaQuery.removePadding( |
61 | context: context, | 65 | context: context, |
@@ -89,6 +93,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | @@ -89,6 +93,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | ||
89 | Duration? duration, | 93 | Duration? duration, |
90 | RouteSettings? settings, | 94 | RouteSettings? settings, |
91 | Color? transitionBackgroundColor, | 95 | Color? transitionBackgroundColor, |
96 | + BoxShadow? shadow, | ||
92 | }) async { | 97 | }) async { |
93 | assert(context != null); | 98 | assert(context != null); |
94 | assert(builder != null); | 99 | assert(builder != null); |
@@ -111,6 +116,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | @@ -111,6 +116,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | ||
111 | child: child, | 116 | child: child, |
112 | backgroundColor: backgroundColor, | 117 | backgroundColor: backgroundColor, |
113 | topRadius: topRadius, | 118 | topRadius: topRadius, |
119 | + shadow: shadow, | ||
114 | ), | 120 | ), |
115 | secondAnimationController: secondAnimation, | 121 | secondAnimationController: secondAnimation, |
116 | expanded: expand, | 122 | expanded: expand, |
@@ -135,8 +141,12 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | @@ -135,8 +141,12 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | ||
135 | 141 | ||
136 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | 142 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { |
137 | final Radius topRadius; | 143 | final Radius topRadius; |
144 | + | ||
138 | final Curve? previousRouteAnimationCurve; | 145 | final Curve? previousRouteAnimationCurve; |
139 | 146 | ||
147 | + | ||
148 | + final BoxShadow? boxShadow; | ||
149 | + | ||
140 | // Background color behind all routes | 150 | // Background color behind all routes |
141 | // Black by default | 151 | // Black by default |
142 | final Color? transitionBackgroundColor; | 152 | final Color? transitionBackgroundColor; |
@@ -159,6 +169,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -159,6 +169,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
159 | Duration? duration, | 169 | Duration? duration, |
160 | RouteSettings? settings, | 170 | RouteSettings? settings, |
161 | ScrollController? scrollController, | 171 | ScrollController? scrollController, |
172 | + this.boxShadow = _default_box_shadow, | ||
162 | this.transitionBackgroundColor, | 173 | this.transitionBackgroundColor, |
163 | this.topRadius = _default_top_radius, | 174 | this.topRadius = _default_top_radius, |
164 | this.previousRouteAnimationCurve, | 175 | this.previousRouteAnimationCurve, |
@@ -226,6 +237,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -226,6 +237,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
226 | final Radius topRadius; | 237 | final Radius topRadius; |
227 | final Curve? animationCurve; | 238 | final Curve? animationCurve; |
228 | final Color backgroundColor; | 239 | final Color backgroundColor; |
240 | + final BoxShadow? boxShadow; | ||
229 | 241 | ||
230 | final Widget body; | 242 | final Widget body; |
231 | 243 | ||
@@ -236,6 +248,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -236,6 +248,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
236 | required this.topRadius, | 248 | required this.topRadius, |
237 | this.backgroundColor = Colors.black, | 249 | this.backgroundColor = Colors.black, |
238 | this.animationCurve, | 250 | this.animationCurve, |
251 | + this.boxShadow, | ||
239 | }) : super(key: key); | 252 | }) : super(key: key); |
240 | 253 | ||
241 | @override | 254 | @override |
@@ -340,6 +353,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -340,6 +353,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
340 | bool enableDrag = true, | 353 | bool enableDrag = true, |
341 | Duration? duration, | 354 | Duration? duration, |
342 | RouteSettings? settings, | 355 | RouteSettings? settings, |
356 | + BoxShadow? shadow, | ||
343 | }) async { | 357 | }) async { |
344 | assert(context != null); | 358 | assert(context != null); |
345 | assert(builder != null); | 359 | assert(builder != null); |
@@ -363,7 +377,8 @@ class CupertinoScaffold extends StatefulWidget { | @@ -363,7 +377,8 @@ class CupertinoScaffold extends StatefulWidget { | ||
363 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( | 377 | containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer( |
364 | child: child, | 378 | child: child, |
365 | backgroundColor: backgroundColor, | 379 | backgroundColor: backgroundColor, |
366 | - topRadius: _default_top_radius, | 380 | + topRadius: topRadius ?? _default_top_radius, |
381 | + shadow: shadow, | ||
367 | ), | 382 | ), |
368 | expanded: expand, | 383 | expanded: expand, |
369 | barrierLabel: barrierLabel, | 384 | barrierLabel: barrierLabel, |
-
Please register or login to post a comment