2022-08-07 17:41:57 +05:30
|
|
|
import Foundation
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
struct SafeArea {
|
|
|
|
static var insets: UIEdgeInsets {
|
2022-08-13 19:42:45 +05:30
|
|
|
let keyWindow = scene?.windows.first { $0.isKeyWindow }
|
2022-08-07 17:41:57 +05:30
|
|
|
|
|
|
|
return keyWindow?.safeAreaInsets ?? .init()
|
|
|
|
}
|
2022-08-13 19:42:45 +05:30
|
|
|
|
2022-09-01 04:11:31 +05:30
|
|
|
static var verticalInset: Double {
|
|
|
|
insets.top + insets.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
static var horizontalInsets: Double {
|
|
|
|
insets.left + insets.right
|
|
|
|
}
|
|
|
|
|
2022-08-13 19:42:45 +05:30
|
|
|
static var scene: UIWindowScene? {
|
|
|
|
UIApplication.shared.connectedScenes
|
2022-08-13 20:16:45 +05:30
|
|
|
.filter { $0.activationState == .foregroundActive }
|
|
|
|
.compactMap { $0 as? UIWindowScene }
|
|
|
|
.first
|
2022-08-13 19:42:45 +05:30
|
|
|
}
|
2022-08-07 17:41:57 +05:30
|
|
|
}
|