[PanModal] Track all dismiss events through panModalPresentable callbacks (#91)

This commit is contained in:
Stephen Sowole 2020-03-25 00:34:58 -07:00 committed by GitHub
parent 17a8231f20
commit 22b4ddd47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 17 deletions

View File

@ -113,7 +113,7 @@ open class PanModalPresentationController: UIPresentationController {
}
view.didTap = { [weak self] _ in
if self?.presentable?.allowsTapToDismiss == true {
self?.dismissPresentedViewController()
self?.presentedViewController.dismiss(animated: true)
}
}
return view
@ -192,7 +192,14 @@ open class PanModalPresentationController: UIPresentationController {
})
}
override public func presentationTransitionDidEnd(_ completed: Bool) {
if completed { return }
backgroundView.removeFromSuperview()
}
override public func dismissalTransitionWillBegin() {
presentable?.panModalWillDismiss()
guard let coordinator = presentedViewController.transitionCoordinator else {
backgroundView.dimState = .off
@ -210,10 +217,10 @@ open class PanModalPresentationController: UIPresentationController {
})
}
override public func presentationTransitionDidEnd(_ completed: Bool) {
if completed { return }
backgroundView.removeFromSuperview()
override public func dismissalTransitionDidEnd(_ completed: Bool) {
if !completed { return }
presentable?.panModalDidDismiss()
}
/**
@ -516,7 +523,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}
} else {
@ -534,7 +541,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)
} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}
}
}
@ -673,16 +680,6 @@ private extension PanModalPresentationController {
else { return number }
return nearestVal
}
/**
Dismiss presented view
*/
func dismissPresentedViewController() {
presentable?.panModalWillDismiss()
presentedViewController.dismiss(animated: true) { [weak self] in
self?.presentable?.panModalDidDismiss()
}
}
}
// MARK: - UIScrollView Observer