Merge branch 'AlexT84-fix_ios_multiple_flutter_presenting_error'
This commit is contained in:
commit
614374c6c9
@ -105,23 +105,17 @@ public class InAppBrowserManager: ChannelDelegate {
|
||||
navController.pushViewController(webViewController, animated: false)
|
||||
webViewController.prepareNavigationControllerBeforeViewWillAppear()
|
||||
|
||||
let frame: CGRect = UIScreen.main.bounds
|
||||
let tmpWindow = UIWindow(frame: frame)
|
||||
|
||||
let tmpController = UIViewController()
|
||||
let baseWindowLevel = UIApplication.shared.keyWindow?.windowLevel
|
||||
tmpWindow.rootViewController = tmpController
|
||||
tmpWindow.windowLevel = UIWindow.Level(baseWindowLevel!.rawValue + 1.0)
|
||||
tmpWindow.makeKeyAndVisible()
|
||||
navController.tmpWindow = tmpWindow
|
||||
|
||||
var animated = true
|
||||
if let browserSettings = webViewController.browserSettings, browserSettings.hidden {
|
||||
tmpWindow.isHidden = true
|
||||
UIApplication.shared.delegate?.window??.makeKeyAndVisible()
|
||||
animated = false
|
||||
}
|
||||
tmpWindow.rootViewController!.present(navController, animated: animated, completion: nil)
|
||||
|
||||
guard let visibleViewController = UIApplication.shared.visibleViewController else {
|
||||
assertionFailure("Failure init the visibleViewController!")
|
||||
return
|
||||
}
|
||||
|
||||
visibleViewController.present(navController, animated: animated)
|
||||
}
|
||||
|
||||
public func openWithSystemBrowser(url: String, result: @escaping FlutterResult) {
|
||||
|
@ -90,7 +90,7 @@ public class ChromeSafariBrowserManager: ChannelDelegate {
|
||||
|
||||
if #available(iOS 9.0, *), let plugin = plugin {
|
||||
|
||||
if let flutterViewController = UIApplication.shared.delegate?.window.unsafelyUnwrapped?.rootViewController {
|
||||
if let flutterViewController = UIApplication.shared.visibleViewController {
|
||||
// flutterViewController could be casted to FlutterViewController if needed
|
||||
|
||||
let safariSettings = SafariBrowserSettings()
|
||||
|
31
ios/Classes/UIApplication/VisibleViewController.swift
Normal file
31
ios/Classes/UIApplication/VisibleViewController.swift
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// VisibleViewController.swift
|
||||
// flutter_inappwebview
|
||||
//
|
||||
// Created by Alexandru Terente on 02.08.2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIApplication {
|
||||
|
||||
var visibleViewController: UIViewController? {
|
||||
guard let rootViewController = keyWindow?.rootViewController else {
|
||||
return nil
|
||||
}
|
||||
return getVisibleViewController(rootViewController)
|
||||
}
|
||||
|
||||
private func getVisibleViewController(_ rootViewController: UIViewController) -> UIViewController? {
|
||||
if let presentedViewController = rootViewController.presentedViewController {
|
||||
return getVisibleViewController(presentedViewController)
|
||||
}
|
||||
if let navigationController = rootViewController as? UINavigationController {
|
||||
return navigationController.visibleViewController
|
||||
}
|
||||
if let tabBarController = rootViewController as? UITabBarController {
|
||||
return tabBarController.selectedViewController
|
||||
}
|
||||
return rootViewController
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user