代码优化

This commit is contained in:
xaoxuu 2021-07-20 16:04:39 +08:00
parent 6b870e4ba8
commit 014e9abdbe
27 changed files with 134 additions and 121 deletions

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -43,8 +43,13 @@ class BaseListVC: UIViewController {
var secs = [Section]() var secs = [Section]()
lazy var tableView: UITableView = { 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 return tv
}() }()

View File

@ -35,6 +35,11 @@ class TestGuardVC: BaseListVC {
vm.add(action: .cancel, title: "取消", handler: nil) vm.add(action: .cancel, title: "取消", handler: nil)
} }
} }
DispatchQueue.main.asyncAfter(deadline: .now()+1) {
Guard.find("del") { vc in
vc.pop()
}
}
} }
// MARK: // MARK:

View File

@ -1,5 +1,5 @@
PODS: PODS:
- Inspire (2.0.0) - Inspire (2.1.0)
- ProHUD (1.0): - ProHUD (1.0):
- Inspire - Inspire
- SnapKit (= 5.0) - SnapKit (= 5.0)
@ -21,10 +21,10 @@ EXTERNAL SOURCES:
:path: ".." :path: ".."
SPEC CHECKSUMS: SPEC CHECKSUMS:
Inspire: 7556357c9c90d5e886f3be5d29fe1e0222b694e1 Inspire: 087dce1e4ff902d26d79bd3453352af09411c172
ProHUD: 7128b55036885ac4f8b4d0b0783ee6f8eb3a2ea9 ProHUD: 7128b55036885ac4f8b4d0b0783ee6f8eb3a2ea9
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
PODFILE CHECKSUM: 80148eec6ba2e9631b208c7b277316b6c551afc4 PODFILE CHECKSUM: 80148eec6ba2e9631b208c7b277316b6c551afc4
COCOAPODS: 1.9.2 COCOAPODS: 1.10.1

4
Example-Old/README.md Normal file
View File

@ -0,0 +1,4 @@
# 使用 AppDelegate 的项目

View File

@ -19,7 +19,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let scene = (scene as? UIWindowScene) else { return } guard let scene = (scene as? UIWindowScene) else { return }
print(scene.statusBarManager?.statusBarFrame)
let rootVC = RootVC() let rootVC = RootVC()
window?.rootViewController = rootVC window?.rootViewController = rootVC
window?.makeKeyAndVisible() window?.makeKeyAndVisible()

View File

@ -0,0 +1,2 @@
# 使用 SceneDelegate 的项目

View File

