Jaime Blasco

fix: allow exposing parametes

... ... @@ -19,4 +19,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
... ...
... ... @@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
... ...
... ... @@ -10,7 +10,7 @@ import 'package:modal_bottom_sheet/src/utils/scroll_to_top_status_bar.dart';
import 'package:modal_bottom_sheet/src/utils/bottom_sheet_suspended_curve.dart';
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;
... ... @@ -34,7 +34,6 @@ class ModalBottomSheet extends StatefulWidget {
/// Creates a bottom sheet.
const ModalBottomSheet({
Key? key,
this.closeProgressThreshold,
required this.animationController,
this.animationCurve,
this.enableDrag = true,
... ... @@ -45,11 +44,16 @@ class ModalBottomSheet extends StatefulWidget {
required this.expanded,
required this.onClosing,
required this.child,
}) : super(key: key);
this.minFlingVelocity = _minFlingVelocity,
double? closeProgressThreshold,
this.willPopThreshold = _willPopThreshold,
}) : closeProgressThreshold =
closeProgressThreshold ?? _closeProgressThreshold,
super(key: key);
/// The closeProgressThreshold parameter
/// specifies when the bottom sheet will be dismissed when user drags it.
final double? closeProgressThreshold;
final double closeProgressThreshold;
/// The animation controller that controls the bottom sheet's entrance and
/// exit animations.
... ... @@ -100,6 +104,14 @@ class ModalBottomSheet extends StatefulWidget {
final ScrollController scrollController;
/// The minFlingVelocity parameter
/// Determines how fast the sheet should be flinged before closing.
final double minFlingVelocity;
/// The willPopThreshold parameter
/// Determines how far the sheet should be flinged before closing.
final double willPopThreshold;
@override
ModalBottomSheetState createState() => ModalBottomSheetState();
... ... @@ -147,8 +159,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
widget.animationController.value < _willPopThreshold;
bool get hasReachedCloseThreshold =>
widget.animationController.value <
(widget.closeProgressThreshold ?? _closeProgressThreshold);
widget.animationController.value < widget.closeProgressThreshold;
void _close() {
isDragging = false;
... ... @@ -237,7 +248,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
}
// If speed is bigger than _minFlingVelocity try to close it
if (velocity > _minFlingVelocity) {
if (velocity > widget.minFlingVelocity) {
tryClose();
} else if (hasReachedCloseThreshold) {
if (widget.animationController.value > 0.0) {
... ... @@ -327,7 +338,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
}
}
Curve get _defaultCurve => widget.animationCurve ?? _modalBottomSheetCurve;
Curve get _defaultCurve => widget.animationCurve ?? _decelerateEasing;
@override
void initState() {
... ...
... ... @@ -136,9 +136,10 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
required this.expanded,
this.bounce = false,
this.animationCurve,
this.duration,
Duration? duration,
RouteSettings? settings,
}) : super(settings: settings);
}) : duration = duration ?? _bottomSheetDuration,
super(settings: settings);
final double? closeProgressThreshold;
final WidgetWithChildBuilder? containerBuilder;
... ... @@ -150,13 +151,13 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
final bool enableDrag;
final ScrollController? scrollController;
final Duration? duration;
final Duration duration;
final AnimationController? secondAnimationController;
final Curve? animationCurve;
@override
Duration get transitionDuration => duration ?? _bottomSheetDuration;
Duration get transitionDuration => duration;
@override
bool get barrierDismissible => isDismissible;
... ... @@ -244,6 +245,7 @@ Future<T?> showCustomModalBottomSheet<T>({
bool enableDrag = true,
Duration? duration,
RouteSettings? settings,
double? closeProgressThreshold,
}) async {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
... ... @@ -268,6 +270,7 @@ Future<T?> showCustomModalBottomSheet<T>({
animationCurve: animationCurve,
duration: duration,
settings: settings,
closeProgressThreshold: closeProgressThreshold,
));
return result;
}
... ...
... ... @@ -81,7 +81,6 @@ Future<T?> showBarModalBottomSheet<T>({
Color? backgroundColor,
double? elevation,
ShapeBorder? shape,
double? closeProgressThreshold,
Clip? clipBehavior,
Color barrierColor = Colors.black87,
bool bounce = true,
... ... @@ -95,6 +94,7 @@ Future<T?> showBarModalBottomSheet<T>({
Duration? duration,
RouteSettings? settings,
SystemUiOverlayStyle? overlayStyle,
double? closeProgressThreshold,
}) async {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
... ...
... ... @@ -74,7 +74,6 @@ Future<T?> showCupertinoModalBottomSheet<T>({
required WidgetBuilder builder,
Color? backgroundColor,
double? elevation,
double? closeProgressThreshold,
ShapeBorder? shape,
Clip? clipBehavior,
Color? barrierColor,
... ... @@ -92,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({
Color? transitionBackgroundColor,
BoxShadow? shadow,
SystemUiOverlayStyle? overlayStyle,
double? closeProgressThreshold,
}) async {
assert(debugCheckHasMediaQuery(context));
final hasMaterialLocalizations =
... ...
... ... @@ -5,7 +5,6 @@ import 'dart:async';
/// Shows a modal material design bottom sheet.
Future<T?> showMaterialModalBottomSheet<T>({
required BuildContext context,
double? closeProgressThreshold,
required WidgetBuilder builder,
Color? backgroundColor,
double? elevation,
... ... @@ -21,6 +20,7 @@ Future<T?> showMaterialModalBottomSheet<T>({
bool enableDrag = true,
Duration? duration,
RouteSettings? settings,
double? closeProgressThreshold,
}) async {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
... ...