Committed by
GitHub
Merge pull request #121 from steve-cahn/add_boxShadow_customization
added shadow parameter to showCupertinoModalBottomSheet
Showing
1 changed file
with
13 additions
and
3 deletions
@@ -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,9 +33,10 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -32,9 +33,10 @@ 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, this.child, this.backgroundColor, @required this.topRadius}) | 39 | + {Key key, this.child, this.backgroundColor, @required this.topRadius, this.shadow}) |
38 | : super(key: key); | 40 | : super(key: key); |
39 | 41 | ||
40 | @override | 42 | @override |
@@ -42,7 +44,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -42,7 +44,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | ||
42 | final topSafeAreaPadding = MediaQuery.of(context).padding.top; | 44 | final topSafeAreaPadding = MediaQuery.of(context).padding.top; |
43 | final topPadding = _behind_widget_visible_height + topSafeAreaPadding; | 45 | final topPadding = _behind_widget_visible_height + topSafeAreaPadding; |
44 | 46 | ||
45 | - final shadow = | 47 | + final _shadow = shadow ?? _default_box_shadow; |
46 | BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5); | 48 | BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5); |
47 | final _backgroundColor = | 49 | final _backgroundColor = |
48 | backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor; | 50 | backgroundColor ?? CupertinoTheme.of(context).scaffoldBackgroundColor; |
@@ -52,7 +54,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | @@ -52,7 +54,7 @@ class _CupertinoBottomSheetContainer extends StatelessWidget { | ||
52 | borderRadius: BorderRadius.vertical(top: topRadius), | 54 | borderRadius: BorderRadius.vertical(top: topRadius), |
53 | child: Container( | 55 | child: Container( |
54 | decoration: | 56 | decoration: |
55 | - BoxDecoration(color: _backgroundColor, boxShadow: [shadow]), | 57 | + BoxDecoration(color: _backgroundColor, boxShadow: [_shadow]), |
56 | width: double.infinity, | 58 | width: double.infinity, |
57 | child: MediaQuery.removePadding( | 59 | child: MediaQuery.removePadding( |
58 | context: context, | 60 | context: context, |
@@ -86,6 +88,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -86,6 +88,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
86 | Duration duration, | 88 | Duration duration, |
87 | RouteSettings settings, | 89 | RouteSettings settings, |
88 | Color transitionBackgroundColor, | 90 | Color transitionBackgroundColor, |
91 | + BoxShadow shadow, | ||
89 | }) async { | 92 | }) async { |
90 | assert(context != null); | 93 | assert(context != null); |
91 | assert(builder != null); | 94 | assert(builder != null); |
@@ -108,6 +111,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -108,6 +111,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
108 | child: child, | 111 | child: child, |
109 | backgroundColor: backgroundColor, | 112 | backgroundColor: backgroundColor, |
110 | topRadius: topRadius, | 113 | topRadius: topRadius, |
114 | + shadow: shadow, | ||
111 | ), | 115 | ), |
112 | secondAnimationController: secondAnimation, | 116 | secondAnimationController: secondAnimation, |
113 | expanded: expand, | 117 | expanded: expand, |
@@ -133,6 +137,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | @@ -133,6 +137,7 @@ Future<T> showCupertinoModalBottomSheet<T>({ | ||
133 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | 137 | class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { |
134 | final Radius topRadius; | 138 | final Radius topRadius; |
135 | final Curve previousRouteAnimationCurve; | 139 | final Curve previousRouteAnimationCurve; |
140 | + final BoxShadow boxShadow; | ||
136 | 141 | ||
137 | // Background color behind all routes | 142 | // Background color behind all routes |
138 | // Black by default | 143 | // Black by default |
@@ -156,6 +161,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -156,6 +161,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
156 | Duration duration, | 161 | Duration duration, |
157 | RouteSettings settings, | 162 | RouteSettings settings, |
158 | ScrollController scrollController, | 163 | ScrollController scrollController, |
164 | + this.boxShadow = _default_box_shadow, | ||
159 | this.transitionBackgroundColor, | 165 | this.transitionBackgroundColor, |
160 | this.topRadius = _default_top_radius, | 166 | this.topRadius = _default_top_radius, |
161 | this.previousRouteAnimationCurve, | 167 | this.previousRouteAnimationCurve, |
@@ -223,6 +229,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -223,6 +229,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
223 | final Radius topRadius; | 229 | final Radius topRadius; |
224 | final Curve animationCurve; | 230 | final Curve animationCurve; |
225 | final Color backgroundColor; | 231 | final Color backgroundColor; |
232 | + final BoxShadow boxShadow; | ||
226 | 233 | ||
227 | final Widget body; | 234 | final Widget body; |
228 | 235 | ||
@@ -233,6 +240,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -233,6 +240,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
233 | @required this.topRadius, | 240 | @required this.topRadius, |
234 | this.backgroundColor = Colors.black, | 241 | this.backgroundColor = Colors.black, |
235 | this.animationCurve, | 242 | this.animationCurve, |
243 | + this.boxShadow, | ||
236 | }) : super(key: key); | 244 | }) : super(key: key); |
237 | 245 | ||
238 | @override | 246 | @override |
@@ -334,6 +342,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -334,6 +342,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
334 | bool enableDrag = true, | 342 | bool enableDrag = true, |
335 | Duration duration, | 343 | Duration duration, |
336 | RouteSettings settings, | 344 | RouteSettings settings, |
345 | + BoxShadow shadow, | ||
337 | }) async { | 346 | }) async { |
338 | assert(context != null); | 347 | assert(context != null); |
339 | assert(builder != null); | 348 | assert(builder != null); |
@@ -358,6 +367,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -358,6 +367,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
358 | child: child, | 367 | child: child, |
359 | backgroundColor: backgroundColor, | 368 | backgroundColor: backgroundColor, |
360 | topRadius: topRadius, | 369 | topRadius: topRadius, |
370 | + shadow: shadow, | ||
361 | ), | 371 | ), |
362 | expanded: expand, | 372 | expanded: expand, |
363 | barrierLabel: barrierLabel, | 373 | barrierLabel: barrierLabel, |
-
Please register or login to post a comment