From 874addef638149acdd86d20be47a14a3380ee2e9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 14 Jan 2020 09:06:39 -0500 Subject: [PATCH] Changed name. New disabled KV. mild updates. --- MVMCoreUI/Atoms/Buttons/Link.swift | 14 +++++--------- MVMCoreUI/BaseClasses/Button.swift | 12 ++++++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 1ec7e9a3..3b6cabb8 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -74,14 +74,6 @@ import UIKit context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context?.strokePath() } - - //-------------------------------------------------- - // MARK: - UITouch - //-------------------------------------------------- - - open override func touchesEnded(_ touches: Set, with event: UIEvent?) { - callActionBlock(self) - } } // MARK: - MVMCoreViewProtocol @@ -134,6 +126,10 @@ extension Link { guard let dictionary = json else { return } actionMap = dictionary + if let disabledColorHex = dictionary["disabledColor"] as? String { + titleColor.disabled = .mfGet(forHex: disabledColorHex) + } + if let colorHex = dictionary[KeyTextColor] as? String { titleColor.enabled = .mfGet(forHex: colorHex) setTitleColor(titleColor.enabled, for: .normal) @@ -153,7 +149,7 @@ extension Link { } } -// MARK:- MVMCoreUIViewConstrainingProtocol +// MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { public func needsToBeConstrained() -> Bool { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 55ac0195..356ef59d 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -public typealias ButtonBlock = (Button) -> () +public typealias ButtonAction = (Button) -> () @objcMembers open class Button: UIButton, MFButtonProtocol { @@ -19,7 +19,7 @@ public typealias ButtonBlock = (Button) -> () private var initialSetupPerformed = false - private var buttonBlock: ButtonBlock? + private var buttonAction: ButtonAction? //-------------------------------------------------- // MARK: - Delegate @@ -62,13 +62,13 @@ public typealias ButtonBlock = (Button) -> () // MARK: - Methods //-------------------------------------------------- - public func addBlock( event: Event, _ buttonBlock: @escaping ButtonBlock) { - self.buttonBlock = buttonBlock + public func addActionBlock( event: Event, _ buttonBlock: @escaping ButtonAction) { + self.buttonAction = buttonBlock addTarget(self, action: #selector(callActionBlock(_:)), for: event) } func callActionBlock(_ sender: Button) { - buttonBlock?(self) + buttonAction?(self) } public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { @@ -76,7 +76,7 @@ public typealias ButtonBlock = (Button) -> () buttonDelegate = delegateObject?.buttonDelegate - addBlock(event: .touchUpInside) { [weak self] sender in + addActionBlock(event: .touchUpInside) { [weak self] sender in guard let self = self else { return } if self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {