diff options
author | Shav Kinderlehrer <[email protected]> | 2024-01-08 14:00:59 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-01-08 14:00:59 -0500 |
commit | 4ec0f962b2a175ae5f1e3e55a720f9534618a4ad (patch) | |
tree | e5f9251b41c15867da7c2f7c8903e8af76b4afc6 /Jel/Controllers/UIScreenCurrent.swift | |
parent | 6d32db67511ca83312d3f8dcd971e48b9b59c9e9 (diff) | |
download | jel-4ec0f962b2a175ae5f1e3e55a720f9534618a4ad.tar.gz jel-4ec0f962b2a175ae5f1e3e55a720f9534618a4ad.zip |
Refactor ItemViews
Diffstat (limited to 'Jel/Controllers/UIScreenCurrent.swift')
-rw-r--r-- | Jel/Controllers/UIScreenCurrent.swift | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Jel/Controllers/UIScreenCurrent.swift b/Jel/Controllers/UIScreenCurrent.swift new file mode 100644 index 0000000..86d4ca0 --- /dev/null +++ b/Jel/Controllers/UIScreenCurrent.swift @@ -0,0 +1,28 @@ +// +// UIScreenCurrent.swift +// Jel +// +// Created by zerocool on 1/8/24. +// + +import Foundation +import SwiftUI + +extension UIWindow { + static var current: UIWindow? { + for scene in UIApplication.shared.connectedScenes { + guard let windowScene = scene as? UIWindowScene else { continue } + for window in windowScene.windows { + if window.isKeyWindow { return window } + } + } + return nil + } +} + + +extension UIScreen { + static var current: UIScreen? { + UIWindow.current?.screen + } +} |