Jaime Blasco

fix: allow exposing parametes

@@ -19,4 +19,4 @@ SPEC CHECKSUMS: @@ -19,4 +19,4 @@ SPEC CHECKSUMS:
19 19
20 PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c 20 PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
21 21
22 -COCOAPODS: 1.11.2 22 +COCOAPODS: 1.11.3
@@ -41,5 +41,7 @@ @@ -41,5 +41,7 @@
41 </array> 41 </array>
42 <key>UIViewControllerBasedStatusBarAppearance</key> 42 <key>UIViewControllerBasedStatusBarAppearance</key>
43 <false/> 43 <false/>
  44 + <key>CADisableMinimumFrameDurationOnPhone</key>
  45 + <true/>
44 </dict> 46 </dict>
45 </plist> 47 </plist>
@@ -10,7 +10,7 @@ import 'package:modal_bottom_sheet/src/utils/scroll_to_top_status_bar.dart'; @@ -10,7 +10,7 @@ import 'package:modal_bottom_sheet/src/utils/scroll_to_top_status_bar.dart';
10 import 'package:modal_bottom_sheet/src/utils/bottom_sheet_suspended_curve.dart'; 10 import 'package:modal_bottom_sheet/src/utils/bottom_sheet_suspended_curve.dart';
11 11
12 const Curve _decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0); 12 const Curve _decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0);
13 -const Curve _modalBottomSheetCurve = _decelerateEasing; 13 +
14 const Duration _bottomSheetDuration = Duration(milliseconds: 400); 14 const Duration _bottomSheetDuration = Duration(milliseconds: 400);
15 const double _minFlingVelocity = 500.0; 15 const double _minFlingVelocity = 500.0;
16 const double _closeProgressThreshold = 0.6; 16 const double _closeProgressThreshold = 0.6;
@@ -34,7 +34,6 @@ class ModalBottomSheet extends StatefulWidget { @@ -34,7 +34,6 @@ class ModalBottomSheet extends StatefulWidget {
34 /// Creates a bottom sheet. 34 /// Creates a bottom sheet.
35 const ModalBottomSheet({ 35 const ModalBottomSheet({
36 Key? key, 36 Key? key,
37 - this.closeProgressThreshold,  
38 required this.animationController, 37 required this.animationController,
39 this.animationCurve, 38 this.animationCurve,
40 this.enableDrag = true, 39 this.enableDrag = true,
@@ -45,11 +44,16 @@ class ModalBottomSheet extends StatefulWidget { @@ -45,11 +44,16 @@ class ModalBottomSheet extends StatefulWidget {
45 required this.expanded, 44 required this.expanded,
46 required this.onClosing, 45 required this.onClosing,
47 required this.child, 46 required this.child,
48 - }) : super(key: key); 47 + this.minFlingVelocity = _minFlingVelocity,
  48 + double? closeProgressThreshold,
  49 + this.willPopThreshold = _willPopThreshold,
  50 + }) : closeProgressThreshold =
  51 + closeProgressThreshold ?? _closeProgressThreshold,
  52 + super(key: key);
49 53
50 /// The closeProgressThreshold parameter 54 /// The closeProgressThreshold parameter
51 /// specifies when the bottom sheet will be dismissed when user drags it. 55 /// specifies when the bottom sheet will be dismissed when user drags it.
52 - final double? closeProgressThreshold; 56 + final double closeProgressThreshold;
53 57
54 /// The animation controller that controls the bottom sheet's entrance and 58 /// The animation controller that controls the bottom sheet's entrance and
55 /// exit animations. 59 /// exit animations.
@@ -100,6 +104,14 @@ class ModalBottomSheet extends StatefulWidget { @@ -100,6 +104,14 @@ class ModalBottomSheet extends StatefulWidget {
100 104
101 final ScrollController scrollController; 105 final ScrollController scrollController;
102 106
  107 + /// The minFlingVelocity parameter
  108 + /// Determines how fast the sheet should be flinged before closing.
  109 + final double minFlingVelocity;
  110 +
  111 + /// The willPopThreshold parameter
  112 + /// Determines how far the sheet should be flinged before closing.
  113 + final double willPopThreshold;
  114 +
103 @override 115 @override
104 ModalBottomSheetState createState() => ModalBottomSheetState(); 116 ModalBottomSheetState createState() => ModalBottomSheetState();
105 117
@@ -147,8 +159,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet> @@ -147,8 +159,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
147 widget.animationController.value < _willPopThreshold; 159 widget.animationController.value < _willPopThreshold;
148 160
149 bool get hasReachedCloseThreshold => 161 bool get hasReachedCloseThreshold =>
150 - widget.animationController.value <  
151 - (widget.closeProgressThreshold ?? _closeProgressThreshold); 162 + widget.animationController.value < widget.closeProgressThreshold;
152 163
153 void _close() { 164 void _close() {
154 isDragging = false; 165 isDragging = false;
@@ -237,7 +248,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet> @@ -237,7 +248,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
237 } 248 }
238 249
239 // If speed is bigger than _minFlingVelocity try to close it 250 // If speed is bigger than _minFlingVelocity try to close it
240 - if (velocity > _minFlingVelocity) { 251 + if (velocity > widget.minFlingVelocity) {
241 tryClose(); 252 tryClose();
242 } else if (hasReachedCloseThreshold) { 253 } else if (hasReachedCloseThreshold) {
243 if (widget.animationController.value > 0.0) { 254 if (widget.animationController.value > 0.0) {
@@ -327,7 +338,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet> @@ -327,7 +338,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
327 } 338 }
328 } 339 }
329 340
330 - Curve get _defaultCurve => widget.animationCurve ?? _modalBottomSheetCurve; 341 + Curve get _defaultCurve => widget.animationCurve ?? _decelerateEasing;
331 342
332 @override 343 @override
333 void initState() { 344 void initState() {
@@ -136,9 +136,10 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> { @@ -136,9 +136,10 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
136 required this.expanded, 136 required this.expanded,
137 this.bounce = false, 137 this.bounce = false,
138 this.animationCurve, 138 this.animationCurve,
139 - this.duration, 139 + Duration? duration,
140 RouteSettings? settings, 140 RouteSettings? settings,
141 - }) : super(settings: settings); 141 + }) : duration = duration ?? _bottomSheetDuration,
  142 + super(settings: settings);
142 143
143 final double? closeProgressThreshold; 144 final double? closeProgressThreshold;
144 final WidgetWithChildBuilder? containerBuilder; 145 final WidgetWithChildBuilder? containerBuilder;
@@ -150,13 +151,13 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> { @@ -150,13 +151,13 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
150 final bool enableDrag; 151 final bool enableDrag;
151 final ScrollController? scrollController; 152 final ScrollController? scrollController;
152 153
153 - final Duration? duration; 154 + final Duration duration;
154 155
155 final AnimationController? secondAnimationController; 156 final AnimationController? secondAnimationController;
156 final Curve? animationCurve; 157 final Curve? animationCurve;
157 158
158 @override 159 @override
159 - Duration get transitionDuration => duration ?? _bottomSheetDuration; 160 + Duration get transitionDuration => duration;
160 161
161 @override 162 @override
162 bool get barrierDismissible => isDismissible; 163 bool get barrierDismissible => isDismissible;
@@ -244,6 +245,7 @@ Future<T?> showCustomModalBottomSheet<T>({ @@ -244,6 +245,7 @@ Future<T?> showCustomModalBottomSheet<T>({
244 bool enableDrag = true, 245 bool enableDrag = true,
245 Duration? duration, 246 Duration? duration,
246 RouteSettings? settings, 247 RouteSettings? settings,
  248 + double? closeProgressThreshold,
247 }) async { 249 }) async {
248 assert(debugCheckHasMediaQuery(context)); 250 assert(debugCheckHasMediaQuery(context));
249 assert(debugCheckHasMaterialLocalizations(context)); 251 assert(debugCheckHasMaterialLocalizations(context));
@@ -268,6 +270,7 @@ Future<T?> showCustomModalBottomSheet<T>({ @@ -268,6 +270,7 @@ Future<T?> showCustomModalBottomSheet<T>({
268 animationCurve: animationCurve, 270 animationCurve: animationCurve,
269 duration: duration, 271 duration: duration,
270 settings: settings, 272 settings: settings,
  273 + closeProgressThreshold: closeProgressThreshold,
271 )); 274 ));
272 return result; 275 return result;
273 } 276 }
@@ -81,7 +81,6 @@ Future<T?> showBarModalBottomSheet<T>({ @@ -81,7 +81,6 @@ Future<T?> showBarModalBottomSheet<T>({
81 Color? backgroundColor, 81 Color? backgroundColor,
82 double? elevation, 82 double? elevation,
83 ShapeBorder? shape, 83 ShapeBorder? shape,
84 - double? closeProgressThreshold,  
85 Clip? clipBehavior, 84 Clip? clipBehavior,
86 Color barrierColor = Colors.black87, 85 Color barrierColor = Colors.black87,
87 bool bounce = true, 86 bool bounce = true,
@@ -95,6 +94,7 @@ Future<T?> showBarModalBottomSheet<T>({ @@ -95,6 +94,7 @@ Future<T?> showBarModalBottomSheet<T>({
95 Duration? duration, 94 Duration? duration,
96 RouteSettings? settings, 95 RouteSettings? settings,
97 SystemUiOverlayStyle? overlayStyle, 96 SystemUiOverlayStyle? overlayStyle,
  97 + double? closeProgressThreshold,
98 }) async { 98 }) async {
99 assert(debugCheckHasMediaQuery(context)); 99 assert(debugCheckHasMediaQuery(context));
100 assert(debugCheckHasMaterialLocalizations(context)); 100 assert(debugCheckHasMaterialLocalizations(context));
@@ -74,7 +74,6 @@ Future<T?> showCupertinoModalBottomSheet<T>({ @@ -74,7 +74,6 @@ Future<T?> showCupertinoModalBottomSheet<T>({
74 required WidgetBuilder builder, 74 required WidgetBuilder builder,
75 Color? backgroundColor, 75 Color? backgroundColor,
76 double? elevation, 76 double? elevation,
77 - double? closeProgressThreshold,  
78 ShapeBorder? shape, 77 ShapeBorder? shape,
79 Clip? clipBehavior, 78 Clip? clipBehavior,
80 Color? barrierColor, 79 Color? barrierColor,
@@ -92,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({ @@ -92,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({
92 Color? transitionBackgroundColor, 91 Color? transitionBackgroundColor,
93 BoxShadow? shadow, 92 BoxShadow? shadow,
94 SystemUiOverlayStyle? overlayStyle, 93 SystemUiOverlayStyle? overlayStyle,
  94 + double? closeProgressThreshold,
95 }) async { 95 }) async {
96 assert(debugCheckHasMediaQuery(context)); 96 assert(debugCheckHasMediaQuery(context));
97 final hasMaterialLocalizations = 97 final hasMaterialLocalizations =
@@ -5,7 +5,6 @@ import 'dart:async'; @@ -5,7 +5,6 @@ import 'dart:async';
5 /// Shows a modal material design bottom sheet. 5 /// Shows a modal material design bottom sheet.
6 Future<T?> showMaterialModalBottomSheet<T>({ 6 Future<T?> showMaterialModalBottomSheet<T>({
7 required BuildContext context, 7 required BuildContext context,
8 - double? closeProgressThreshold,  
9 required WidgetBuilder builder, 8 required WidgetBuilder builder,
10 Color? backgroundColor, 9 Color? backgroundColor,
11 double? elevation, 10 double? elevation,
@@ -21,6 +20,7 @@ Future<T?> showMaterialModalBottomSheet<T>({ @@ -21,6 +20,7 @@ Future<T?> showMaterialModalBottomSheet<T>({
21 bool enableDrag = true, 20 bool enableDrag = true,
22 Duration? duration, 21 Duration? duration,
23 RouteSettings? settings, 22 RouteSettings? settings,
  23 + double? closeProgressThreshold,
24 }) async { 24 }) async {
25 assert(debugCheckHasMediaQuery(context)); 25 assert(debugCheckHasMediaQuery(context));
26 assert(debugCheckHasMaterialLocalizations(context)); 26 assert(debugCheckHasMaterialLocalizations(context));