Skip to content

Commit

Permalink
Add completion block to present function (slackhq#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanpichler authored Apr 21, 2020
1 parent b012aec commit b2f5bd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion PanModal/Presenter/PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions PanModal/Presenter/UIViewController+PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -55,7 +59,7 @@ extension UIViewController: PanModalPresenter {
viewControllerToPresent.transitioningDelegate = PanModalPresentationDelegate.default
}

present(viewControllerToPresent, animated: true, completion: nil)
present(viewControllerToPresent, animated: true, completion: completion)
}

}
Expand Down

0 comments on commit b2f5bd7

Please sign in to comment.