[ios] refactor search modes switching

For the expanded iphone mode (in portait) only the searchEverywhere will be used
For the halfscreen everywhere + viewport
For the iPad the everywhere + viewport is always enabled
For the hidden only the viewport

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn
2025-05-28 18:10:57 +04:00
committed by Konstantin Pastbin
parent 6d093a45cf
commit 4cf5ec3c86
5 changed files with 103 additions and 52 deletions

View File

@@ -77,7 +77,7 @@ final class ModalPresentationStepsController {
}
let animation: PresentationStepChangeAnimation = abs(velocity.y) > Constants.slowSwipeVelocity ? .slideAndBounce : .slide
setStep(nextStep, animation: animation, notifyAboutStepUpdate: true)
setStep(nextStep, animation: animation)
default:
break
}
@@ -86,27 +86,23 @@ final class ModalPresentationStepsController {
func setStep(_ step: ModalPresentationStep,
completion: (() -> Void)? = nil) {
guard currentStep != step else { return }
setStep(step, animation: .slide, notifyAboutStepUpdate: false, completion: completion)
setStep(step, animation: .slide, completion: completion)
}
private func setStep(_ step: ModalPresentationStep,
animation: PresentationStepChangeAnimation,
notifyAboutStepUpdate: Bool = true,
completion: (() -> Void)? = nil) {
guard let presentedView else { return }
currentStep = step
updateMaxAvailableFrame()
let frame = frame(for: step)
didUpdateHandler?(.didUpdateStep(step))
didUpdateHandler?(.didUpdateFrame(frame))
ModalPresentationAnimator.animate(with: animation) {
presentedView.frame = frame
} completion: { [weak self] _ in
guard let self else { return }
if notifyAboutStepUpdate {
self.didUpdateHandler?(.didUpdateStep(step))
}
} completion: { _ in
completion?()
}
}