name change
This commit is contained in:
parent
5bda356dc9
commit
79127889dd
@ -22,7 +22,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open weak var buttonDelegate: ButtonDelegateProtocol?
|
open weak var buttonDelegate: ButtonDelegateProtocol?
|
||||||
private var actionObject: ActionDelegate?
|
private var actionDelegate: ActionDelegate?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
@ -31,7 +31,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
|
|||||||
public static func create(with image: UIImage?) -> Self {
|
public static func create(with image: UIImage?) -> Self {
|
||||||
let actionObject = ActionDelegate()
|
let actionObject = ActionDelegate()
|
||||||
let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:)))
|
let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:)))
|
||||||
button.actionObject = actionObject
|
button.actionDelegate = actionObject
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
|
|||||||
/// Creates the item with the passed in action.
|
/// Creates the item with the passed in action.
|
||||||
public static func create(with image: UIImage?, action: @escaping BarButtonAction) -> Self {
|
public static func create(with image: UIImage?, action: @escaping BarButtonAction) -> Self {
|
||||||
let button = create(with: image)
|
let button = create(with: image)
|
||||||
button.actionObject?.buttonAction = action
|
button.actionDelegate?.buttonAction = action
|
||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,11 +62,10 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
|
|||||||
|
|
||||||
open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
buttonDelegate = delegateObject?.buttonDelegate
|
buttonDelegate = delegateObject?.buttonDelegate
|
||||||
actionObject?.buttonAction = { [weak self] sender in
|
actionDelegate?.buttonAction = { sender in
|
||||||
guard let self = self else { return }
|
|
||||||
if let data = try? actionModel.encode(using: JSONEncoder()),
|
if let data = try? actionModel.encode(using: JSONEncoder()),
|
||||||
let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any],
|
let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any],
|
||||||
delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
|
delegateObject?.buttonDelegate?.button?(sender, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,9 +73,8 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
|
|||||||
|
|
||||||
open func set(with actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
open func set(with actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
buttonDelegate = delegateObject?.buttonDelegate
|
buttonDelegate = delegateObject?.buttonDelegate
|
||||||
actionObject?.buttonAction = { [weak self] sender in
|
actionDelegate?.buttonAction = { sender in
|
||||||
guard let self = self,
|
guard delegateObject?.buttonDelegate?.button?(sender, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return }
|
||||||
delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return }
|
|
||||||
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user