Dendos

allow to pass closeProgressThreshold double to showModat methods

... ... @@ -18,8 +18,8 @@ const Curve _decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0);
const Curve _modalBottomSheetCurve = _decelerateEasing;
const Duration _bottomSheetDuration = Duration(milliseconds: 400);
const double _minFlingVelocity = 500.0;
const double _closeProgressThreshold = 0.6;
const double _willPopThreshold = 2;
const double _closeProgressThreshold = 0.8;
const double _willPopThreshold = 0.8;
typedef ScrollWidgetBuilder = Widget Function(
BuildContext context, ScrollController controller);
... ... @@ -42,6 +42,7 @@ class ModalBottomSheet extends StatefulWidget {
/// Creates a bottom sheet.
const ModalBottomSheet({
Key key,
this.closeProgressThreshold = _closeProgressThreshold,
this.animationController,
this.animationCurve,
this.enableDrag = true,
... ... @@ -57,6 +58,8 @@ class ModalBottomSheet extends StatefulWidget {
assert(builder != null),
super(key: key);
final double closeProgressThreshold;
/// The animation controller that controls the bottom sheet's entrance and
/// exit animations.
///
... ... @@ -152,7 +155,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
widget.animationController.value < _willPopThreshold;
bool get hasReachedCloseThreshold =>
widget.animationController.value < _closeProgressThreshold;
widget.animationController.value < widget.closeProgressThreshold;
void _close() {
isDragging = false;
... ...
... ... @@ -11,6 +11,7 @@ const Duration _bottomSheetDuration = Duration(milliseconds: 400);
class _ModalBottomSheet<T> extends StatefulWidget {
const _ModalBottomSheet({
Key key,
this.closeProgressThreshold,
this.route,
this.secondAnimationController,
this.bounce = false,
... ... @@ -22,6 +23,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
assert(enableDrag != null),
super(key: key);
final double closeProgressThreshold;
final ModalBottomSheetRoute<T> route;
final bool expanded;
final bool bounce;
... ... @@ -85,6 +87,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
label: _getRouteLabel(),
explicitChildNodes: true,
child: ModalBottomSheet(
closeProgressThreshold: widget.closeProgressThreshold,
expanded: widget.route.expanded,
containerBuilder: widget.route.containerBuilder,
animationController: widget.route._animationController,
... ... @@ -113,6 +116,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
class ModalBottomSheetRoute<T> extends PopupRoute<T> {
ModalBottomSheetRoute({
this.closeProgressThreshold,
this.containerBuilder,
this.builder,
this.scrollController,
... ... @@ -131,6 +135,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
assert(enableDrag != null),
super(settings: settings);
final double closeProgressThreshold;
final WidgetWithChildBuilder containerBuilder;
final ScrollWidgetBuilder builder;
final bool expanded;
... ... @@ -180,6 +185,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
context: context,
// removeTop: true,
child: _ModalBottomSheet<T>(
closeProgressThreshold: closeProgressThreshold,
route: this,
secondAnimationController: secondAnimationController,
expanded: expanded,
... ...
... ... @@ -75,6 +75,7 @@ Future<T> showBarModalBottomSheet<T>({
Color backgroundColor,
double elevation,
ShapeBorder shape,
double closeProgressThreshold,
Clip clipBehavior,
Color barrierColor = Colors.black87,
bool bounce = true,
... ... @@ -99,6 +100,7 @@ Future<T> showBarModalBottomSheet<T>({
.push(ModalBottomSheetRoute<T>(
builder: builder,
bounce: bounce,
closeProgressThreshold: closeProgressThreshold,
containerBuilder: (_, __, child) => BarBottomSheet(
child: child,
control: topControl,
... ...
... ... @@ -6,6 +6,7 @@ import 'dart:async';
Future<T> showMaterialModalBottomSheet<T>({
@required BuildContext context,
@required ScrollWidgetBuilder builder,
double closeProgressThreshold,
Color backgroundColor,
double elevation,
ShapeBorder shape,
... ... @@ -31,6 +32,7 @@ Future<T> showMaterialModalBottomSheet<T>({
final result = await Navigator.of(context, rootNavigator: useRootNavigator)
.push(ModalBottomSheetRoute<T>(
builder: builder,
closeProgressThreshold: closeProgressThreshold,
containerBuilder: _materialContainerBuilder(
context,
backgroundColor: backgroundColor,
... ...