优化代码

This commit is contained in:
xaoxuu 2020-06-22 10:14:47 +08:00
parent 6275ac7615
commit 0818b97c16
6 changed files with 19 additions and 14 deletions

View File

@ -8,7 +8,6 @@
import UIKit
import SnapKit
import Inspire
public extension UIWindow.Level {
static let proAlert = UIWindow.Level.alert - 1

View File

@ -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 {

View File

@ -8,7 +8,6 @@
import UIKit
import SnapKit
import Inspire
public typealias Guard = ProHUD.Guard

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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 {