Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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