mirror of https://github.com/xaoxuu/ProHUD
支持ObjC
This commit is contained in:
parent
5fb9e6efc3
commit
e7029c3751
|
@ -73,10 +73,10 @@ open class Alert: ProHUD.Controller {
|
||||||
return stack
|
return stack
|
||||||
}()
|
}()
|
||||||
|
|
||||||
open class ViewModel: BaseViewModel {}
|
@objc(AlertViewModel) open class ViewModel: BaseViewModel {}
|
||||||
|
|
||||||
/// 视图模型
|
/// 视图模型
|
||||||
public var vm = ViewModel()
|
@objc public var vm = ViewModel()
|
||||||
|
|
||||||
public override var title: String? {
|
public override var title: String? {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -84,7 +84,7 @@ open class Alert: ProHUD.Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult public init(_ vm: ViewModel, handler: ((_ alert: Alert) -> Void)? = nil) {
|
@discardableResult @objc public init(_ vm: ViewModel, handler: ((_ alert: Alert) -> Void)? = nil) {
|
||||||
super.init()
|
super.init()
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
handler?(self)
|
handler?(self)
|
||||||
|
@ -96,7 +96,7 @@ open class Alert: ProHUD.Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult public convenience init(handler: ((_ alert: Alert) -> Void)?) {
|
@discardableResult @objc public convenience init(handler: ((_ alert: Alert) -> Void)?) {
|
||||||
self.init(.init(), handler: handler)
|
self.init(.init(), handler: handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,15 @@ open class Capsule: Controller {
|
||||||
return lb
|
return lb
|
||||||
}()
|
}()
|
||||||
|
|
||||||
open class ViewModel: BaseViewModel {
|
@objc(CapsuleViewModel) open class ViewModel: BaseViewModel {
|
||||||
|
|
||||||
public enum Position {
|
@objc public enum Position: Int {
|
||||||
case top
|
case top
|
||||||
case middle
|
case middle
|
||||||
case bottom
|
case bottom
|
||||||
}
|
}
|
||||||
public var position: Position = .top
|
|
||||||
|
@objc public var position: Position = .top
|
||||||
|
|
||||||
public static var top: Self {
|
public static var top: Self {
|
||||||
let obj = Self.init()
|
let obj = Self.init()
|
||||||
|
@ -72,11 +73,11 @@ open class Capsule: Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 视图模型
|
/// 视图模型
|
||||||
public var vm = ViewModel()
|
@objc public var vm = ViewModel()
|
||||||
|
|
||||||
private var tapActionCallback: ((_ capsule: Capsule) -> Void)?
|
private var tapActionCallback: ((_ capsule: Capsule) -> Void)?
|
||||||
|
|
||||||
@discardableResult public init(_ vm: ViewModel, handler: ((_ capsule: Capsule) -> Void)? = nil) {
|
@discardableResult @objc public init(_ vm: ViewModel, handler: ((_ capsule: Capsule) -> Void)? = nil) {
|
||||||
super.init()
|
super.init()
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
handler?(self)
|
handler?(self)
|
||||||
|
@ -87,7 +88,7 @@ open class Capsule: Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult public convenience init(handler: ((_ capsule: Capsule) -> Void)?) {
|
@discardableResult @objc public convenience init(handler: ((_ capsule: Capsule) -> Void)?) {
|
||||||
self.init(.init(), handler: handler)
|
self.init(.init(), handler: handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,19 @@ import UIKit
|
||||||
open class BaseViewModel: NSObject {
|
open class BaseViewModel: NSObject {
|
||||||
|
|
||||||
/// 图标
|
/// 图标
|
||||||
open var icon: UIImage?
|
@objc open var icon: UIImage?
|
||||||
var iconURL: URL?
|
@objc var iconURL: URL?
|
||||||
|
|
||||||
/// 图标旋转动画
|
/// 图标旋转动画
|
||||||
open var rotation: Rotation?
|
open var rotation: Rotation?
|
||||||
|
|
||||||
/// 标题
|
/// 标题
|
||||||
open var title: String?
|
@objc open var title: String?
|
||||||
|
|
||||||
/// 消息正文
|
/// 消息正文
|
||||||
open var message: String?
|
@objc open var message: String?
|
||||||
|
|
||||||
open var tintColor: UIColor?
|
@objc open var tintColor: UIColor?
|
||||||
|
|
||||||
/// 持续时间(为空代表根据场景不同的默认配置,为0代表无穷大)
|
/// 持续时间(为空代表根据场景不同的默认配置,为0代表无穷大)
|
||||||
open var duration: TimeInterval? {
|
open var duration: TimeInterval? {
|
||||||
|
@ -32,7 +32,7 @@ open class BaseViewModel: NSObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public required override init() {
|
@objc public required override init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ open class Sheet: Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult public init(handler: @escaping (_ sheet: Sheet) -> Void, onTappedBackground action: ((_ sheet: Sheet) -> Void)? = nil) {
|
@discardableResult @objc public init(handler: @escaping (_ sheet: Sheet) -> Void, onTappedBackground action: ((_ sheet: Sheet) -> Void)? = nil) {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
onTappedBackground = action
|
onTappedBackground = action
|
||||||
|
|
|
@ -83,10 +83,10 @@ open class Toast: Controller {
|
||||||
/// 是否可以通过手势移除(向上滑出屏幕)
|
/// 是否可以通过手势移除(向上滑出屏幕)
|
||||||
public var isRemovable = true
|
public var isRemovable = true
|
||||||
|
|
||||||
open class ViewModel: BaseViewModel {}
|
@objc(ToastViewModel) open class ViewModel: BaseViewModel {}
|
||||||
|
|
||||||
/// 视图模型
|
/// 视图模型
|
||||||
public var vm = ViewModel()
|
@objc public var vm = ViewModel()
|
||||||
|
|
||||||
private var tapActionCallback: ((_ toast: Toast) -> Void)?
|
private var tapActionCallback: ((_ toast: Toast) -> Void)?
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ open class Toast: Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@discardableResult public init(_ vm: ViewModel, handler: ((_ toast: Toast) -> Void)? = nil) {
|
@discardableResult @objc public init(_ vm: ViewModel, handler: ((_ toast: Toast) -> Void)? = nil) {
|
||||||
super.init()
|
super.init()
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
handler?(self)
|
handler?(self)
|
||||||
|
@ -109,7 +109,7 @@ open class Toast: Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult public convenience init(handler: ((_ toast: Toast) -> Void)?) {
|
@discardableResult @objc public convenience init(handler: ((_ toast: Toast) -> Void)?) {
|
||||||
self.init(.init(), handler: handler)
|
self.init(.init(), handler: handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue