diff --git a/PHDemo/PHDemo.xcodeproj/project.pbxproj b/PHDemo/PHDemo.xcodeproj/project.pbxproj index 0e6cd5f..ce3fa74 100644 --- a/PHDemo/PHDemo.xcodeproj/project.pbxproj +++ b/PHDemo/PHDemo.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 55; + objectVersion = 60; objects = { /* Begin PBXBuildFile section */ @@ -22,6 +22,7 @@ CDA83DB928C601E60025F0DF /* TableHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA83DB828C601E60025F0DF /* TableHeaderView.swift */; }; CDB6A2A228BC5F4600DEC80D /* ProHUD in Frameworks */ = {isa = PBXBuildFile; productRef = CDB6A2A128BC5F4600DEC80D /* ProHUD */; }; CDB7A1D028C32A7400E034D8 /* AlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB7A1CF28C32A7400E034D8 /* AlertVC.swift */; }; + CDCBAEC42A80D6FD00C30DE5 /* ProHUD in Frameworks */ = {isa = PBXBuildFile; productRef = CDCBAEC32A80D6FD00C30DE5 /* ProHUD */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -38,7 +39,6 @@ CD8EEF4828BC5C7300E660EA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; CD9C7B1D28CB8972006190CD /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; CDA83DB828C601E60025F0DF /* TableHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableHeaderView.swift; sourceTree = ""; }; - CDB6A29F28BC5F0F00DEC80D /* ProHUD */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = ProHUD; path = ..; sourceTree = ""; }; CDB7A1CF28C32A7400E034D8 /* AlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertVC.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -47,6 +47,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + CDCBAEC42A80D6FD00C30DE5 /* ProHUD in Frameworks */, CD891BCD2A80B58E00848BBC /* SnapKit in Frameworks */, CDB6A2A228BC5F4600DEC80D /* ProHUD in Frameworks */, CD6AE8A32A7CC1BA0044E53D /* SnapKit in Frameworks */, @@ -59,7 +60,6 @@ CD8EEF2E28BC5C7200E660EA = { isa = PBXGroup; children = ( - CDB6A29E28BC5F0F00DEC80D /* Packages */, CD8EEF3928BC5C7200E660EA /* PHDemo */, CD8EEF3828BC5C7200E660EA /* Products */, CDB6A2A028BC5F4600DEC80D /* Frameworks */, @@ -94,14 +94,6 @@ path = PHDemo; sourceTree = ""; }; - CDB6A29E28BC5F0F00DEC80D /* Packages */ = { - isa = PBXGroup; - children = ( - CDB6A29F28BC5F0F00DEC80D /* ProHUD */, - ); - name = Packages; - sourceTree = ""; - }; CDB6A2A028BC5F4600DEC80D /* Frameworks */ = { isa = PBXGroup; children = ( @@ -129,6 +121,7 @@ CDB6A2A128BC5F4600DEC80D /* ProHUD */, CD6AE8A22A7CC1BA0044E53D /* SnapKit */, CD891BCC2A80B58E00848BBC /* SnapKit */, + CDCBAEC32A80D6FD00C30DE5 /* ProHUD */, ); productName = PHDemo; productReference = CD8EEF3728BC5C7200E660EA /* PHDemo.app */; @@ -160,6 +153,7 @@ mainGroup = CD8EEF2E28BC5C7200E660EA; packageReferences = ( CD891BCB2A80B58E00848BBC /* XCRemoteSwiftPackageReference "SnapKit" */, + CDCBAEC22A80D6FD00C30DE5 /* XCLocalSwiftPackageReference ".." */, ); productRefGroup = CD8EEF3828BC5C7200E660EA /* Products */; projectDirPath = ""; @@ -417,6 +411,13 @@ }; /* End XCConfigurationList section */ +/* Begin XCLocalSwiftPackageReference section */ + CDCBAEC22A80D6FD00C30DE5 /* XCLocalSwiftPackageReference ".." */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ..; + }; +/* End XCLocalSwiftPackageReference section */ + /* Begin XCRemoteSwiftPackageReference section */ CD891BCB2A80B58E00848BBC /* XCRemoteSwiftPackageReference "SnapKit" */ = { isa = XCRemoteSwiftPackageReference; @@ -442,6 +443,10 @@ isa = XCSwiftPackageProductDependency; productName = ProHUD; }; + CDCBAEC32A80D6FD00C30DE5 /* ProHUD */ = { + isa = XCSwiftPackageProductDependency; + productName = ProHUD; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = CD8EEF2F28BC5C7200E660EA /* Project object */; diff --git a/PHDemo/PHDemo/ToastVC.swift b/PHDemo/PHDemo/ToastVC.swift index 6aa8082..2f8b9be 100644 --- a/PHDemo/PHDemo/ToastVC.swift +++ b/PHDemo/PHDemo/ToastVC.swift @@ -30,6 +30,17 @@ func updateProgress(in duration: TimeInterval, callback: @escaping (_ percent: C } } +let isTesting: Bool = false + +class TestToast: Toast { + override func push() { + guard isTesting else { + return + } + super.push() + } +} + class ToastVC: ListVC { @@ -53,7 +64,7 @@ class ToastVC: ListVC { list.add(title: "默认布局") { section in section.add(title: "标题 + 正文") { - Toast(.title(title).message(message)).push() + TestToast(.title(title).message(message)).push() } section.add(title: "一段长文本") { Toast(.message(message)).push() diff --git a/Sources/ProHUD/Alert/Alert.swift b/Sources/ProHUD/Alert/Alert.swift index 88b785b..c3f8119 100644 --- a/Sources/ProHUD/Alert/Alert.swift +++ b/Sources/ProHUD/Alert/Alert.swift @@ -7,7 +7,7 @@ import UIKit -public class Alert: ProHUD.Controller { +open class Alert: ProHUD.Controller { public lazy var config: Configuration = { var cfg = Configuration() @@ -107,7 +107,7 @@ public class Alert: ProHUD.Controller { navEvents[.onViewDidLoad]?(self) } - required init?(coder: NSCoder) { + required public init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/Sources/ProHUD/Alert/AlertManager.swift b/Sources/ProHUD/Alert/AlertManager.swift index ec07a4e..424109f 100644 --- a/Sources/ProHUD/Alert/AlertManager.swift +++ b/Sources/ProHUD/Alert/AlertManager.swift @@ -8,10 +8,9 @@ import UIKit extension Alert: HUD { - public func push(scene: UIWindowScene?) { - push() - } - public func push() { + + @objc open func push() { + guard Configuration.isEnabled else { return } let window = createAttachedWindowIfNotExists() guard window.alerts.contains(self) == false else { return @@ -38,7 +37,7 @@ extension Alert: HUD { Alert.updateAlertsLayout(alerts: window.alerts) } - public func pop() { + @objc open func pop() { navEvents[.onViewWillDisappear]?(self) let window = window ?? createAttachedWindowIfNotExists() Alert.removeAlert(alert: self) diff --git a/Sources/ProHUD/Core/Models/Configuration.swift b/Sources/ProHUD/Core/Models/Configuration.swift index c9c46f3..ce76105 100644 --- a/Sources/ProHUD/Core/Models/Configuration.swift +++ b/Sources/ProHUD/Core/Models/Configuration.swift @@ -9,6 +9,9 @@ import UIKit public class Configuration: NSObject { + /// 全局功能开关 + public static var isEnabled: Bool = true + /// 是否允许log输出 public static var enablePrint = true diff --git a/Sources/ProHUD/Core/Protocols/HUD.swift b/Sources/ProHUD/Core/Protocols/HUD.swift index 66e5b98..8c529a5 100644 --- a/Sources/ProHUD/Core/Protocols/HUD.swift +++ b/Sources/ProHUD/Core/Protocols/HUD.swift @@ -7,15 +7,14 @@ import UIKit -public protocol HUD { - func push() - func push(workspace: Workspace?) - func pop() +@objc public protocol HUD { + @objc func push() + @objc func pop() } -public extension HUD { - func push(workspace: Workspace?) { - AppContext.workspace = workspace - push() - } -} +//public extension HUD { +// func push(workspace: Workspace?) { +// AppContext.workspace = workspace +// push() +// } +//} diff --git a/Sources/ProHUD/Sheet/Sheet.swift b/Sources/ProHUD/Sheet/Sheet.swift index 635205e..d17de47 100644 --- a/Sources/ProHUD/Sheet/Sheet.swift +++ b/Sources/ProHUD/Sheet/Sheet.swift @@ -7,7 +7,7 @@ import UIKit -public class Sheet: Controller { +open class Sheet: Controller { weak var window: SheetWindow? diff --git a/Sources/ProHUD/Sheet/SheetManager.swift b/Sources/ProHUD/Sheet/SheetManager.swift index 84ad844..fda51a5 100644 --- a/Sources/ProHUD/Sheet/SheetManager.swift +++ b/Sources/ProHUD/Sheet/SheetManager.swift @@ -9,11 +9,12 @@ import UIKit extension Sheet: HUD { - public func push() { + @objc open func push() { + guard Configuration.isEnabled else { return } SheetWindow.push(sheet: self) } - public func pop() { + @objc open func pop() { SheetWindow.pop(sheet: self) } diff --git a/Sources/ProHUD/Toast/Toast.swift b/Sources/ProHUD/Toast/Toast.swift index b6e5782..ea6254a 100644 --- a/Sources/ProHUD/Toast/Toast.swift +++ b/Sources/ProHUD/Toast/Toast.swift @@ -7,7 +7,7 @@ import UIKit -public class Toast: Controller { +open class Toast: Controller { weak var window: ToastWindow? diff --git a/Sources/ProHUD/Toast/ToastManager.swift b/Sources/ProHUD/Toast/ToastManager.swift index 0607fc5..dec8706 100644 --- a/Sources/ProHUD/Toast/ToastManager.swift +++ b/Sources/ProHUD/Toast/ToastManager.swift @@ -9,11 +9,12 @@ import UIKit extension Toast: HUD { - public func push() { + @objc open func push() { + guard Configuration.isEnabled else { return } ToastWindow.push(toast: self) } - public func pop() { + @objc open func pop() { ToastWindow.pop(toast: self) }