mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1018 B
Swift
34 lines
1018 B
Swift
8 years ago
|
//
|
||
6 years ago
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||
8 years ago
|
//
|
||
|
|
||
|
import Foundation
|
||
|
|
||
7 years ago
|
@objc public extension UIApplication {
|
||
8 years ago
|
|
||
6 years ago
|
public var frontmostViewControllerIgnoringAlerts: UIViewController? {
|
||
7 years ago
|
return findFrontmostViewController(ignoringAlerts: true)
|
||
8 years ago
|
}
|
||
|
|
||
6 years ago
|
public var frontmostViewController: UIViewController? {
|
||
7 years ago
|
return findFrontmostViewController(ignoringAlerts: false)
|
||
8 years ago
|
}
|
||
|
|
||
|
internal func findFrontmostViewController(ignoringAlerts: Bool) -> UIViewController? {
|
||
7 years ago
|
guard let window = CurrentAppContext().mainWindow else {
|
||
|
return nil
|
||
|
}
|
||
|
Logger.error("findFrontmostViewController: \(window)")
|
||
|
guard let viewController = window.rootViewController else {
|
||
7 years ago
|
owsFailDebug("Missing root view controller.")
|
||
7 years ago
|
return nil
|
||
|
}
|
||
|
return viewController.findFrontmostViewController(ignoringAlerts)
|
||
8 years ago
|
}
|
||
|
|
||
6 years ago
|
public func openSystemSettings() {
|
||
6 years ago
|
openURL(URL(string: UIApplication.openSettingsURLString)!)
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
}
|