Skip to content

Commit

Permalink
Fixed bottom sheet dismission (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
almazrafi authored Jun 18, 2023
1 parent 4b6f90e commit b151ca3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ internal final class BottomSheetPresentedInteraction: BottomSheetInteraction {
.transition
.wantsInteractiveStart = !isGestureFinished

presentationController
.presentingViewController
.dismiss(animated: true)
presentationController.dismissPresentedViewController()
}

internal func start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,15 @@ internal final class BottomSheetPresentationController: UIPresentationController
}

@objc private func onDimmingViewTapGesture() {
if delegate?.presentationControllerShouldDismiss?(self) ?? true {
presentingViewController.dismiss(animated: true)
guard state == .presented else {
return
}

guard delegate?.presentationControllerShouldDismiss?(self) ?? true else {
return
}

dismissPresentedViewController()
}

@objc private func onTransitionViewPanGesture(recognizer: UIPanGestureRecognizer) {
Expand Down Expand Up @@ -474,6 +480,16 @@ internal final class BottomSheetPresentationController: UIPresentationController
animator.startAnimation()
}

internal func dismissPresentedViewController() {
delegate?.presentationControllerWillDismiss?(self)

presentingViewController.dismiss(animated: true) {
if self.state == .dismissed {
self.delegate?.presentationControllerDidDismiss?(self)
}
}
}

internal override func presentationTransitionWillBegin() {
super.presentationTransitionWillBegin()

Expand Down Expand Up @@ -506,8 +522,6 @@ internal final class BottomSheetPresentationController: UIPresentationController
internal override func dismissalTransitionWillBegin() {
super.dismissalTransitionWillBegin()

delegate?.presentationControllerWillDismiss?(self)

animateChangesAlongsideTransition {
self.dimmingView?.alpha = .zero
}
Expand All @@ -521,8 +535,6 @@ internal final class BottomSheetPresentationController: UIPresentationController
transition.wantsInteractiveStart = false

if completed {
delegate?.presentationControllerDidDismiss?(self)

dimmingView?.removeFromSuperview()
transitionView?.removeFromSuperview()

Expand Down

0 comments on commit b151ca3

Please sign in to comment.