mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
26 lines
601 B
Swift
26 lines
601 B
Swift
import Foundation
|
|
import UIKit
|
|
|
|
struct SafeArea {
|
|
static var insets: UIEdgeInsets {
|
|
let keyWindow = scene?.windows.first { $0.isKeyWindow }
|
|
|
|
return keyWindow?.safeAreaInsets ?? .init()
|
|
}
|
|
|
|
static var verticalInset: Double {
|
|
insets.top + insets.bottom
|
|
}
|
|
|
|
static var horizontalInsets: Double {
|
|
insets.left + insets.right
|
|
}
|
|
|
|
static var scene: UIWindowScene? {
|
|
UIApplication.shared.connectedScenes
|
|
.filter { $0.activationState == .foregroundActive }
|
|
.compactMap { $0 as? UIWindowScene }
|
|
.first
|
|
}
|
|
}
|