name change

This commit is contained in:
Pfeil, Scott Robert 2020-05-20 20:28:13 -04:00
parent 5bda356dc9
commit 79127889dd

View File

@ -22,7 +22,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
//--------------------------------------------------
open weak var buttonDelegate: ButtonDelegateProtocol?
private var actionObject: ActionDelegate?
private var actionDelegate: ActionDelegate?
//--------------------------------------------------
// MARK: - Initializers
@ -31,7 +31,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
public static func create(with image: UIImage?) -> Self {
let actionObject = ActionDelegate()
let button = self.init(image: image, style: .plain, target: actionObject, action: #selector(actionObject.callActionBlock(_:)))
button.actionObject = actionObject
button.actionDelegate = actionObject
return button
}
@ -52,7 +52,7 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
/// Creates the item with the passed in action.
public static func create(with image: UIImage?, action: @escaping BarButtonAction) -> Self {
let button = create(with: image)
button.actionObject?.buttonAction = action
button.actionDelegate?.buttonAction = action
return button
}
@ -62,11 +62,10 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
buttonDelegate = delegateObject?.buttonDelegate
actionObject?.buttonAction = { [weak self] sender in
guard let self = self else { return }
actionDelegate?.buttonAction = { sender in
if let data = try? actionModel.encode(using: JSONEncoder()),
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)
}
}
@ -74,9 +73,8 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
open func set(with actionMap: [AnyHashable : Any], delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
buttonDelegate = delegateObject?.buttonDelegate
actionObject?.buttonAction = { [weak self] sender in
guard let self = self,
delegateObject?.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return }
actionDelegate?.buttonAction = { sender in
guard delegateObject?.buttonDelegate?.button?(sender, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true else { return }
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
}