diff --git a/PanModal/Presenter/PanModalPresenter.swift b/PanModal/Presenter/PanModalPresenter.swift index f27ba698..8763fdac 100644 --- a/PanModal/Presenter/PanModalPresenter.swift +++ b/PanModal/Presenter/PanModalPresenter.swift @@ -29,7 +29,10 @@ protocol PanModalPresenter: AnyObject { /** Presents a view controller that conforms to the PanModalPresentable protocol */ - func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView?, sourceRect: CGRect) + func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, + sourceView: UIView?, + sourceRect: CGRect, + completion: (() -> Void)?) } #endif diff --git a/PanModal/Presenter/UIViewController+PanModalPresenter.swift b/PanModal/Presenter/UIViewController+PanModalPresenter.swift index 48358c21..b252d8f7 100644 --- a/PanModal/Presenter/UIViewController+PanModalPresenter.swift +++ b/PanModal/Presenter/UIViewController+PanModalPresenter.swift @@ -35,10 +35,14 @@ extension UIViewController: PanModalPresenter { - viewControllerToPresent: The view controller to be presented - sourceView: The view containing the anchor rectangle for the popover. - sourceRect: The rectangle in the specified view in which to anchor the popover. + - completion: The block to execute after the presentation finishes. You may specify nil for this parameter. - Note: sourceView & sourceRect are only required for presentation on an iPad. */ - public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView? = nil, sourceRect: CGRect = .zero) { + public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, + sourceView: UIView? = nil, + sourceRect: CGRect = .zero, + completion: (() -> Void)? = nil) { /** Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate` @@ -55,7 +59,7 @@ extension UIViewController: PanModalPresenter { viewControllerToPresent.transitioningDelegate = PanModalPresentationDelegate.default } - present(viewControllerToPresent, animated: true, completion: nil) + present(viewControllerToPresent, animated: true, completion: completion) } }