mirror of https://github.com/xaoxuu/ProHUD
代码优化
This commit is contained in:
parent
6b870e4ba8
commit
014e9abdbe
22
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/Contents.json
vendored
Normal file
22
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "prohud.rainbow.circle@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "prohud.rainbow.circle@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@2x.png
vendored
Normal file
BIN
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@3x.png
vendored
Normal file
BIN
Example-Old/Example/Assets.xcassets/prohud.rainbow.circle.imageset/prohud.rainbow.circle@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "prohud.trash@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "prohud.trash@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@2x.png
vendored
Normal file
BIN
Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@3x.png
vendored
Normal file
BIN
Example-Old/Example/Assets.xcassets/prohud.trash.imageset/prohud.trash@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.5 KiB |
|
@ -43,8 +43,13 @@ class BaseListVC: UIViewController {
|
|||
var secs = [Section]()
|
||||
|
||||
lazy var tableView: UITableView = {
|
||||
let tv = UITableView(frame: .zero, style: .insetGrouped)
|
||||
|
||||
let tv: UITableView
|
||||
if #available(iOS 13.0, *) {
|
||||
tv = UITableView(frame: .zero, style: .insetGrouped)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
tv = UITableView(frame: .zero, style: .grouped)
|
||||
}
|
||||
return tv
|
||||
}()
|
||||
|
||||
|
|
|
@ -35,6 +35,11 @@ class TestGuardVC: BaseListVC {
|
|||
vm.add(action: .cancel, title: "取消", handler: nil)
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
|
||||
Guard.find("del") { vc in
|
||||
vc.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: 升级至专业版
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
PODS:
|
||||
- Inspire (2.0.0)
|
||||
- Inspire (2.1.0)
|
||||
- ProHUD (1.0):
|
||||
- Inspire
|
||||
- SnapKit (= 5.0)
|
||||
|
@ -21,10 +21,10 @@ EXTERNAL SOURCES:
|
|||
:path: ".."
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Inspire: 7556357c9c90d5e886f3be5d29fe1e0222b694e1
|
||||
Inspire: 087dce1e4ff902d26d79bd3453352af09411c172
|
||||
ProHUD: 7128b55036885ac4f8b4d0b0783ee6f8eb3a2ea9
|
||||
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
|
||||
|
||||
PODFILE CHECKSUM: 80148eec6ba2e9631b208c7b277316b6c551afc4
|
||||
|
||||
COCOAPODS: 1.9.2
|
||||
COCOAPODS: 1.10.1
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# 使用 AppDelegate 的项目
|
||||
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
guard let scene = (scene as? UIWindowScene) else { return }
|
||||
|
||||
|
||||
print(scene.statusBarManager?.statusBarFrame)
|
||||
let rootVC = RootVC()
|
||||
window?.rootViewController = rootVC
|
||||
window?.makeKeyAndVisible()
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# 使用 SceneDelegate 的项目
|
||||
|
|
@ -10,7 +10,7 @@ let package = Package(
|
|||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/SnapKit/SnapKit.git", "5.0.0" ..< "6.0.0"),
|
||||
.package(url: "https://github.com/xaoxuu/Inspire.git", "2.0.0" ..< "3.0.0"),
|
||||
.package(url: "https://github.com/xaoxuu/Inspire.git", "2.1.0" ..< "3.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
CDB6A07B22EEF06500AF6CF0 /* HUDController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07A22EEF06500AF6CF0 /* HUDController.swift */; };
|
||||
CDB6A07D22EEF19D00AF6CF0 /* HUDConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07C22EEF19D00AF6CF0 /* HUDConfig.swift */; };
|
||||
CDC39CFD22FD6DDF0070E914 /* GuardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC39CFC22FD6DDF0070E914 /* GuardModel.swift */; };
|
||||
CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */; };
|
||||
CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */; };
|
||||
CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SnapKit */; };
|
||||
CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* Inspire */; };
|
||||
CDF2C58924A0572C002ECDD5 /* HUDUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF2C58824A0572C002ECDD5 /* HUDUtils.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -58,8 +58,8 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */,
|
||||
CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */,
|
||||
CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */,
|
||||
CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */,
|
||||
36CB9DEED3C3E823FE7B1C75 /* Pods_ProHUD.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -189,8 +189,8 @@
|
|||
);
|
||||
name = ProHUD;
|
||||
packageProductDependencies = (
|
||||
CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */,
|
||||
CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */,
|
||||
CDC67BE82490A19100CC6FE6 /* SnapKit */,
|
||||
CDC67BEB2490A1D100CC6FE6 /* Inspire */,
|
||||
);
|
||||
productName = ProHUD;
|
||||
productReference = CD95D21C22E72C4C007559A3 /* ProHUD.framework */;
|
||||
|
@ -221,8 +221,8 @@
|
|||
);
|
||||
mainGroup = CD95D21222E72C4C007559A3;
|
||||
packageReferences = (
|
||||
CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */,
|
||||
CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */,
|
||||
CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */,
|
||||
CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */,
|
||||
);
|
||||
productRefGroup = CD95D21D22E72C4C007559A3 /* Products */;
|
||||
projectDirPath = "";
|
||||
|
@ -493,7 +493,7 @@
|
|||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCRemoteSwiftPackageReference section */
|
||||
CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */ = {
|
||||
CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/SnapKit/SnapKit";
|
||||
requirement = {
|
||||
|
@ -501,25 +501,25 @@
|
|||
minimumVersion = 5.0.1;
|
||||
};
|
||||
};
|
||||
CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */ = {
|
||||
CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */ = {
|
||||
isa = XCRemoteSwiftPackageReference;
|
||||
repositoryURL = "https://github.com/xaoxuu/Inspire";
|
||||
requirement = {
|
||||
kind = upToNextMajorVersion;
|
||||
minimumVersion = 2.0.0;
|
||||
minimumVersion = 2.1.0;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */ = {
|
||||
CDC67BE82490A19100CC6FE6 /* SnapKit */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */;
|
||||
package = CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */;
|
||||
productName = SnapKit;
|
||||
};
|
||||
CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */ = {
|
||||
CDC67BEB2490A1D100CC6FE6 /* Inspire */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */;
|
||||
package = CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */;
|
||||
productName = Inspire;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
|
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
import SnapKit
|
||||
|
||||
public extension UIWindow.Level {
|
||||
static let proAlert = UIWindow.Level.alert - 1
|
||||
static let alertForProHUD = UIWindow.Level.alert - 1
|
||||
}
|
||||
|
||||
public extension ProHUD.Configuration {
|
||||
|
@ -75,7 +75,7 @@ public extension ProHUD.Configuration {
|
|||
|
||||
|
||||
// MARK: - 内部调用
|
||||
internal extension ProHUD.Configuration.Alert {
|
||||
extension ProHUD.Configuration.Alert {
|
||||
|
||||
var reloadData: (ProHUD.Alert) -> Void {
|
||||
return privReloadData
|
||||
|
|
|
@ -14,9 +14,9 @@ public typealias Alert = ProHUD.Alert
|
|||
public extension ProHUD {
|
||||
class Alert: HUDController {
|
||||
|
||||
internal static var alerts = [Alert]()
|
||||
static var alerts = [Alert]()
|
||||
|
||||
internal static var alertWindow: UIWindow?
|
||||
static var alertWindow: UIWindow?
|
||||
|
||||
/// 内容视图
|
||||
public var contentView = createBlurView()
|
||||
|
@ -96,9 +96,7 @@ public extension Alert {
|
|||
window.resignKey()
|
||||
window.addSubview(view)
|
||||
if #available(iOS 13.0, *) {
|
||||
window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
window.windowScene = cfg.windowScene ?? .currentWindowScene
|
||||
}
|
||||
view.transform = .init(scaleX: 1.2, y: 1.2)
|
||||
view.alpha = 0
|
||||
|
@ -234,7 +232,7 @@ public extension Alert {
|
|||
|
||||
|
||||
// MARK: - 创建和设置
|
||||
internal extension Alert {
|
||||
extension Alert {
|
||||
|
||||
/// 插入一个按钮
|
||||
/// - Parameter style: 样式
|
||||
|
@ -338,19 +336,13 @@ fileprivate extension Alert {
|
|||
alertWindow = w
|
||||
w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0)
|
||||
// 比原生alert层级低一点
|
||||
w.windowLevel = .proAlert
|
||||
w.windowLevel = .alertForProHUD
|
||||
return w
|
||||
}
|
||||
|
||||
class func privRemoveItemFromArray(alert: Alert) {
|
||||
if alerts.count > 1 {
|
||||
for (i, a) in alerts.enumerated() {
|
||||
if a == alert {
|
||||
if i < alerts.count {
|
||||
alerts.remove(at: i)
|
||||
}
|
||||
}
|
||||
}
|
||||
alerts.removeAll { $0 == alert }
|
||||
privUpdateAlertsLayout()
|
||||
} else if alerts.count == 1 {
|
||||
alerts.removeAll()
|
||||
|
|
|
@ -47,15 +47,15 @@ public extension Alert {
|
|||
// MARK: 私有
|
||||
|
||||
/// 持续时间
|
||||
internal var durationBlock: DispatchWorkItem?
|
||||
var durationBlock: DispatchWorkItem?
|
||||
|
||||
/// 强制退出按钮
|
||||
internal var hideTimerBlock: DispatchWorkItem?
|
||||
var hideTimerBlock: DispatchWorkItem?
|
||||
|
||||
/// 强制退出代码
|
||||
internal var forceQuitCallback: (() -> Void)?
|
||||
var forceQuitCallback: (() -> Void)?
|
||||
|
||||
internal func updateDuration() {
|
||||
func updateDuration() {
|
||||
durationBlock?.cancel()
|
||||
if let t = duration ?? scene.alertDuration, t > 0 {
|
||||
durationBlock = DispatchWorkItem(block: { [weak self] in
|
||||
|
|
|
@ -51,7 +51,7 @@ public extension ProHUD.Configuration {
|
|||
|
||||
|
||||
// MARK: - 内部调用
|
||||
internal extension ProHUD.Configuration.Guard {
|
||||
extension ProHUD.Configuration.Guard {
|
||||
|
||||
var reloadData: (ProHUD.Guard) -> Void {
|
||||
return privReloadData
|
||||
|
|
|
@ -119,21 +119,8 @@ public extension Guard {
|
|||
}
|
||||
if let vc = viewController ?? cfg.rootViewController {
|
||||
return f(vc)
|
||||
} else {
|
||||
// 尝试获取RootVC
|
||||
let ws = UIApplication.shared.windows.filter { (w) -> Bool in
|
||||
// 去除掉诸如 UITextEffectsWindow 这样的类,去掉隐藏的Window
|
||||
if "\(type(of:w))" == "UIWindow" && w.isHidden == false && w.windowLevel == .normal {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for w in ws {
|
||||
if let vc = w.rootViewController {
|
||||
return f(vc)
|
||||
}
|
||||
}
|
||||
} else if let vc = UIViewController.currentRootViewController {
|
||||
return f(vc)
|
||||
debug("⚠️自动获取根控制器失败,请设置根控制器或者传入需要push到的控制器")
|
||||
}
|
||||
return self
|
||||
|
@ -200,23 +187,15 @@ public extension Guard {
|
|||
/// 查找指定的实例
|
||||
/// - Parameter identifier: 指定实例的标识
|
||||
class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] {
|
||||
var gg = [Guard]()
|
||||
if let vc = viewController ?? cfg.rootViewController {
|
||||
for child in vc.children {
|
||||
if child.isKind(of: Guard.self) {
|
||||
if let g = child as? Guard {
|
||||
if let id = identifier {
|
||||
if g.identifier == id {
|
||||
gg.append(g)
|
||||
}
|
||||
} else {
|
||||
gg.append(g)
|
||||
}
|
||||
}
|
||||
}
|
||||
guard let vc = viewController ?? cfg.rootViewController ?? UIViewController.currentRootViewController else { return [] }
|
||||
return vc.children.compactMap { (child) -> Guard? in
|
||||
guard let child = child as? Guard else { return nil }
|
||||
if let id = identifier, child.identifier == id {
|
||||
return child
|
||||
} else {
|
||||
return child
|
||||
}
|
||||
}
|
||||
return gg
|
||||
}
|
||||
|
||||
/// 查找指定的实例
|
||||
|
@ -249,7 +228,7 @@ public extension Guard {
|
|||
|
||||
|
||||
// MARK: - 创建和设置
|
||||
internal extension Guard {
|
||||
extension Guard {
|
||||
|
||||
/// 加载一个标题
|
||||
/// - Parameter text: 文本
|
||||
|
|
|
@ -12,7 +12,7 @@ public extension Guard {
|
|||
|
||||
struct ViewModel {
|
||||
|
||||
internal weak var vc: Guard?
|
||||
weak var vc: Guard?
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
@available(iOS 13.0, *) fileprivate var sharedWindowScene: UIWindowScene?
|
||||
|
||||
/// HUD配置
|
||||
public extension ProHUD {
|
||||
|
@ -19,22 +20,14 @@ public extension ProHUD {
|
|||
/// 根控制器,默认可以自动获取,如果获取失败请主动设置
|
||||
public var rootViewController: UIViewController?
|
||||
|
||||
/// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置
|
||||
@available(iOS 13.0, *)
|
||||
private static var sharedWindowScene: UIWindowScene?
|
||||
|
||||
/// iOS13必须设置此值,默认可以自动获取,如果获取失败请主动设置
|
||||
@available(iOS 13.0, *)
|
||||
public var windowScene: UIWindowScene? {
|
||||
set {
|
||||
Configuration.sharedWindowScene = newValue
|
||||
}
|
||||
get {
|
||||
return Configuration.sharedWindowScene
|
||||
}
|
||||
set { sharedWindowScene = newValue }
|
||||
get { sharedWindowScene }
|
||||
}
|
||||
|
||||
/// 动态颜色(适配iOS13)
|
||||
/// 动态颜色
|
||||
public lazy var dynamicColor: UIColor = {
|
||||
if #available(iOS 13.0, *) {
|
||||
let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in
|
||||
|
|
|
@ -85,9 +85,7 @@ internal extension HUDController {
|
|||
}
|
||||
|
||||
@objc func didTappedButton(_ sender: UIButton) {
|
||||
if let ac = buttonEvents[sender] {
|
||||
ac()
|
||||
}
|
||||
buttonEvents[sender]?()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,8 +115,8 @@ public extension LoadingAnimationView {
|
|||
v.updateProgress(progress: progress)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/// 旋转动画
|
||||
public protocol LoadingRotateAnimation: LoadingAnimationView {}
|
||||
|
|
|
@ -15,16 +15,16 @@ extension String {
|
|||
|
||||
extension ProHUD {
|
||||
static var safeAreaInsets: UIEdgeInsets {
|
||||
return Inspire.shared.screen.safeAreaInsets
|
||||
Inspire.shared.screen.safeAreaInsets
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func == (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool {
|
||||
return left.identifier == right.identifier
|
||||
left.identifier == right.identifier
|
||||
}
|
||||
|
||||
|
||||
func != (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool {
|
||||
return left.identifier != right.identifier
|
||||
left.identifier != right.identifier
|
||||
}
|
||||
|
|
|
@ -12,22 +12,23 @@ public class ProHUD {
|
|||
|
||||
public static let shared = ProHUD()
|
||||
|
||||
public var config: Configuration {
|
||||
return cfg
|
||||
}
|
||||
public var config: Configuration { cfg }
|
||||
|
||||
public struct Scene {
|
||||
private var id = "unknown"
|
||||
public var identifier: String {
|
||||
return id
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Scene
|
||||
public extension ProHUD {
|
||||
|
||||
struct Scene {
|
||||
public let identifier: String
|
||||
public var image: UIImage?
|
||||
public var alertDuration: TimeInterval?
|
||||
public var toastDuration: TimeInterval? = 3
|
||||
public var title: String?
|
||||
public var message: String?
|
||||
init() {
|
||||
|
||||
public init(identifier: String) {
|
||||
self.identifier = identifier
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,10 +36,6 @@ public class ProHUD {
|
|||
|
||||
// 默认场景,可直接在项目工程中覆写场景参数
|
||||
public extension ProHUD.Scene {
|
||||
init(identifier: String) {
|
||||
self.init()
|
||||
id = identifier
|
||||
}
|
||||
static var `default`: ProHUD.Scene {
|
||||
var scene = ProHUD.Scene.init(identifier: "prohud.default")
|
||||
scene.image = ProHUD.image(named: "prohud.note")
|
||||
|
|
|
@ -53,7 +53,7 @@ public extension ProHUD.Configuration {
|
|||
|
||||
|
||||
// MARK: - 内部调用
|
||||
internal extension ProHUD.Configuration.Toast {
|
||||
extension ProHUD.Configuration.Toast {
|
||||
|
||||
var reloadData: (ProHUD.Toast) -> Void {
|
||||
return privReloadData
|
||||
|
|
|
@ -13,7 +13,7 @@ public typealias Toast = ProHUD.Toast
|
|||
public extension ProHUD {
|
||||
class Toast: HUDController {
|
||||
|
||||
internal static var toasts = [Toast]()
|
||||
static var toasts = [Toast]()
|
||||
|
||||
public var window: UIWindow?
|
||||
|
||||
|
@ -66,7 +66,7 @@ public extension ProHUD {
|
|||
/// 视图模型
|
||||
public var vm = ViewModel()
|
||||
|
||||
internal var maxY = CGFloat(0)
|
||||
var maxY = CGFloat(0)
|
||||
|
||||
// MARK: 生命周期
|
||||
|
||||
|
@ -120,9 +120,7 @@ public extension Toast {
|
|||
let window = UIWindow(frame: .zero)
|
||||
self.window = window
|
||||
if #available(iOS 13.0, *) {
|
||||
window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
window.windowScene = cfg.windowScene ?? .currentWindowScene
|
||||
}
|
||||
window.windowLevel = .proToast
|
||||
window.backgroundColor = .clear
|
||||
|
@ -270,11 +268,7 @@ public extension Toast {
|
|||
class func pop(_ toast: Toast) {
|
||||
toast.willDisappearCallback?()
|
||||
if toasts.count > 1 {
|
||||
for (i, t) in toasts.enumerated() {
|
||||
if t == toast {
|
||||
toasts.remove(at: i)
|
||||
}
|
||||
}
|
||||
toasts.removeAll { $0 == toast }
|
||||
privUpdateToastsLayout()
|
||||
} else if toasts.count == 1 {
|
||||
toasts.removeAll()
|
||||
|
|
|
@ -47,12 +47,12 @@ public extension Toast {
|
|||
// MARK: 私有
|
||||
|
||||
/// 持续时间
|
||||
internal var durationBlock: DispatchWorkItem?
|
||||
var durationBlock: DispatchWorkItem?
|
||||
|
||||
/// 点击事件回调
|
||||
internal var tapCallback: (() -> Void)?
|
||||
var tapCallback: (() -> Void)?
|
||||
|
||||
internal func updateDuration() {
|
||||
func updateDuration() {
|
||||
durationBlock?.cancel()
|
||||
if let t = duration ?? scene.toastDuration, t > 0 {
|
||||
durationBlock = DispatchWorkItem(block: { [weak self] in
|
||||
|
|
Loading…
Reference in New Issue