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); @@ -18,8 +18,8 @@ const Curve _decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0);
18 const Curve _modalBottomSheetCurve = _decelerateEasing; 18 const Curve _modalBottomSheetCurve = _decelerateEasing;
19 const Duration _bottomSheetDuration = Duration(milliseconds: 400); 19 const Duration _bottomSheetDuration = Duration(milliseconds: 400);
20 const double _minFlingVelocity = 500.0; 20 const double _minFlingVelocity = 500.0;
21 -const double _closeProgressThreshold = 0.6;  
22 -const double _willPopThreshold = 2; 21 +const double _closeProgressThreshold = 0.8;
  22 +const double _willPopThreshold = 0.8;
23 23
24 typedef ScrollWidgetBuilder = Widget Function( 24 typedef ScrollWidgetBuilder = Widget Function(
25 BuildContext context, ScrollController controller); 25 BuildContext context, ScrollController controller);
@@ -42,6 +42,7 @@ class ModalBottomSheet extends StatefulWidget { @@ -42,6 +42,7 @@ class ModalBottomSheet extends StatefulWidget {
42 /// Creates a bottom sheet. 42 /// Creates a bottom sheet.
43 const ModalBottomSheet({ 43 const ModalBottomSheet({
44 Key key, 44 Key key,
  45 + this.closeProgressThreshold = _closeProgressThreshold,
45 this.animationController, 46 this.animationController,
46 this.animationCurve, 47 this.animationCurve,
47 this.enableDrag = true, 48 this.enableDrag = true,
@@ -57,6 +58,8 @@ class ModalBottomSheet extends StatefulWidget { @@ -57,6 +58,8 @@ class ModalBottomSheet extends StatefulWidget {
57 assert(builder != null), 58 assert(builder != null),
58 super(key: key); 59 super(key: key);
59 60
  61 + final double closeProgressThreshold;
  62 +
60 /// The animation controller that controls the bottom sheet's entrance and 63 /// The animation controller that controls the bottom sheet's entrance and
61 /// exit animations. 64 /// exit animations.
62 /// 65 ///
@@ -152,7 +155,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet> @@ -152,7 +155,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
152 widget.animationController.value < _willPopThreshold; 155 widget.animationController.value < _willPopThreshold;
153 156
154 bool get hasReachedCloseThreshold => 157 bool get hasReachedCloseThreshold =>
155 - widget.animationController.value < _closeProgressThreshold; 158 + widget.animationController.value < widget.closeProgressThreshold;
156 159
157 void _close() { 160 void _close() {
158 isDragging = false; 161 isDragging = false;
@@ -11,6 +11,7 @@ const Duration _bottomSheetDuration = Duration(milliseconds: 400); @@ -11,6 +11,7 @@ const Duration _bottomSheetDuration = Duration(milliseconds: 400);
11 class _ModalBottomSheet<T> extends StatefulWidget { 11 class _ModalBottomSheet<T> extends StatefulWidget {
12 const _ModalBottomSheet({ 12 const _ModalBottomSheet({
13 Key key, 13 Key key,
  14 + this.closeProgressThreshold,
14 this.route, 15 this.route,
15 this.secondAnimationController, 16 this.secondAnimationController,
16 this.bounce = false, 17 this.bounce = false,
@@ -22,6 +23,7 @@ class _ModalBottomSheet<T> extends StatefulWidget { @@ -22,6 +23,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
22 assert(enableDrag != null), 23 assert(enableDrag != null),
23 super(key: key); 24 super(key: key);
24 25
  26 + final double closeProgressThreshold;
25 final ModalBottomSheetRoute<T> route; 27 final ModalBottomSheetRoute<T> route;
26 final bool expanded; 28 final bool expanded;
27 final bool bounce; 29 final bool bounce;
@@ -85,6 +87,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -85,6 +87,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
85 label: _getRouteLabel(), 87 label: _getRouteLabel(),
86 explicitChildNodes: true, 88 explicitChildNodes: true,
87 child: ModalBottomSheet( 89 child: ModalBottomSheet(
  90 + closeProgressThreshold: widget.closeProgressThreshold,
88 expanded: widget.route.expanded, 91 expanded: widget.route.expanded,
89 containerBuilder: widget.route.containerBuilder, 92 containerBuilder: widget.route.containerBuilder,
90 animationController: widget.route._animationController, 93 animationController: widget.route._animationController,
@@ -113,6 +116,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> { @@ -113,6 +116,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
113 116
114 class ModalBottomSheetRoute<T> extends PopupRoute<T> { 117 class ModalBottomSheetRoute<T> extends PopupRoute<T> {
115 ModalBottomSheetRoute({ 118 ModalBottomSheetRoute({
  119 + this.closeProgressThreshold,
116 this.containerBuilder, 120 this.containerBuilder,
117 this.builder, 121 this.builder,
118 this.scrollController, 122 this.scrollController,
@@ -131,6 +135,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -131,6 +135,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
131 assert(enableDrag != null), 135 assert(enableDrag != null),
132 super(settings: settings); 136 super(settings: settings);
133 137
  138 + final double closeProgressThreshold;
134 final WidgetWithChildBuilder containerBuilder; 139 final WidgetWithChildBuilder containerBuilder;
135 final ScrollWidgetBuilder builder; 140 final ScrollWidgetBuilder builder;
136 final bool expanded; 141 final bool expanded;
@@ -180,6 +185,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -180,6 +185,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
180 context: context, 185 context: context,
181 // removeTop: true, 186 // removeTop: true,
182 child: _ModalBottomSheet<T>( 187 child: _ModalBottomSheet<T>(
  188 + closeProgressThreshold: closeProgressThreshold,
183 route: this, 189 route: this,
184 secondAnimationController: secondAnimationController, 190 secondAnimationController: secondAnimationController,
185 expanded: expanded, 191 expanded: expanded,
@@ -75,6 +75,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -75,6 +75,7 @@ Future<T> showBarModalBottomSheet<T>({
75 Color backgroundColor, 75 Color backgroundColor,
76 double elevation, 76 double elevation,
77 ShapeBorder shape, 77 ShapeBorder shape,
  78 + double closeProgressThreshold,
78 Clip clipBehavior, 79 Clip clipBehavior,
79 Color barrierColor = Colors.black87, 80 Color barrierColor = Colors.black87,
80 bool bounce = true, 81 bool bounce = true,
@@ -99,6 +100,7 @@ Future<T> showBarModalBottomSheet<T>({ @@ -99,6 +100,7 @@ Future<T> showBarModalBottomSheet<T>({
99 .push(ModalBottomSheetRoute<T>( 100 .push(ModalBottomSheetRoute<T>(
100 builder: builder, 101 builder: builder,
101 bounce: bounce, 102 bounce: bounce,
  103 + closeProgressThreshold: closeProgressThreshold,
102 containerBuilder: (_, __, child) => BarBottomSheet( 104 containerBuilder: (_, __, child) => BarBottomSheet(
103 child: child, 105 child: child,
104 control: topControl, 106 control: topControl,
@@ -6,6 +6,7 @@ import 'dart:async'; @@ -6,6 +6,7 @@ import 'dart:async';
6 Future<T> showMaterialModalBottomSheet<T>({ 6 Future<T> showMaterialModalBottomSheet<T>({
7 @required BuildContext context, 7 @required BuildContext context,
8 @required ScrollWidgetBuilder builder, 8 @required ScrollWidgetBuilder builder,
  9 + double closeProgressThreshold,
9 Color backgroundColor, 10 Color backgroundColor,
10 double elevation, 11 double elevation,
11 ShapeBorder shape, 12 ShapeBorder shape,
@@ -31,6 +32,7 @@ Future<T> showMaterialModalBottomSheet<T>({ @@ -31,6 +32,7 @@ Future<T> showMaterialModalBottomSheet<T>({
31 final result = await Navigator.of(context, rootNavigator: useRootNavigator) 32 final result = await Navigator.of(context, rootNavigator: useRootNavigator)
32 .push(ModalBottomSheetRoute<T>( 33 .push(ModalBottomSheetRoute<T>(
33 builder: builder, 34 builder: builder,
  35 + closeProgressThreshold: closeProgressThreshold,
34 containerBuilder: _materialContainerBuilder( 36 containerBuilder: _materialContainerBuilder(
35 context, 37 context,
36 backgroundColor: backgroundColor, 38 backgroundColor: backgroundColor,