Rewrote ButtonTapBlock in swift
This commit is contained in:
parent
4b855a1a63
commit
109ef54479
@ -6,22 +6,22 @@
|
|||||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
public typealias ButtonBlock = (Button) -> Void
|
||||||
|
|
||||||
@objcMembers open class Button: UIButton, MFButtonProtocol {
|
@objcMembers open class Button: UIButton, MFButtonProtocol {
|
||||||
|
|
||||||
public var actionMap: [AnyHashable: Any]?
|
public var actionMap: [AnyHashable: Any]?
|
||||||
public weak var buttonDelegate: ButtonDelegateProtocol?
|
public weak var buttonDelegate: ButtonDelegateProtocol?
|
||||||
|
private var buttonBlock: ButtonBlock?
|
||||||
|
|
||||||
//Does buttonTap block need to be rewritten in swift?
|
public func addBlock(_ buttonBlock: @escaping ButtonBlock, event: Event) {
|
||||||
private var buttonTapBlock: ButtonTapBlock?
|
self.buttonBlock = buttonBlock
|
||||||
|
|
||||||
public func addBlock(_ buttonTapBlock: @escaping ButtonTapBlock, event: Event) {
|
|
||||||
self.buttonTapBlock = buttonTapBlock
|
|
||||||
addTarget(self, action: #selector(callBlock(_:)), for: event)
|
addTarget(self, action: #selector(callBlock(_:)), for: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
func callBlock(_ sender: Button) {
|
func callBlock(_ sender: Button) {
|
||||||
guard let buttonTapBlock = buttonTapBlock else { return }
|
guard let buttonBlock = buttonBlock else { return }
|
||||||
buttonTapBlock(self)
|
buttonBlock(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user