mirror of https://github.com/xaoxuu/ProHUD
优化代码
This commit is contained in:
parent
6275ac7615
commit
0818b97c16
|
@ -8,7 +8,6 @@
|
|||
|
||||
import UIKit
|
||||
import SnapKit
|
||||
import Inspire
|
||||
|
||||
public extension UIWindow.Level {
|
||||
static let proAlert = UIWindow.Level.alert - 1
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import UIKit
|
||||
import SnapKit
|
||||
import Inspire
|
||||
|
||||
public extension ProHUD.Configuration {
|
||||
struct Guard {
|
||||
|
@ -106,7 +105,7 @@ fileprivate var privReloadData: (ProHUD.Guard) -> Void = {
|
|||
if width < config.cardMaxWidth {
|
||||
mk.bottom.equalToSuperview()
|
||||
} else {
|
||||
mk.bottom.equalToSuperview().offset(-Inspire.shared.screen.safeAreaInsets.bottom)
|
||||
mk.bottom.equalToSuperview().offset(-ProHUD.safeAreaInsets.bottom)
|
||||
}
|
||||
} else if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
mk.centerY.equalToSuperview()
|
||||
|
@ -116,13 +115,13 @@ fileprivate var privReloadData: (ProHUD.Guard) -> Void = {
|
|||
// stack
|
||||
vc.contentStack.snp.makeConstraints { (mk) in
|
||||
if isPortrait && vc.isFullScreen {
|
||||
mk.top.equalToSuperview().offset(Inspire.shared.screen.safeAreaInsets.top)
|
||||
mk.top.equalToSuperview().offset(ProHUD.safeAreaInsets.top)
|
||||
} else {
|
||||
mk.top.equalToSuperview().offset(config.padding)
|
||||
}
|
||||
mk.centerX.equalToSuperview()
|
||||
if width < config.cardMaxWidth {
|
||||
let bottom = Inspire.shared.screen.safeAreaInsets.bottom
|
||||
let bottom = ProHUD.safeAreaInsets.bottom
|
||||
if bottom == 0 {
|
||||
mk.bottom.equalToSuperview().offset(-config.padding)
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import UIKit
|
||||
import SnapKit
|
||||
import Inspire
|
||||
|
||||
public typealias Guard = ProHUD.Guard
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
|
||||
fileprivate var sharedWindowScene: UIWindowScene?
|
||||
|
||||
/// HUD配置
|
||||
public extension ProHUD {
|
||||
struct Configuration {
|
||||
|
||||
|
@ -21,14 +19,18 @@ public extension ProHUD {
|
|||
/// 根控制器,默认可以自动获取,如果获取失败请主动设置
|
||||
public var rootViewController: UIViewController?
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
/// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置
|
||||
@available(iOS 13.0, *)
|
||||
private static var sharedWindowScene: UIWindowScene?
|
||||
|
||||
/// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置
|
||||
@available(iOS 13.0, *)
|
||||
public var windowScene: UIWindowScene? {
|
||||
set {
|
||||
sharedWindowScene = newValue
|
||||
Configuration.sharedWindowScene = newValue
|
||||
}
|
||||
get {
|
||||
return sharedWindowScene
|
||||
return Configuration.sharedWindowScene
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import Inspire
|
||||
|
||||
public extension ProHUD {
|
||||
|
||||
|
@ -173,3 +174,9 @@ extension CALayer {
|
|||
removeAnimation(forKey: .rotateKey)
|
||||
}
|
||||
}
|
||||
|
||||
extension ProHUD {
|
||||
static var safeAreaInsets: UIEdgeInsets {
|
||||
return Inspire.shared.screen.updatedSafeAreaInsets
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
//
|
||||
|
||||
import UIKit
|
||||
import Inspire
|
||||
|
||||
public typealias Toast = ProHUD.Toast
|
||||
|
||||
|
@ -316,7 +315,7 @@ fileprivate extension Toast {
|
|||
|
||||
class func privUpdateToastsLayout() {
|
||||
func f() {
|
||||
let top = Inspire.shared.screen.updatedSafeAreaInsets.top
|
||||
let top = ProHUD.safeAreaInsets.top
|
||||
for (i, e) in toasts.enumerated() {
|
||||
let config = cfg.toast
|
||||
if let window = e.window {
|
||||
|
|
Loading…
Reference in New Issue