Skip to content

Commit

Permalink
[PanModal] Track all dismiss events through panModalPresentable callb…
Browse files Browse the repository at this point in the history
…acks (#91)
  • Loading branch information
Stephen Sowole authored Mar 25, 2020
1 parent 17a8231 commit 22b4ddd
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions PanModal/Controller/PanModalPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
}

/**
Expand Down Expand Up @@ -516,7 +523,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)

} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}

} else {
Expand All @@ -534,7 +541,7 @@ private extension PanModalPresentationController {
transition(to: .shortForm)

} else {
dismissPresentedViewController()
presentedViewController.dismiss(animated: true)
}
}
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22b4ddd

Please sign in to comment.