|
|
|
|
|
|
using Unity.UIWidgets.widgets; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.material { |
|
|
|
public static class BottomSheetUtils { |
|
|
|
public partial class material_ { |
|
|
|
public static readonly TimeSpan _bottomSheetEnterDuration = new TimeSpan(0, 0, 0, 0, 250); |
|
|
|
public static readonly TimeSpan _bottomSheetExitDuration = new TimeSpan(0, 0, 0, 0, 200); |
|
|
|
public static readonly Curve _modalBottomSheetCurve = material_.decelerateEasing; |
|
|
|
public const double _minFlingVelocity = 700.0; |
|
|
|
public const double _closeProgressThreshold = 0.5; |
|
|
|
|
|
|
|
delegate void BottomSheetDragStartHandler(DragStartDetails details); |
|
|
|
delegate void BottomSheetDragEndHandler( |
|
|
|
DragEndDetails details, |
|
|
|
bool isClosing = false |
|
|
|
); |
|
|
|
|
|
|
|
public static Future<T> showModalBottomSheet<T>( |
|
|
|
BuildContext context, |
|
|
|
WidgetBuilder builder |
|
|
|
|
|
|
|
|
|
|
public static AnimationController createAnimationController(TickerProvider vsync) { |
|
|
|
return new AnimationController( |
|
|
|
duration: BottomSheetUtils._kBottomSheetDuration, |
|
|
|
duration: material_._kBottomSheetDuration, |
|
|
|
debugLabel: "BottomSheet", |
|
|
|
vsync: vsync |
|
|
|
); |
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (details.velocity.pixelsPerSecond.dy > BottomSheetUtils._kMinFlingVelocity) { |
|
|
|
if (details.velocity.pixelsPerSecond.dy > material_._kMinFlingVelocity) { |
|
|
|
float flingVelocity = -details.velocity.pixelsPerSecond.dy / _childHeight.Value; |
|
|
|
if (widget.animationController.value > 0.0f) { |
|
|
|
widget.animationController.fling(velocity: flingVelocity); |
|
|
|
|
|
|
widget.onClosing(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (widget.animationController.value < BottomSheetUtils._kCloseProgressThreshold) { |
|
|
|
else if (widget.animationController.value < material_._kCloseProgressThreshold) { |
|
|
|
if (widget.animationController.value > 0.0f) { |
|
|
|
widget.animationController.fling(velocity: -1.0f); |
|
|
|
} |
|
|
|
|
|
|
public readonly ThemeData theme; |
|
|
|
|
|
|
|
public override TimeSpan transitionDuration { |
|
|
|
get { return BottomSheetUtils._kBottomSheetDuration; } |
|
|
|
get { return material_._kBottomSheetDuration; } |
|
|
|
} |
|
|
|
|
|
|
|
public override bool barrierDismissible { |
|
|
|