支持ObjC

This commit is contained in:
xaoxuu 2023-08-17 18:17:16 +08:00
parent 5fb9e6efc3
commit e7029c3751
5 changed files with 22 additions and 21 deletions

View File

@ -73,10 +73,10 @@ open class Alert: ProHUD.Controller {
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? {
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()
self.vm = vm
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)
}

View File

@ -44,14 +44,15 @@ open class Capsule: Controller {
return lb
}()
open class ViewModel: BaseViewModel {
@objc(CapsuleViewModel) open class ViewModel: BaseViewModel {
public enum Position {
@objc public enum Position: Int {
case top
case middle
case bottom
}
public var position: Position = .top
@objc public var position: Position = .top
public static var top: Self {
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)?
@discardableResult public init(_ vm: ViewModel, handler: ((_ capsule: Capsule) -> Void)? = nil) {
@discardableResult @objc public init(_ vm: ViewModel, handler: ((_ capsule: Capsule) -> Void)? = nil) {
super.init()
self.vm = vm
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)
}

View File

@ -11,19 +11,19 @@ import UIKit
open class BaseViewModel: NSObject {
///
open var icon: UIImage?
var iconURL: URL?
@objc open var icon: UIImage?
@objc var iconURL: URL?
///
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
open var duration: TimeInterval? {
@ -32,7 +32,7 @@ open class BaseViewModel: NSObject {
}
}
public required override init() {
@objc public required override init() {
}

View File

@ -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()
onTappedBackground = action

View File

@ -83,10 +83,10 @@ open class Toast: Controller {
///
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)?
@ -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()
self.vm = vm
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)
}