diff --git a/MVMCoreUI/Atoms/Views/Label.swift b/MVMCoreUI/Atoms/Views/Label.swift index e0bb2a25..d604a2e7 100644 --- a/MVMCoreUI/Atoms/Views/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label.swift @@ -365,7 +365,7 @@ extension Label { public func createActionBlockFrom(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> ActionBlock { return { [weak self] in - if (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate?.button?(self!, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { + if let wSelf = self, (delegateObject as? MVMCoreUIDelegateObject)?.buttonDelegate?.button?(wSelf, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift index 76fb8db4..2befda5a 100644 --- a/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift +++ b/MVMCoreUI/Atoms/Views/LabelWithInternalButton.swift @@ -14,7 +14,8 @@ public typealias ButtonObjectDelegate = NSObjectProtocol & ButtonDelegateProtoco public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProtocol & MVMCoreLoadDelegateProtocol & MVMCorePresentationDelegateProtocol & NSObjectProtocol -@objcMembers open class LabelWithInternalButton: UIControl, MVMCoreViewProtocol, MFButtonProtocol { +@available(*, deprecated, message: "This class is deprecated, please use the Label class.") +@objcMembers open class LabelWithInternalButton: UIControl, MVMCoreViewProtocol, MFButtonProtocol, MVMCoreUIMoleculeViewProtocol { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -177,7 +178,6 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt if self.label == nil { let label = Label(frame: .zero) - label.isUserInteractionEnabled = true label.setContentCompressionResistancePriority(.required, for: .vertical) addSubview(label) NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: true, pinLeft: true, pinRight: true) @@ -458,14 +458,9 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt @available(*, deprecated) private func setActionMap(_ actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, actionDelegate delegate: ActionObjectDelegate?, buttonDelegate: ButtonObjectDelegate?) { - actionBlock = { [weak self, weak buttonDelegate] in - var performAction = true - - if let wSelf = self, let wButtonDelegate = buttonDelegate, wButtonDelegate.responds(to: #selector(ButtonObjectDelegate.button(_:shouldPerformActionWithMap:additionalData:))) { - performAction = wButtonDelegate.button?(wSelf, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? false - } - - if performAction { + actionBlock = { [weak self, weak delegate, weak buttonDelegate] in + + if let wSelf = self, buttonDelegate?.button?(wSelf, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegate: delegate as? CoreObjectActionLoadPresentDelegate) } } @@ -582,10 +577,10 @@ public typealias CoreObjectActionLoadPresentDelegate = MVMCoreActionDelegateProt } setLabelAttributes() } -} -// MARK: - Atomization -extension LabelWithInternalButton: MVMCoreUIMoleculeViewProtocol { + //------------------------------------------------------ + // MARK: - Atomization + //------------------------------------------------------ // Default values for view. @objc open func setAsMolecule() { diff --git a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift index 118502b6..8573ca87 100644 --- a/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift +++ b/MVMCoreUI/Atoms/Views/LeftRightLabelView.swift @@ -178,9 +178,9 @@ import Foundation guard let dictionary = actionMap else { return } - title?.setWithJSON(dictionary.optionalDictionaryForKey("title"), delegateObject: delegateObject, additionalData: additionalData) - message?.setWithJSON(dictionary.optionalDictionaryForKey("message"), delegateObject: delegateObject, additionalData: additionalData) - detail?.setWithJSON(dictionary.optionalDictionaryForKey("detail"), delegateObject: delegateObject, additionalData: additionalData) + title?.setWithJSON(dictionary.optionalDictionaryForKey("title"), delegateObject: delegateObject as! MVMCoreUIDelegateObject, additionalData: additionalData) + message?.setWithJSON(dictionary.optionalDictionaryForKey("message"), delegateObject: delegateObject as! MVMCoreUIDelegateObject, additionalData: additionalData) + detail?.setWithJSON(dictionary.optionalDictionaryForKey("detail"), delegateObject: delegateObject as! MVMCoreUIDelegateObject, additionalData: additionalData) if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) @@ -197,7 +197,7 @@ import Foundation } open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) + super.setWithJSON(json, delegateObject: delegateObject as! MVMCoreUIDelegateObject, additionalData: additionalData) setWithJSON(actionMap: json, delegateObject: delegateObject, additionalData: additionalData) } }