Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

Commit b2f5bd7

Browse files
Add completion block to present function (#94)
1 parent b012aec commit b2f5bd7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

PanModal/Presenter/PanModalPresenter.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ protocol PanModalPresenter: AnyObject {
2929
/**
3030
Presents a view controller that conforms to the PanModalPresentable protocol
3131
*/
32-
func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView?, sourceRect: CGRect)
32+
func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType,
33+
sourceView: UIView?,
34+
sourceRect: CGRect,
35+
completion: (() -> Void)?)
3336

3437
}
3538
#endif

PanModal/Presenter/UIViewController+PanModalPresenter.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ extension UIViewController: PanModalPresenter {
3535
- viewControllerToPresent: The view controller to be presented
3636
- sourceView: The view containing the anchor rectangle for the popover.
3737
- sourceRect: The rectangle in the specified view in which to anchor the popover.
38+
- completion: The block to execute after the presentation finishes. You may specify nil for this parameter.
3839

3940
- Note: sourceView & sourceRect are only required for presentation on an iPad.
4041
*/
41-
public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType, sourceView: UIView? = nil, sourceRect: CGRect = .zero) {
42+
public func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType,
43+
sourceView: UIView? = nil,
44+
sourceRect: CGRect = .zero,
45+
completion: (() -> Void)? = nil) {
4246

4347
/**
4448
Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate`
@@ -55,7 +59,7 @@ extension UIViewController: PanModalPresenter {
5559
viewControllerToPresent.transitioningDelegate = PanModalPresentationDelegate.default
5660
}
5761

58-
present(viewControllerToPresent, animated: true, completion: nil)
62+
present(viewControllerToPresent, animated: true, completion: completion)
5963
}
6064

6165
}

0 commit comments

Comments
 (0)