Jaime Blasco

Add transitionBackgroundColor

Allow to customize backaground color behind all views animated by CupertinoModalBottomSheetRoute
... ... @@ -84,6 +84,7 @@ Future<T> showCupertinoModalBottomSheet<T>({
Radius topRadius = _default_top_radius,
Duration duration,
RouteSettings settings,
Color transitionBackgroundColor,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -121,6 +122,7 @@ Future<T> showCupertinoModalBottomSheet<T>({
previousRouteAnimationCurve: previousRouteAnimationCurve,
duration: duration,
settings: settings,
transitionBackgroundColor: transitionBackgroundColor ?? Colors.black
));
return result;
}
... ... @@ -129,6 +131,10 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
final Radius topRadius;
final Curve previousRouteAnimationCurve;
// Background color behind all routes
// Black by default
final Color transitionBackgroundColor;
CupertinoModalBottomSheetRoute({
ScrollWidgetBuilder builder,
WidgetWithChildBuilder containerBuilder,
... ... @@ -145,6 +151,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
@required bool expanded,
Duration duration,
RouteSettings settings,
this.transitionBackgroundColor,
this.topRadius = _default_top_radius,
this.previousRouteAnimationCurve,
}) : assert(expanded != null),
... ... @@ -199,6 +206,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
body: child,
animationCurve: previousRouteAnimationCurve,
topRadius: topRadius,
backgroundColor: transitionBackgroundColor ?? Colors.black,
);
}
}
... ... @@ -207,6 +215,7 @@ class _CupertinoModalTransition extends StatelessWidget {
final Animation<double> secondaryAnimation;
final Radius topRadius;
final Curve animationCurve;
final Color backgroundColor;
final Widget body;
... ... @@ -215,6 +224,7 @@ class _CupertinoModalTransition extends StatelessWidget {
@required this.secondaryAnimation,
@required this.body,
@required this.topRadius,
this.backgroundColor = Colors.black,
this.animationCurve,
}) : super(key: key);
... ... @@ -246,7 +256,7 @@ class _CupertinoModalTransition extends StatelessWidget {
: (1 - progress) * startRoundCorner + progress * topRadius.x;
return Stack(
children: <Widget>[
Container(color: Colors.black),
Container(color: backgroundColor),
Transform.translate(
offset: Offset(0, yOffset),
child: Transform.scale(
... ... @@ -266,6 +276,7 @@ class _CupertinoModalTransition extends StatelessWidget {
class _CupertinoScaffold extends InheritedWidget {
final AnimationController animation;
final Radius topRadius;
@override
... ... @@ -288,10 +299,14 @@ class CupertinoScaffold extends StatefulWidget {
final Widget body;
final Radius topRadius;
final Color transitionBackgroundColor;
const CupertinoScaffold(
{Key key, this.body, this.topRadius = _default_top_radius})
: super(key: key);
const CupertinoScaffold({
Key key,
this.body,
this.topRadius = _default_top_radius,
this.transitionBackgroundColor = Colors.black,
}) : super(key: key);
@override
State<StatefulWidget> createState() => _CupertinoScaffoldState();
... ... @@ -376,6 +391,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold>
secondaryAnimation: animationController,
body: widget.body,
topRadius: widget.topRadius,
backgroundColor: widget.transitionBackgroundColor,
),
);
}
... ...
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
... ... @@ -29,6 +15,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
charcode:
dependency: transitive
description:
... ... @@ -36,27 +29,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
clock:
dependency: transitive
description:
name: collection
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
version: "1.0.1"
collection:
dependency: transitive
description:
name: convert
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.14.13"
fake_async:
dependency: transitive
description:
name: crypto
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
... ... @@ -67,20 +60,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.8"
meta:
dependency: transitive
description:
... ... @@ -94,28 +80,14 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
pedantic:
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "1.9.0"
sky_engine:
dependency: transitive
description: flutter
... ... @@ -162,7 +134,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.17"
typed_data:
dependency: transitive
description:
... ... @@ -177,13 +149,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
sdks:
dart: ">=2.6.0 <3.0.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.12.0 <2.0.0"
... ...