diff --git a/iphone/Maps/UI/Search/SearchOnMap/Presentation/ModalPresentationAnimator.swift b/iphone/Maps/UI/Search/SearchOnMap/Presentation/ModalPresentationAnimator.swift index 6af87627b..1b7857d5d 100644 --- a/iphone/Maps/UI/Search/SearchOnMap/Presentation/ModalPresentationAnimator.swift +++ b/iphone/Maps/UI/Search/SearchOnMap/Presentation/ModalPresentationAnimator.swift @@ -8,8 +8,10 @@ final class ModalPresentationAnimator { private enum Constants { static let animationDuration: TimeInterval = kDefaultAnimationDuration - static let springDamping: CGFloat = 0.85 + static let springDamping: CGFloat = 0.8 static let springVelocity: CGFloat = 0.2 + static let controlPoint1: CGPoint = CGPoint(x: 0.25, y: 0.1) + static let controlPoint2: CGPoint = CGPoint(x: 0.15, y: 1.0) } static func animate(with stepAnimation: PresentationStepChangeAnimation = .slide, @@ -19,20 +21,29 @@ final class ModalPresentationAnimator { case .none: animations() completion?(true) + case .slide: - UIView.animate(withDuration: Constants.animationDuration, - delay: 0, - options: .curveEaseOut, - animations: animations, - completion: completion) + let timing = UICubicTimingParameters(controlPoint1: Constants.controlPoint1, + controlPoint2: Constants.controlPoint2) + let animator = UIViewPropertyAnimator(duration: Constants.animationDuration, + timingParameters: timing) + animator.addAnimations(animations) + animator.addCompletion { position in + completion?(position == .end) + } + animator.startAnimation() + case .slideAndBounce: - UIView.animate(withDuration: Constants.animationDuration, - delay: 0, - usingSpringWithDamping: Constants.springDamping, - initialSpringVelocity: Constants.springVelocity, - options: .curveLinear, - animations: animations, - completion: completion) + let velocity = CGVector(dx: Constants.springVelocity, dy: Constants.springVelocity) + let timing = UISpringTimingParameters(dampingRatio: Constants.springDamping, + initialVelocity: velocity) + let animator = UIViewPropertyAnimator(duration: Constants.animationDuration, + timingParameters: timing) + animator.addAnimations(animations) + animator.addCompletion { position in + completion?(position == .end) + } + animator.startAnimation() } } }