Rodinei Fagundes

Merge branch 'master' of github.com:jamesblasco/modal_bottom_sheet

... ... @@ -49,6 +49,7 @@ Also it supports `WillPopScope` to prevent closing the dialog
|bool enableDrag = true| The `enableDrag` parameter specifies whether the bottom sheet can be dragged up and down and dismissed by swiping downwards. |
|AnimationController secondAnimation| The `secondAnimation` parameter allows you to provide an animation controller that will be used to animate push/pop of the modal route. Using this param is advised against and will be probably removed in future versions |
|bool bounce = false| The `bounce` parameter specifies if the bottom sheet can go beyond the top boundary while dragging |
|Duration duration = const Duration(milliseconds: 400)| The `duration` of modal opening |
#### Material params
... ...
... ... @@ -81,6 +81,7 @@ Future<T> showAvatarModalBottomSheet<T>({
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -104,6 +105,7 @@ Future<T> showAvatarModalBottomSheet<T>({
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
duration: duration,
));
return result;
}
... ...
... ... @@ -7,42 +7,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
... ... @@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
cupertino_icons:
dependency: "direct main"
description:
... ... @@ -85,7 +85,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
matcher:
dependency: transitive
description:
... ... @@ -106,7 +106,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.4"
version: "0.1.5"
path:
dependency: transitive
description:
... ... @@ -114,13 +114,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0+1"
petitparser:
dependency: transitive
description:
... ... @@ -141,7 +134,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
... ... @@ -153,7 +146,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
... ... @@ -188,7 +181,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
... ... @@ -237,7 +230,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.7.0 <3.0.0"
flutter: ">=1.12.8 <2.0.0"
... ...
... ... @@ -38,6 +38,7 @@ class ModalBottomSheet extends StatefulWidget {
const ModalBottomSheet({
Key key,
this.animationController,
this.animationCurve,
this.enableDrag = true,
this.containerBuilder,
this.bounce = true,
... ... @@ -58,6 +59,11 @@ class ModalBottomSheet extends StatefulWidget {
/// is not just a passive observer.
final AnimationController animationController;
/// The curve used by the animation showing and dismissing the bottom sheet.
///
/// If no curve is provided it falls back to `Curves.easeOutSine`.
final Curve animationCurve;
/// Allows the bottom sheet to go beyond the top bound of the content,
/// but then bounce the content back to the edge of
/// the top bound.
... ... @@ -102,9 +108,12 @@ class ModalBottomSheet extends StatefulWidget {
/// This API available as a convenience for a Material compliant bottom sheet
/// animation. If alternative animation durations are required, a different
/// animation controller could be provided.
static AnimationController createAnimationController(TickerProvider vsync) {
static AnimationController createAnimationController(
TickerProvider vsync, {
Duration duration,
}) {
return AnimationController(
duration: _bottomSheetDuration,
duration: duration ?? _bottomSheetDuration,
debugLabel: 'BottomSheet',
vsync: vsync,
);
... ... @@ -276,7 +285,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
Widget build(BuildContext context) {
final bounceAnimation = CurvedAnimation(
parent: _bounceDragController,
curve: Curves.easeOutSine,
curve: widget.animationCurve ?? Curves.easeOutSine,
);
var child = widget.builder(context, _scrollController);
... ...
... ... @@ -17,6 +17,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
this.scrollController,
this.expanded = false,
this.enableDrag = true,
this.animationCurve,
}) : assert(expanded != null),
assert(enableDrag != null),
super(key: key);
... ... @@ -26,6 +27,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
final bool bounce;
final bool enableDrag;
final AnimationController secondAnimationController;
final Curve animationCurve;
final ScrollController scrollController;
@override
... ... @@ -97,6 +99,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
builder: widget.route.builder,
enableDrag: widget.enableDrag,
bounce: widget.bounce,
animationCurve: widget.animationCurve,
),
);
},
... ... @@ -116,6 +119,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
this.enableDrag = true,
@required this.expanded,
this.bounce = false,
this.animationCurve,
this.duration,
RouteSettings settings,
}) : assert(expanded != null),
assert(isDismissible != null),
... ... @@ -131,10 +136,13 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
final bool enableDrag;
final ScrollController scrollController;
final Duration duration;
final AnimationController secondAnimationController;
final Curve animationCurve;
@override
Duration get transitionDuration => _bottomSheetDuration;
Duration get transitionDuration => duration ?? _bottomSheetDuration;
@override
bool get barrierDismissible => isDismissible;
... ... @@ -150,8 +158,10 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
@override
AnimationController createAnimationController() {
assert(_animationController == null);
_animationController =
ModalBottomSheet.createAnimationController(navigator.overlay);
_animationController = ModalBottomSheet.createAnimationController(
navigator.overlay,
duration: duration,
);
return _animationController;
}
... ... @@ -172,6 +182,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
scrollController: scrollController,
bounce: bounce,
enableDrag: enableDrag,
animationCurve: animationCurve,
),
);
return bottomSheet;
... ... @@ -195,8 +206,8 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
}
/// Shows a modal material design bottom sheet.
Future<T> showCustomModalBottomSheet<T>(
{@required BuildContext context,
Future<T> showCustomModalBottomSheet<T>({
@required BuildContext context,
@required ScrollWidgetBuilder builder,
@required WidgetWithChildBuilder containerWidget,
Color backgroundColor,
... ... @@ -207,10 +218,13 @@ Future<T> showCustomModalBottomSheet<T>(
bool bounce = false,
bool expand = false,
AnimationController secondAnimation,
Curve animationCurve,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
ScrollController scrollController}) async {
ScrollController scrollController,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
assert(containerWidget != null);
... ... @@ -231,6 +245,8 @@ Future<T> showCustomModalBottomSheet<T>(
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
animationCurve: animationCurve,
duration: duration,
));
return result;
}
... ...
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';
import '../../modal_bottom_sheet.dart';
import '../bottom_sheet_route.dart';
... ... @@ -9,6 +10,7 @@ class BarBottomSheet extends StatelessWidget {
final Widget child;
const BarBottomSheet({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
... ... @@ -66,9 +68,11 @@ Future<T> showBarModalBottomSheet<T>({
bool bounce = true,
bool expand = false,
AnimationController secondAnimation,
Curve animationCurve,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -91,6 +95,8 @@ Future<T> showBarModalBottomSheet<T>({
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
animationCurve: animationCurve,
duration: duration,
));
return result;
}
... ...
... ... @@ -75,11 +75,14 @@ Future<T> showCupertinoModalBottomSheet<T>({
Color barrierColor,
bool expand = false,
AnimationController secondAnimation,
Curve animationCurve,
Curve previousRouteAnimationCurve,
bool useRootNavigator = false,
bool bounce = true,
bool isDismissible,
bool enableDrag = true,
Radius topRadius = _default_top_radius,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -113,12 +116,16 @@ Future<T> showCupertinoModalBottomSheet<T>({
modalBarrierColor: barrierColor ?? Colors.black12,
enableDrag: enableDrag,
topRadius: topRadius,
animationCurve: animationCurve,
previousRouteAnimationCurve: previousRouteAnimationCurve,
duration: duration,
));
return result;
}
class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
final Radius topRadius;
final Curve previousRouteAnimationCurve;
CupertinoModalBottomSheetRoute({
ScrollWidgetBuilder builder,
... ... @@ -128,13 +135,16 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
ShapeBorder shape,
Clip clipBehavior,
AnimationController secondAnimationController,
Curve animationCurve,
Color modalBarrierColor,
bool bounce = true,
bool isDismissible = true,
bool enableDrag = true,
@required bool expanded,
Duration duration,
RouteSettings settings,
this.topRadius = _default_top_radius,
this.previousRouteAnimationCurve,
}) : assert(expanded != null),
assert(isDismissible != null),
assert(enableDrag != null),
... ... @@ -149,6 +159,8 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
enableDrag: enableDrag,
expanded: expanded,
settings: settings,
animationCurve: animationCurve,
duration: duration,
);
@override
... ... @@ -183,6 +195,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
return _CupertinoModalTransition(
secondaryAnimation: secondaryAnimation,
body: child,
animationCurve: previousRouteAnimationCurve,
topRadius: topRadius,
);
}
... ... @@ -191,6 +204,7 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
class _CupertinoModalTransition extends StatelessWidget {
final Animation<double> secondaryAnimation;
final Radius topRadius;
final Curve animationCurve;
final Widget body;
... ... @@ -199,6 +213,7 @@ class _CupertinoModalTransition extends StatelessWidget {
@required this.secondaryAnimation,
@required this.body,
@required this.topRadius,
this.animationCurve,
}) : super(key: key);
@override
... ... @@ -212,7 +227,7 @@ class _CupertinoModalTransition extends StatelessWidget {
final curvedAnimation = CurvedAnimation(
parent: secondaryAnimation,
curve: Curves.easeOut,
curve: animationCurve ?? Curves.easeOut,
);
return AnnotatedRegion<SystemUiOverlayStyle>(
... ... @@ -280,6 +295,8 @@ class CupertinoScaffold extends StatefulWidget {
static Future<T> showCupertinoModalBottomSheet<T>({
@required BuildContext context,
@required ScrollWidgetBuilder builder,
Curve animationCurve,
Curve previousRouteAnimationCurve,
Color backgroundColor,
Color barrierColor,
bool expand = false,
... ... @@ -288,6 +305,7 @@ class CupertinoScaffold extends StatefulWidget {
bool isDismissible,
bool enableDrag = true,
Radius topRadius = _default_top_radius,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -317,6 +335,9 @@ class CupertinoScaffold extends StatefulWidget {
modalBarrierColor: barrierColor ?? Colors.black12,
enableDrag: enableDrag,
topRadius: topRadius,
animationCurve: animationCurve,
previousRouteAnimationCurve: previousRouteAnimationCurve,
duration: duration,
));
return result;
}
... ...
... ... @@ -14,9 +14,11 @@ Future<T> showMaterialModalBottomSheet<T>({
bool bounce = false,
bool expand = false,
AnimationController secondAnimation,
Curve animationCurve,
bool useRootNavigator = false,
bool isDismissible = true,
bool enableDrag = true,
Duration duration,
}) async {
assert(context != null);
assert(builder != null);
... ... @@ -44,6 +46,8 @@ Future<T> showMaterialModalBottomSheet<T>({
isDismissible: isDismissible,
modalBarrierColor: barrierColor,
enableDrag: enableDrag,
animationCurve: animationCurve,
duration: duration,
));
return result;
}
... ...
... ... @@ -7,42 +7,42 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "2.4.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "2.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.1.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
convert:
dependency: transitive
description:
... ... @@ -56,7 +56,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4"
flutter:
dependency: "direct main"
description: flutter
... ... @@ -73,7 +73,7 @@ packages:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "2.1.12"
matcher:
dependency: transitive
description:
... ... @@ -115,7 +115,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
... ... @@ -127,7 +127,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
... ... @@ -162,7 +162,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.11"
version: "0.2.15"
typed_data:
dependency: transitive
description:
... ... @@ -183,7 +183,7 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.5.0"
version: "3.6.1"
sdks:
dart: ">=2.4.0 <3.0.0"
dart: ">=2.6.0 <3.0.0"
flutter: ">=1.12.0 <2.0.0"
... ...