支持继承,可以设置条件显示

This commit is contained in:
xaoxuu 2023-08-07 15:52:47 +08:00
parent 1d4465b496
commit 320e4db560
10 changed files with 54 additions and 35 deletions

View File

@ -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 = "<group>"; };
CD9C7B1D28CB8972006190CD /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
CDA83DB828C601E60025F0DF /* TableHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableHeaderView.swift; sourceTree = "<group>"; };
CDB6A29F28BC5F0F00DEC80D /* ProHUD */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = ProHUD; path = ..; sourceTree = "<group>"; };
CDB7A1CF28C32A7400E034D8 /* AlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertVC.swift; sourceTree = "<group>"; };
/* 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 = "<group>";
};
CDB6A29E28BC5F0F00DEC80D /* Packages */ = {
isa = PBXGroup;
children = (
CDB6A29F28BC5F0F00DEC80D /* ProHUD */,
);
name = Packages;
sourceTree = "<group>";
};
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 */;

View File

@ -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()

View File

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

View File

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

View File

@ -9,6 +9,9 @@ import UIKit
public class Configuration: NSObject {
///
public static var isEnabled: Bool = true
/// log
public static var enablePrint = true

View File

@ -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()
// }
//}

View File

@ -7,7 +7,7 @@
import UIKit
public class Sheet: Controller {
open class Sheet: Controller {
weak var window: SheetWindow?

View File

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

View File

@ -7,7 +7,7 @@
import UIKit
public class Toast: Controller {
open class Toast: Controller {
weak var window: ToastWindow?

View File

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