Showing
3 changed files
with
24 additions
and
8 deletions
| @@ -7,14 +7,15 @@ import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; | @@ -7,14 +7,15 @@ import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; | ||
| 7 | class AvatarBottomSheet extends StatelessWidget { | 7 | class AvatarBottomSheet extends StatelessWidget { |
| 8 | final Widget child; | 8 | final Widget child; |
| 9 | final Animation<double> animation; | 9 | final Animation<double> animation; |
| 10 | + final SystemUiOverlayStyle? overlayStyle; | ||
| 10 | 11 | ||
| 11 | - const AvatarBottomSheet({Key? key, required this.child, required this.animation}) | 12 | + const AvatarBottomSheet({Key? key, required this.child, required this.animation, this.overlayStyle}) |
| 12 | : super(key: key); | 13 | : super(key: key); |
| 13 | 14 | ||
| 14 | @override | 15 | @override |
| 15 | Widget build(BuildContext context) { | 16 | Widget build(BuildContext context) { |
| 16 | return AnnotatedRegion<SystemUiOverlayStyle>( | 17 | return AnnotatedRegion<SystemUiOverlayStyle>( |
| 17 | - value: SystemUiOverlayStyle.light, | 18 | + value: overlayStyle ?? SystemUiOverlayStyle.light, |
| 18 | child: Column( | 19 | child: Column( |
| 19 | mainAxisSize: MainAxisSize.min, | 20 | mainAxisSize: MainAxisSize.min, |
| 20 | crossAxisAlignment: CrossAxisAlignment.start, | 21 | crossAxisAlignment: CrossAxisAlignment.start, |
| @@ -81,6 +82,7 @@ Future<T?> showAvatarModalBottomSheet<T>({ | @@ -81,6 +82,7 @@ Future<T?> showAvatarModalBottomSheet<T>({ | ||
| 81 | bool isDismissible = true, | 82 | bool isDismissible = true, |
| 82 | bool enableDrag = true, | 83 | bool enableDrag = true, |
| 83 | Duration? duration, | 84 | Duration? duration, |
| 85 | + SystemUiOverlayStyle? overlayStyle, | ||
| 84 | }) async { | 86 | }) async { |
| 85 | assert(debugCheckHasMediaQuery(context)); | 87 | assert(debugCheckHasMediaQuery(context)); |
| 86 | assert(debugCheckHasMaterialLocalizations(context)); | 88 | assert(debugCheckHasMaterialLocalizations(context)); |
| @@ -90,6 +92,7 @@ Future<T?> showAvatarModalBottomSheet<T>({ | @@ -90,6 +92,7 @@ Future<T?> showAvatarModalBottomSheet<T>({ | ||
| 90 | containerBuilder: (_, animation, child) => AvatarBottomSheet( | 92 | containerBuilder: (_, animation, child) => AvatarBottomSheet( |
| 91 | child: child, | 93 | child: child, |
| 92 | animation: animation, | 94 | animation: animation, |
| 95 | + overlayStyle: overlayStyle, | ||
| 93 | ), | 96 | ), |
| 94 | bounce: bounce, | 97 | bounce: bounce, |
| 95 | secondAnimationController: secondAnimation, | 98 | secondAnimationController: secondAnimation, |
| @@ -14,6 +14,7 @@ class BarBottomSheet extends StatelessWidget { | @@ -14,6 +14,7 @@ class BarBottomSheet extends StatelessWidget { | ||
| 14 | final Clip? clipBehavior; | 14 | final Clip? clipBehavior; |
| 15 | final double? elevation; | 15 | final double? elevation; |
| 16 | final ShapeBorder? shape; | 16 | final ShapeBorder? shape; |
| 17 | + final SystemUiOverlayStyle? overlayStyle; | ||
| 17 | 18 | ||
| 18 | const BarBottomSheet({ | 19 | const BarBottomSheet({ |
| 19 | Key? key, | 20 | Key? key, |
| @@ -22,12 +23,13 @@ class BarBottomSheet extends StatelessWidget { | @@ -22,12 +23,13 @@ class BarBottomSheet extends StatelessWidget { | ||
| 22 | this.clipBehavior, | 23 | this.clipBehavior, |
| 23 | this.shape, | 24 | this.shape, |
| 24 | this.elevation, | 25 | this.elevation, |
| 26 | + this.overlayStyle, | ||
| 25 | }) : super(key: key); | 27 | }) : super(key: key); |
| 26 | 28 | ||
| 27 | @override | 29 | @override |
| 28 | Widget build(BuildContext context) { | 30 | Widget build(BuildContext context) { |
| 29 | return AnnotatedRegion<SystemUiOverlayStyle>( | 31 | return AnnotatedRegion<SystemUiOverlayStyle>( |
| 30 | - value: SystemUiOverlayStyle.light, | 32 | + value: overlayStyle ?? SystemUiOverlayStyle.light, |
| 31 | child: Column( | 33 | child: Column( |
| 32 | mainAxisSize: MainAxisSize.min, | 34 | mainAxisSize: MainAxisSize.min, |
| 33 | crossAxisAlignment: CrossAxisAlignment.center, | 35 | crossAxisAlignment: CrossAxisAlignment.center, |
| @@ -88,6 +90,7 @@ Future<T?> showBarModalBottomSheet<T>({ | @@ -88,6 +90,7 @@ Future<T?> showBarModalBottomSheet<T>({ | ||
| 88 | bool enableDrag = true, | 90 | bool enableDrag = true, |
| 89 | Widget? topControl, | 91 | Widget? topControl, |
| 90 | Duration? duration, | 92 | Duration? duration, |
| 93 | + SystemUiOverlayStyle? overlayStyle, | ||
| 91 | }) async { | 94 | }) async { |
| 92 | assert(debugCheckHasMediaQuery(context)); | 95 | assert(debugCheckHasMediaQuery(context)); |
| 93 | assert(debugCheckHasMaterialLocalizations(context)); | 96 | assert(debugCheckHasMaterialLocalizations(context)); |
| @@ -102,6 +105,7 @@ Future<T?> showBarModalBottomSheet<T>({ | @@ -102,6 +105,7 @@ Future<T?> showBarModalBottomSheet<T>({ | ||
| 102 | clipBehavior: clipBehavior, | 105 | clipBehavior: clipBehavior, |
| 103 | shape: shape, | 106 | shape: shape, |
| 104 | elevation: elevation, | 107 | elevation: elevation, |
| 108 | + overlayStyle: overlayStyle, | ||
| 105 | ), | 109 | ), |
| 106 | secondAnimationController: secondAnimation, | 110 | secondAnimationController: secondAnimation, |
| 107 | expanded: expand, | 111 | expanded: expand, |
| @@ -91,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | @@ -91,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | ||
| 91 | RouteSettings? settings, | 91 | RouteSettings? settings, |
| 92 | Color? transitionBackgroundColor, | 92 | Color? transitionBackgroundColor, |
| 93 | BoxShadow? shadow, | 93 | BoxShadow? shadow, |
| 94 | + SystemUiOverlayStyle? overlayStyle, | ||
| 94 | }) async { | 95 | }) async { |
| 95 | assert(debugCheckHasMediaQuery(context)); | 96 | assert(debugCheckHasMediaQuery(context)); |
| 96 | final hasMaterialLocalizations = | 97 | final hasMaterialLocalizations = |
| @@ -126,7 +127,8 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | @@ -126,7 +127,8 @@ Future<T?> showCupertinoModalBottomSheet<T>({ | ||
| 126 | previousRouteAnimationCurve: previousRouteAnimationCurve, | 127 | previousRouteAnimationCurve: previousRouteAnimationCurve, |
| 127 | duration: duration, | 128 | duration: duration, |
| 128 | settings: settings, | 129 | settings: settings, |
| 129 | - transitionBackgroundColor: transitionBackgroundColor ?? Colors.black), | 130 | + transitionBackgroundColor: transitionBackgroundColor ?? Colors.black, |
| 131 | + overlayStyle: overlayStyle), | ||
| 130 | ); | 132 | ); |
| 131 | return result; | 133 | return result; |
| 132 | } | 134 | } |
| @@ -142,6 +144,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -142,6 +144,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 142 | // Background color behind all routes | 144 | // Background color behind all routes |
| 143 | // Black by default | 145 | // Black by default |
| 144 | final Color? transitionBackgroundColor; | 146 | final Color? transitionBackgroundColor; |
| 147 | + final SystemUiOverlayStyle? overlayStyle; | ||
| 145 | 148 | ||
| 146 | CupertinoModalBottomSheetRoute({ | 149 | CupertinoModalBottomSheetRoute({ |
| 147 | required WidgetBuilder builder, | 150 | required WidgetBuilder builder, |
| @@ -165,6 +168,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -165,6 +168,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 165 | this.transitionBackgroundColor, | 168 | this.transitionBackgroundColor, |
| 166 | this.topRadius = _kDefaultTopRadius, | 169 | this.topRadius = _kDefaultTopRadius, |
| 167 | this.previousRouteAnimationCurve, | 170 | this.previousRouteAnimationCurve, |
| 171 | + this.overlayStyle, | ||
| 168 | }) : super( | 172 | }) : super( |
| 169 | closeProgressThreshold: closeProgressThreshold, | 173 | closeProgressThreshold: closeProgressThreshold, |
| 170 | scrollController: scrollController, | 174 | scrollController: scrollController, |
| @@ -217,6 +221,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | @@ -217,6 +221,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> { | ||
| 217 | animationCurve: previousRouteAnimationCurve, | 221 | animationCurve: previousRouteAnimationCurve, |
| 218 | topRadius: topRadius, | 222 | topRadius: topRadius, |
| 219 | backgroundColor: transitionBackgroundColor ?? Colors.black, | 223 | backgroundColor: transitionBackgroundColor ?? Colors.black, |
| 224 | + overlayStyle: overlayStyle, | ||
| 220 | ); | 225 | ); |
| 221 | } | 226 | } |
| 222 | } | 227 | } |
| @@ -227,6 +232,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -227,6 +232,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
| 227 | final Curve? animationCurve; | 232 | final Curve? animationCurve; |
| 228 | final Color backgroundColor; | 233 | final Color backgroundColor; |
| 229 | final BoxShadow? boxShadow; | 234 | final BoxShadow? boxShadow; |
| 235 | + final SystemUiOverlayStyle? overlayStyle; | ||
| 230 | 236 | ||
| 231 | final Widget body; | 237 | final Widget body; |
| 232 | 238 | ||
| @@ -238,6 +244,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -238,6 +244,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
| 238 | this.backgroundColor = Colors.black, | 244 | this.backgroundColor = Colors.black, |
| 239 | this.animationCurve, | 245 | this.animationCurve, |
| 240 | this.boxShadow, | 246 | this.boxShadow, |
| 247 | + this.overlayStyle, | ||
| 241 | }) : super(key: key); | 248 | }) : super(key: key); |
| 242 | 249 | ||
| 243 | @override | 250 | @override |
| @@ -255,10 +262,7 @@ class _CupertinoModalTransition extends StatelessWidget { | @@ -255,10 +262,7 @@ class _CupertinoModalTransition extends StatelessWidget { | ||
| 255 | ); | 262 | ); |
| 256 | 263 | ||
| 257 | return AnnotatedRegion<SystemUiOverlayStyle>( | 264 | return AnnotatedRegion<SystemUiOverlayStyle>( |
| 258 | - value: SystemUiOverlayStyle( | ||
| 259 | - statusBarIconBrightness: Brightness.light, | ||
| 260 | - statusBarBrightness: Brightness.dark, | ||
| 261 | - ), | 265 | + value: overlayStyle ?? SystemUiOverlayStyle.light, |
| 262 | child: AnimatedBuilder( | 266 | child: AnimatedBuilder( |
| 263 | animation: curvedAnimation, | 267 | animation: curvedAnimation, |
| 264 | child: body, | 268 | child: body, |
| @@ -319,12 +323,14 @@ class CupertinoScaffold extends StatefulWidget { | @@ -319,12 +323,14 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 319 | final Widget body; | 323 | final Widget body; |
| 320 | final Radius topRadius; | 324 | final Radius topRadius; |
| 321 | final Color transitionBackgroundColor; | 325 | final Color transitionBackgroundColor; |
| 326 | + final SystemUiOverlayStyle? overlayStyle; | ||
| 322 | 327 | ||
| 323 | const CupertinoScaffold({ | 328 | const CupertinoScaffold({ |
| 324 | Key? key, | 329 | Key? key, |
| 325 | required this.body, | 330 | required this.body, |
| 326 | this.topRadius = _kDefaultTopRadius, | 331 | this.topRadius = _kDefaultTopRadius, |
| 327 | this.transitionBackgroundColor = Colors.black, | 332 | this.transitionBackgroundColor = Colors.black, |
| 333 | + this.overlayStyle, | ||
| 328 | }) : super(key: key); | 334 | }) : super(key: key); |
| 329 | 335 | ||
| 330 | @override | 336 | @override |
| @@ -346,6 +352,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -346,6 +352,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 346 | Duration? duration, | 352 | Duration? duration, |
| 347 | RouteSettings? settings, | 353 | RouteSettings? settings, |
| 348 | BoxShadow? shadow, | 354 | BoxShadow? shadow, |
| 355 | + SystemUiOverlayStyle? overlayStyle, | ||
| 349 | }) async { | 356 | }) async { |
| 350 | assert(debugCheckHasMediaQuery(context)); | 357 | assert(debugCheckHasMediaQuery(context)); |
| 351 | final isCupertinoApp = | 358 | final isCupertinoApp = |
| @@ -378,6 +385,7 @@ class CupertinoScaffold extends StatefulWidget { | @@ -378,6 +385,7 @@ class CupertinoScaffold extends StatefulWidget { | ||
| 378 | previousRouteAnimationCurve: previousRouteAnimationCurve, | 385 | previousRouteAnimationCurve: previousRouteAnimationCurve, |
| 379 | duration: duration, | 386 | duration: duration, |
| 380 | settings: settings, | 387 | settings: settings, |
| 388 | + overlayStyle: overlayStyle, | ||
| 381 | )); | 389 | )); |
| 382 | return result; | 390 | return result; |
| 383 | } | 391 | } |
| @@ -409,6 +417,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold> | @@ -409,6 +417,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold> | ||
| 409 | body: widget.body, | 417 | body: widget.body, |
| 410 | topRadius: widget.topRadius, | 418 | topRadius: widget.topRadius, |
| 411 | backgroundColor: widget.transitionBackgroundColor, | 419 | backgroundColor: widget.transitionBackgroundColor, |
| 420 | + overlayStyle: widget.overlayStyle, | ||
| 412 | ), | 421 | ), |
| 413 | ); | 422 | ); |
| 414 | } | 423 | } |
-
Please register or login to post a comment