@ -10,7 +10,7 @@ let package = Package(
], ],
dependencies: [ dependencies: [
.package(url: "https://github.com/SnapKit/SnapKit.git", "5.0.0" ..< "6.0.0"), .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: [ targets: [
.target( .target(

View File

@ -23,8 +23,8 @@
CDB6A07B22EEF06500AF6CF0 /* HUDController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07A22EEF06500AF6CF0 /* HUDController.swift */; }; CDB6A07B22EEF06500AF6CF0 /* HUDController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07A22EEF06500AF6CF0 /* HUDController.swift */; };
CDB6A07D22EEF19D00AF6CF0 /* HUDConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07C22EEF19D00AF6CF0 /* HUDConfig.swift */; }; CDB6A07D22EEF19D00AF6CF0 /* HUDConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB6A07C22EEF19D00AF6CF0 /* HUDConfig.swift */; };
CDC39CFD22FD6DDF0070E914 /* GuardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC39CFC22FD6DDF0070E914 /* GuardModel.swift */; }; CDC39CFD22FD6DDF0070E914 /* GuardModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDC39CFC22FD6DDF0070E914 /* GuardModel.swift */; };
CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */; }; CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BE82490A19100CC6FE6 /* SnapKit */; };
CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */; }; CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */ = {isa = PBXBuildFile; productRef = CDC67BEB2490A1D100CC6FE6 /* Inspire */; };
CDF2C58924A0572C002ECDD5 /* HUDUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF2C58824A0572C002ECDD5 /* HUDUtils.swift */; }; CDF2C58924A0572C002ECDD5 /* HUDUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF2C58824A0572C002ECDD5 /* HUDUtils.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -58,8 +58,8 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
CDC67BEC2490A1D100CC6FE6 /* BuildFile in Frameworks */, CDC67BEC2490A1D100CC6FE6 /* Inspire in Frameworks */,
CDC67BE92490A19100CC6FE6 /* BuildFile in Frameworks */, CDC67BE92490A19100CC6FE6 /* SnapKit in Frameworks */,
36CB9DEED3C3E823FE7B1C75 /* Pods_ProHUD.framework in Frameworks */, 36CB9DEED3C3E823FE7B1C75 /* Pods_ProHUD.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -189,8 +189,8 @@
); );
name = ProHUD; name = ProHUD;
packageProductDependencies = ( packageProductDependencies = (
CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */, CDC67BE82490A19100CC6FE6 /* SnapKit */,
CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */, CDC67BEB2490A1D100CC6FE6 /* Inspire */,
); );
productName = ProHUD; productName = ProHUD;
productReference = CD95D21C22E72C4C007559A3 /* ProHUD.framework */; productReference = CD95D21C22E72C4C007559A3 /* ProHUD.framework */;
@ -221,8 +221,8 @@
); );
mainGroup = CD95D21222E72C4C007559A3; mainGroup = CD95D21222E72C4C007559A3;
packageReferences = ( packageReferences = (
CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */, CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */,
CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */, CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */,
); );
productRefGroup = CD95D21D22E72C4C007559A3 /* Products */; productRefGroup = CD95D21D22E72C4C007559A3 /* Products */;
projectDirPath = ""; projectDirPath = "";
@ -493,7 +493,7 @@
/* End XCConfigurationList section */ /* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */ /* Begin XCRemoteSwiftPackageReference section */
CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */ = { CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit"; repositoryURL = "https://github.com/SnapKit/SnapKit";
requirement = { requirement = {
@ -501,25 +501,25 @@
minimumVersion = 5.0.1; minimumVersion = 5.0.1;
}; };
}; };
CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */ = { CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */ = {
isa = XCRemoteSwiftPackageReference; isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/xaoxuu/Inspire"; repositoryURL = "https://github.com/xaoxuu/Inspire";
requirement = { requirement = {
kind = upToNextMajorVersion; kind = upToNextMajorVersion;
minimumVersion = 2.0.0; minimumVersion = 2.1.0;
}; };
}; };
/* End XCRemoteSwiftPackageReference section */ /* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */ /* Begin XCSwiftPackageProductDependency section */
CDC67BE82490A19100CC6FE6 /* SwiftPackageProductDependency */ = { CDC67BE82490A19100CC6FE6 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
package = CDC67BE72490A19100CC6FE6 /* RemoteSwiftPackageReference */; package = CDC67BE72490A19100CC6FE6 /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit; productName = SnapKit;
}; };
CDC67BEB2490A1D100CC6FE6 /* SwiftPackageProductDependency */ = { CDC67BEB2490A1D100CC6FE6 /* Inspire */ = {
isa = XCSwiftPackageProductDependency; isa = XCSwiftPackageProductDependency;
package = CDC67BEA2490A1D100CC6FE6 /* RemoteSwiftPackageReference */; package = CDC67BEA2490A1D100CC6FE6 /* XCRemoteSwiftPackageReference "Inspire" */;
productName = Inspire; productName = Inspire;
}; };
/* End XCSwiftPackageProductDependency section */ /* End XCSwiftPackageProductDependency section */

View File

