mirror of
https://github.com/hanzoai/dev-desktop.git
synced 2026-11-20 23:52:12 +00:00
21 lines
937 B
Swift
21 lines
937 B
Swift
import ExpoModulesCore
|
|
import UIKit
|
|
|
|
public final class HanzoWorkspaceOrientationSubscriber: ExpoAppDelegateSubscriber {
|
|
private static let hingeWindows = NSHashTable<UIWindow>.weakObjects()
|
|
|
|
static func allowHingeOrientations(in window: UIWindow) {
|
|
guard !hingeWindows.contains(window) else { return }
|
|
hingeWindows.add(window)
|
|
window.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
|
|
}
|
|
|
|
public func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
|
|
if UIDevice.current.userInterfaceIdiom == .pad {
|
|
let orientations = Bundle.main.object(forInfoDictionaryKey: "UISupportedInterfaceOrientations~ipad") as? [String] ?? []
|
|
return orientations == ["UIInterfaceOrientationPortrait"] ? .portrait : .all
|
|
}
|
|
return window.map { Self.hingeWindows.contains($0) } == true ? .allButUpsideDown : .portrait
|
|
}
|
|
}
|