diff --git a/PHDemo/PHDemo.xcodeproj/project.pbxproj b/PHDemo/PHDemo.xcodeproj/project.pbxproj index 915b787..cea1350 100644 --- a/PHDemo/PHDemo.xcodeproj/project.pbxproj +++ b/PHDemo/PHDemo.xcodeproj/project.pbxproj @@ -7,11 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - CD2439342A82164E00A3BBF5 /* CapsuleVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2439332A82164E00A3BBF5 /* CapsuleVC.swift */; }; + CD2439342A82164E00A3BBF5 /* DemoCapsuleVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD2439332A82164E00A3BBF5 /* DemoCapsuleVC.swift */; }; CD6537BF28C3311B00A5981B /* ListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537BE28C3311B00A5981B /* ListModel.swift */; }; CD6537C128C35E1C00A5981B /* ListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C028C35E1C00A5981B /* ListVC.swift */; }; - CD6537C328C35E6200A5981B /* ToastVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C228C35E6200A5981B /* ToastVC.swift */; }; - CD6537C528C35F2C00A5981B /* SheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C428C35F2C00A5981B /* SheetVC.swift */; }; + CD6537C328C35E6200A5981B /* DemoToastVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C228C35E6200A5981B /* DemoToastVC.swift */; }; + CD6537C528C35F2C00A5981B /* DemoSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6537C428C35F2C00A5981B /* DemoSheetVC.swift */; }; CD6AE8A32A7CC1BA0044E53D /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CD6AE8A22A7CC1BA0044E53D /* SnapKit */; }; CD891BCD2A80B58E00848BBC /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = CD891BCC2A80B58E00848BBC /* SnapKit */; }; CD8EEF3B28BC5C7200E660EA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD8EEF3A28BC5C7200E660EA /* AppDelegate.swift */; }; @@ -22,16 +22,16 @@ CD9C7B1E28CB8972006190CD /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9C7B1D28CB8972006190CD /* Extensions.swift */; }; 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 */; }; + CDB7A1D028C32A7400E034D8 /* DemoAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB7A1CF28C32A7400E034D8 /* DemoAlertVC.swift */; }; CDCBAEC42A80D6FD00C30DE5 /* ProHUD in Frameworks */ = {isa = PBXBuildFile; productRef = CDCBAEC32A80D6FD00C30DE5 /* ProHUD */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - CD2439332A82164E00A3BBF5 /* CapsuleVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CapsuleVC.swift; sourceTree = ""; }; + CD2439332A82164E00A3BBF5 /* DemoCapsuleVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoCapsuleVC.swift; sourceTree = ""; }; CD6537BE28C3311B00A5981B /* ListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListModel.swift; sourceTree = ""; }; CD6537C028C35E1C00A5981B /* ListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListVC.swift; sourceTree = ""; }; - CD6537C228C35E6200A5981B /* ToastVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastVC.swift; sourceTree = ""; }; - CD6537C428C35F2C00A5981B /* SheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetVC.swift; sourceTree = ""; }; + CD6537C228C35E6200A5981B /* DemoToastVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoToastVC.swift; sourceTree = ""; }; + CD6537C428C35F2C00A5981B /* DemoSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoSheetVC.swift; sourceTree = ""; }; CD8EEF3728BC5C7200E660EA /* PHDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PHDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; CD8EEF3A28BC5C7200E660EA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; CD8EEF3C28BC5C7200E660EA /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; @@ -41,7 +41,7 @@ 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 = ""; }; - CDB7A1CF28C32A7400E034D8 /* AlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertVC.swift; sourceTree = ""; }; + CDB7A1CF28C32A7400E034D8 /* DemoAlertVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoAlertVC.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,10 +85,10 @@ CDA83DB828C601E60025F0DF /* TableHeaderView.swift */, CD9C7B1D28CB8972006190CD /* Extensions.swift */, CD6537C028C35E1C00A5981B /* ListVC.swift */, - CD6537C228C35E6200A5981B /* ToastVC.swift */, - CDB7A1CF28C32A7400E034D8 /* AlertVC.swift */, - CD6537C428C35F2C00A5981B /* SheetVC.swift */, - CD2439332A82164E00A3BBF5 /* CapsuleVC.swift */, + CD6537C228C35E6200A5981B /* DemoToastVC.swift */, + CDB7A1CF28C32A7400E034D8 /* DemoAlertVC.swift */, + CD6537C428C35F2C00A5981B /* DemoSheetVC.swift */, + CD2439332A82164E00A3BBF5 /* DemoCapsuleVC.swift */, CD8EEF4028BC5C7200E660EA /* Main.storyboard */, CD8EEF4328BC5C7300E660EA /* Assets.xcassets */, CD8EEF4528BC5C7300E660EA /* LaunchScreen.storyboard */, @@ -186,10 +186,10 @@ buildActionMask = 2147483647; files = ( CDA83DB928C601E60025F0DF /* TableHeaderView.swift in Sources */, - CD6537C528C35F2C00A5981B /* SheetVC.swift in Sources */, - CD2439342A82164E00A3BBF5 /* CapsuleVC.swift in Sources */, - CD6537C328C35E6200A5981B /* ToastVC.swift in Sources */, - CDB7A1D028C32A7400E034D8 /* AlertVC.swift in Sources */, + CD6537C528C35F2C00A5981B /* DemoSheetVC.swift in Sources */, + CD2439342A82164E00A3BBF5 /* DemoCapsuleVC.swift in Sources */, + CD6537C328C35E6200A5981B /* DemoToastVC.swift in Sources */, + CDB7A1D028C32A7400E034D8 /* DemoAlertVC.swift in Sources */, CD6537C128C35E1C00A5981B /* ListVC.swift in Sources */, CD8EEF3B28BC5C7200E660EA /* AppDelegate.swift in Sources */, CD8EEF3D28BC5C7200E660EA /* SceneDelegate.swift in Sources */, diff --git a/PHDemo/PHDemo/Base.lproj/Main.storyboard b/PHDemo/PHDemo/Base.lproj/Main.storyboard index a19e0c5..e21af6e 100644 --- a/PHDemo/PHDemo/Base.lproj/Main.storyboard +++ b/PHDemo/PHDemo/Base.lproj/Main.storyboard @@ -2,16 +2,15 @@ - - + - + @@ -60,10 +59,10 @@ - + - + @@ -90,10 +89,10 @@ - + - + @@ -120,10 +119,10 @@ - + - + diff --git a/PHDemo/PHDemo/AlertVC.swift b/PHDemo/PHDemo/DemoAlertVC.swift similarity index 99% rename from PHDemo/PHDemo/AlertVC.swift rename to PHDemo/PHDemo/DemoAlertVC.swift index 54fa2a3..5518e53 100644 --- a/PHDemo/PHDemo/AlertVC.swift +++ b/PHDemo/PHDemo/DemoAlertVC.swift @@ -1,5 +1,5 @@ // -// AlertVC.swift +// DemoAlertVC.swift // PHDemo // // Created by xaoxuu on 2022/9/3. @@ -8,7 +8,7 @@ import UIKit import ProHUD -class AlertVC: ListVC { +class DemoAlertVC: ListVC { override func viewDidLoad() { super.viewDidLoad() @@ -29,9 +29,7 @@ class AlertVC: ListVC { list.add(title: "纯文字") { section in section.add(title: "只有一句话") { - // Alert(.message("只有一句话").duration(2)) - // 可以简写成这样: - Alert("只有一句话") + Alert(.message("只有一句话").duration(2)) } section.add(title: "标题 + 正文") { let title = "这是标题" diff --git a/PHDemo/PHDemo/CapsuleVC.swift b/PHDemo/PHDemo/DemoCapsuleVC.swift similarity index 99% rename from PHDemo/PHDemo/CapsuleVC.swift rename to PHDemo/PHDemo/DemoCapsuleVC.swift index 271cb20..c98fbdf 100644 --- a/PHDemo/PHDemo/CapsuleVC.swift +++ b/PHDemo/PHDemo/DemoCapsuleVC.swift @@ -1,5 +1,5 @@ // -// CapsuleVC.swift +// DemoCapsuleVC.swift // PHDemo // // Created by xaoxuu on 2022/9/3. @@ -8,7 +8,7 @@ import UIKit import ProHUD -class CapsuleVC: ListVC { +class DemoCapsuleVC: ListVC { override func viewDidLoad() { super.viewDidLoad() diff --git a/PHDemo/PHDemo/SheetVC.swift b/PHDemo/PHDemo/DemoSheetVC.swift similarity index 99% rename from PHDemo/PHDemo/SheetVC.swift rename to PHDemo/PHDemo/DemoSheetVC.swift index ec62d7e..cbceca2 100644 --- a/PHDemo/PHDemo/SheetVC.swift +++ b/PHDemo/PHDemo/DemoSheetVC.swift @@ -1,5 +1,5 @@ // -// SheetVC.swift +// DemoSheetVC.swift // PHDemo // // Created by xaoxuu on 2022/9/3. @@ -8,7 +8,7 @@ import UIKit import ProHUD -class SheetVC: ListVC { +class DemoSheetVC: ListVC { override func viewDidLoad() { super.viewDidLoad() diff --git a/PHDemo/PHDemo/ToastVC.swift b/PHDemo/PHDemo/DemoToastVC.swift similarity index 99% rename from PHDemo/PHDemo/ToastVC.swift rename to PHDemo/PHDemo/DemoToastVC.swift index 1a515c3..72bf556 100644 --- a/PHDemo/PHDemo/ToastVC.swift +++ b/PHDemo/PHDemo/DemoToastVC.swift @@ -1,5 +1,5 @@ // -// ToastVC.swift +// DemoToastVC.swift // PHDemo // // Created by xaoxuu on 2022/9/3. @@ -44,7 +44,7 @@ class TestToast: ToastProvider { typealias Target = TestToastTarget } -class ToastVC: ListVC { +class DemoToastVC: ListVC { override func viewDidLoad() { super.viewDidLoad() diff --git a/Sources/ProHUD/Alert/AlertProvider.swift b/Sources/ProHUD/Alert/AlertProvider.swift index 15c18c6..f480f70 100644 --- a/Sources/ProHUD/Alert/AlertProvider.swift +++ b/Sources/ProHUD/Alert/AlertProvider.swift @@ -16,6 +16,10 @@ open class AlertProvider: HUDProvider { super.init(initializer: initializer) } + /// 根据ViewModel和自定义的初始化代码创建一个Target并显示 + /// - Parameters: + /// - vm: 数据模型 + /// - initializer: 自定义的初始化代码 @discardableResult public convenience init(_ vm: ViewModel, initializer: ((_ alert: Target) -> Void)?) { self.init { alert in alert.vm = vm @@ -28,11 +32,6 @@ open class AlertProvider: HUDProvider { self.init(vm, initializer: nil) } - @discardableResult @objc public convenience init(_ text: String, duration: TimeInterval = 3) { - self.init(.message(text).duration(duration), initializer: nil) - } - - /// 如果不存在就创建并弹出一个HUD实例,如果存在就更新实例 /// - Parameters: /// - identifier: 实例唯一标识符(如果为空,则以代码位置为唯一标识符) diff --git a/Sources/ProHUD/Capsule/CapsuleProvider.swift b/Sources/ProHUD/Capsule/CapsuleProvider.swift index fa8e969..00b8d5a 100644 --- a/Sources/ProHUD/Capsule/CapsuleProvider.swift +++ b/Sources/ProHUD/Capsule/CapsuleProvider.swift @@ -33,6 +33,8 @@ open class CapsuleProvider: HUDProvider { self.init(vm, initializer: nil) } + /// 根据文本作为数据模型创建一个Target并显示 + /// - Parameter text: 文本 @discardableResult public convenience init(_ text: String) { self.init(.message(text), initializer: nil) } diff --git a/Sources/ProHUD/Toast/ToastProvider.swift b/Sources/ProHUD/Toast/ToastProvider.swift index e1c2c22..a94f6fe 100644 --- a/Sources/ProHUD/Toast/ToastProvider.swift +++ b/Sources/ProHUD/Toast/ToastProvider.swift @@ -16,6 +16,10 @@ open class ToastProvider: HUDProvider { super.init(initializer: initializer) } + /// 根据ViewModel和自定义的初始化代码创建一个Target并显示 + /// - Parameters: + /// - vm: 数据模型 + /// - initializer: 自定义的初始化代码 @discardableResult public convenience init(_ vm: ViewModel, initializer: ((_ toast: Target) -> Void)?) { self.init { toast in toast.vm = vm @@ -29,6 +33,8 @@ open class ToastProvider: HUDProvider { self.init(vm, initializer: nil) } + /// 根据文本作为数据模型创建一个Target并显示 + /// - Parameter text: 文本 @discardableResult @objc public convenience init(_ text: String) { self.init(.message(text), initializer: nil) }