Skip to content

Commit

Permalink
fix(ios): don't use the tmpWindow on popover presentation (#2714)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Apr 7, 2020
1 parent 6a03960 commit 327ffc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions ios/Capacitor/Capacitor/CAPBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,20 @@ enum BridgeError: Error {
}

@objc public func presentVC(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil) {
self.tmpWindow.makeKeyAndVisible()
self.tmpVC.present(viewControllerToPresent, animated: flag, completion: completion)
if viewControllerToPresent.modalPresentationStyle == .popover {
self.viewController.present(viewControllerToPresent, animated: flag, completion: completion)
} else {
self.tmpWindow.makeKeyAndVisible()
self.tmpVC.present(viewControllerToPresent, animated: flag, completion: completion)
}
}

@objc public func dismissVC(animated flag: Bool, completion: (() -> Void)? = nil) {
self.tmpVC.dismiss(animated: flag, completion: completion)
if self.tmpWindow.isHidden {
self.viewController.dismiss(animated: flag, completion: completion)
} else {
self.tmpVC.dismiss(animated: flag, completion: completion)
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/Plugins/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CAPBrowserPlugin : CAPPlugin, SFSafariViewControllerDelegate {
self.vc = SFSafariViewController.init(url: url!)
self.vc!.delegate = self
let presentationStyle = call.getString("presentationStyle")
if presentationStyle != nil && presentationStyle == "popover" {
if presentationStyle != nil && presentationStyle == "popover" && UIDevice.current.userInterfaceIdiom == .pad {
self.vc!.modalPresentationStyle = .popover
self.setCenteredPopover(self.vc)
} else {
Expand Down

0 comments on commit 327ffc5

Please sign in to comment.