Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions PanModal/Presenter/PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protocol PanModalPresenter: AnyObject {
Presents a view controller that conforms to the PanModalPresentable protocol
*/
func presentPanModal(_ viewControllerToPresent: PanModalPresentable.LayoutType,
userInterfaceIdiom: UIUserInterfaceIdiom,
sourceView: UIView?,
sourceRect: CGRect,
completion: (() -> Void)?)
Expand Down
4 changes: 3 additions & 1 deletion PanModal/Presenter/UIViewController+PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ extension UIViewController: PanModalPresenter {

- Parameters:
- viewControllerToPresent: The view controller to be presented
- userInterfaceIdiom: The user interface idiom deciding to use the popover presentation style or not.
- 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,
userInterfaceIdiom: UIUserInterfaceIdiom = UIDevice.current.userInterfaceIdiom,
sourceView: UIView? = nil,
sourceRect: CGRect = .zero,
completion: (() -> Void)? = nil) {
Expand All @@ -48,7 +50,7 @@ extension UIViewController: PanModalPresenter {
Here, we deliberately do not check for size classes. More info in `PanModalPresentationDelegate`
*/

if UIDevice.current.userInterfaceIdiom == .pad {
if userInterfaceIdiom == .pad {
viewControllerToPresent.modalPresentationStyle = .popover
viewControllerToPresent.popoverPresentationController?.sourceRect = sourceRect
viewControllerToPresent.popoverPresentationController?.sourceView = sourceView ?? view
Expand Down