@ -10,7 +10,7 @@ import UIKit
import SnapKit import SnapKit
public extension UIWindow.Level { public extension UIWindow.Level {
static let proAlert = UIWindow.Level.alert - 1 static let alertForProHUD = UIWindow.Level.alert - 1
} }
public extension ProHUD.Configuration { public extension ProHUD.Configuration {
@ -75,7 +75,7 @@ public extension ProHUD.Configuration {
// MARK: - // MARK: -
internal extension ProHUD.Configuration.Alert { extension ProHUD.Configuration.Alert {
var reloadData: (ProHUD.Alert) -> Void { var reloadData: (ProHUD.Alert) -> Void {
return privReloadData return privReloadData

View File

@ -14,9 +14,9 @@ public typealias Alert = ProHUD.Alert
public extension ProHUD { public extension ProHUD {
class Alert: HUDController { 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() public var contentView = createBlurView()
@ -96,9 +96,7 @@ public extension Alert {
window.resignKey() window.resignKey()
window.addSubview(view) window.addSubview(view)
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene window.windowScene = cfg.windowScene ?? .currentWindowScene
} else {
// Fallback on earlier versions
} }
view.transform = .init(scaleX: 1.2, y: 1.2) view.transform = .init(scaleX: 1.2, y: 1.2)
view.alpha = 0 view.alpha = 0
@ -234,7 +232,7 @@ public extension Alert {
// MARK: - // MARK: -
internal extension Alert { extension Alert {
/// ///
/// - Parameter style: /// - Parameter style:
@ -338,19 +336,13 @@ fileprivate extension Alert {
alertWindow = w alertWindow = w
w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0) w.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0)
// alert // alert
w.windowLevel = .proAlert w.windowLevel = .alertForProHUD
return w return w
} }
class func privRemoveItemFromArray(alert: Alert) { class func privRemoveItemFromArray(alert: Alert) {
if alerts.count > 1 { if alerts.count > 1 {
for (i, a) in alerts.enumerated() { alerts.removeAll { $0 == alert }
if a == alert {
if i < alerts.count {
alerts.remove(at: i)
}
}
}
privUpdateAlertsLayout() privUpdateAlertsLayout()
} else if alerts.count == 1 { } else if alerts.count == 1 {
alerts.removeAll() alerts.removeAll()

View File

@ -47,15 +47,15 @@ public extension Alert {
// MARK: // 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() durationBlock?.cancel()
if let t = duration ?? scene.alertDuration, t > 0 { if let t = duration ?? scene.alertDuration, t > 0 {
durationBlock = DispatchWorkItem(block: { [weak self] in durationBlock = DispatchWorkItem(block: { [weak self] in

View File

@ -51,7 +51,7 @@ public extension ProHUD.Configuration {
// MARK: - // MARK: -
internal extension ProHUD.Configuration.Guard { extension ProHUD.Configuration.Guard {
var reloadData: (ProHUD.Guard) -> Void { var reloadData: (ProHUD.Guard) -> Void {
return privReloadData return privReloadData

View File

@ -119,21 +119,8 @@ public extension Guard {
} }
if let vc = viewController ?? cfg.rootViewController { if let vc = viewController ?? cfg.rootViewController {
return f(vc) return f(vc)
} else { } else if let vc = UIViewController.currentRootViewController {
// 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) return f(vc)
}
}
debug("自动获取根控制器失败请设置根控制器或者传入需要push到的控制器") debug("自动获取根控制器失败请设置根控制器或者传入需要push到的控制器")
} }
return self return self
@ -200,24 +187,16 @@ public extension Guard {
/// ///
/// - Parameter identifier: /// - Parameter identifier:
class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] { class func find(_ identifier: String?, from viewController: UIViewController? = nil) -> [Guard] {
var gg = [Guard]() guard let vc = viewController ?? cfg.rootViewController ?? UIViewController.currentRootViewController else { return [] }
if let vc = viewController ?? cfg.rootViewController { return vc.children.compactMap { (child) -> Guard? in
for child in vc.children { guard let child = child as? Guard else { return nil }
if child.isKind(of: Guard.self) { if let id = identifier, child.identifier == id {
if let g = child as? Guard { return child
if let id = identifier {
if g.identifier == id {
gg.append(g)
}
} else { } else {
gg.append(g) return child
} }
} }
} }
}
}
return gg
}
/// ///
/// - Parameter identifier: /// - Parameter identifier:
@ -249,7 +228,7 @@ public extension Guard {
// MARK: - // MARK: -
internal extension Guard { extension Guard {
/// ///
/// - Parameter text: /// - Parameter text:

View File

@ -12,7 +12,7 @@ public extension Guard {
struct ViewModel { struct ViewModel {
internal weak var vc: Guard? weak var vc: Guard?
} }

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
@available(iOS 13.0, *) fileprivate var sharedWindowScene: UIWindowScene?
/// HUD /// HUD
public extension ProHUD { public extension ProHUD {
@ -19,22 +20,14 @@ public extension ProHUD {
/// ///
public var rootViewController: UIViewController? public var rootViewController: UIViewController?
/// iOS13
@available(iOS 13.0, *)
private static var sharedWindowScene: UIWindowScene?
/// iOS13 /// iOS13
@available(iOS 13.0, *) @available(iOS 13.0, *)
public var windowScene: UIWindowScene? { public var windowScene: UIWindowScene? {
set { set { sharedWindowScene = newValue }
Configuration.sharedWindowScene = newValue get { sharedWindowScene }
}
get {
return Configuration.sharedWindowScene
}
} }
/// iOS13 ///
public lazy var dynamicColor: UIColor = { public lazy var dynamicColor: UIColor = {
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in let color = UIColor { (traitCollection: UITraitCollection) -> UIColor in

View File

@ -85,9 +85,7 @@ internal extension HUDController {
} }
@objc func didTappedButton(_ sender: UIButton) { @objc func didTappedButton(_ sender: UIButton) {
if let ac = buttonEvents[sender] { buttonEvents[sender]?()
ac()
}
} }
} }
@ -117,8 +115,8 @@ public extension LoadingAnimationView {
v.updateProgress(progress: progress) v.updateProgress(progress: progress)
} }
} }
} }
} }
/// ///
public protocol LoadingRotateAnimation: LoadingAnimationView {} public protocol LoadingRotateAnimation: LoadingAnimationView {}

View File

@ -15,16 +15,16 @@ extension String {
extension ProHUD { extension ProHUD {
static var safeAreaInsets: UIEdgeInsets { static var safeAreaInsets: UIEdgeInsets {
return Inspire.shared.screen.safeAreaInsets Inspire.shared.screen.safeAreaInsets
} }
} }
func == (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool { 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 { func != (left: ProHUD.Scene, right: ProHUD.Scene) -> Bool {
return left.identifier != right.identifier left.identifier != right.identifier
} }

View File

@ -12,22 +12,23 @@ public class ProHUD {
public static let shared = ProHUD() public static let shared = ProHUD()
public var config: Configuration { public var config: Configuration { cfg }
return 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 image: UIImage?
public var alertDuration: TimeInterval? public var alertDuration: TimeInterval?
public var toastDuration: TimeInterval? = 3 public var toastDuration: TimeInterval? = 3
public var title: String? public var title: String?
public var message: String? public var message: String?
init() { public init(identifier: String) {
self.identifier = identifier
} }
} }
@ -35,10 +36,6 @@ public class ProHUD {
// //
public extension ProHUD.Scene { public extension ProHUD.Scene {
init(identifier: String) {
self.init()
id = identifier
}
static var `default`: ProHUD.Scene { static var `default`: ProHUD.Scene {
var scene = ProHUD.Scene.init(identifier: "prohud.default") var scene = ProHUD.Scene.init(identifier: "prohud.default")
scene.image = ProHUD.image(named: "prohud.note") scene.image = ProHUD.image(named: "prohud.note")

View File

@ -53,7 +53,7 @@ public extension ProHUD.Configuration {
// MARK: - // MARK: -
internal extension ProHUD.Configuration.Toast { extension ProHUD.Configuration.Toast {
var reloadData: (ProHUD.Toast) -> Void { var reloadData: (ProHUD.Toast) -> Void {
return privReloadData return privReloadData

View File

@ -13,7 +13,7 @@ public typealias Toast = ProHUD.Toast
public extension ProHUD { public extension ProHUD {
class Toast: HUDController { class Toast: HUDController {
internal static var toasts = [Toast]() static var toasts = [Toast]()
public var window: UIWindow? public var window: UIWindow?
@ -66,7 +66,7 @@ public extension ProHUD {
/// ///
public var vm = ViewModel() public var vm = ViewModel()
internal var maxY = CGFloat(0) var maxY = CGFloat(0)
// MARK: // MARK:
@ -120,9 +120,7 @@ public extension Toast {
let window = UIWindow(frame: .zero) let window = UIWindow(frame: .zero)
self.window = window self.window = window
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
window.windowScene = cfg.windowScene ?? UIApplication.shared.windows.first?.windowScene window.windowScene = cfg.windowScene ?? .currentWindowScene
} else {
// Fallback on earlier versions
} }
window.windowLevel = .proToast window.windowLevel = .proToast
window.backgroundColor = .clear window.backgroundColor = .clear
@ -270,11 +268,7 @@ public extension Toast {
class func pop(_ toast: Toast) { class func pop(_ toast: Toast) {
toast.willDisappearCallback?() toast.willDisappearCallback?()
if toasts.count > 1 { if toasts.count > 1 {
for (i, t) in toasts.enumerated() { toasts.removeAll { $0 == toast }
if t == toast {
toasts.remove(at: i)
}
}
privUpdateToastsLayout() privUpdateToastsLayout()
} else if toasts.count == 1 { } else if toasts.count == 1 {
toasts.removeAll() toasts.removeAll()

View File

@ -47,12 +47,12 @@ public extension Toast {
// MARK: // MARK:
/// ///
internal var durationBlock: DispatchWorkItem? var durationBlock: DispatchWorkItem?
/// ///
internal var tapCallback: (() -> Void)? var tapCallback: (() -> Void)?
internal func updateDuration() { func updateDuration() {
durationBlock?.cancel() durationBlock?.cancel()
if let t = duration ?? scene.toastDuration, t > 0 { if let t = duration ?? scene.toastDuration, t > 0 {
durationBlock = DispatchWorkItem(block: { [weak self] in durationBlock = DispatchWorkItem(block: { [weak self] in