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