From 499f9eb55db81be5577b44ba8c2555cd5fb3877b Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Mon, 1 Apr 2019 13:30:31 -0400 Subject: [PATCH 1/5] Fixed setWithJSON, allows it to work properly with Atom molecule. Provided more properties to control. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index af7d1d60..9f48d358 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -112,9 +112,7 @@ open class CaretButton: MFCustomButton { } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegate: delegate, additionalData: additionalData) - - // Configure class properties with JSON values + guard let jsonDictionary = json else { return } if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { @@ -128,5 +126,17 @@ open class CaretButton: MFCustomButton { if let disabledColorHex = jsonDictionary["disabledColor"] as? String { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } + + if let caretViewHeight = jsonDictionary["caretViewHeight"] as? NSNumber { + rightViewHeight = caretViewHeight + } + + if let caretViewWidth = jsonDictionary["caretViewWidth"] as? NSNumber { + rightViewWidth = caretViewWidth + } + + if let buttonText = jsonDictionary["buttonText"] as? String { + setTitle(buttonText, for: .normal) + } } } From dd407f45f96847ebec5e88285c4ae6ce36679010 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Mon, 1 Apr 2019 16:44:33 -0400 Subject: [PATCH 2/5] changes made. Reduced access to caret dimensions. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 24 +++++++---------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 9f48d358..930cdd68 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,34 +109,24 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear + setTitle(actionMap?.optionalStringForKey(KeyTitle), for: .normal) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - - guard let jsonDictionary = json else { return } + setWithActionMap(actionMap, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) - if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { + guard let dictionary = json else { return } + + if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } - if let enableColorHex = jsonDictionary["enableColor"] as? String { + if let enableColorHex = dictionary["enableColor"] as? String { enabledColor = UIColor.mfGet(forHex: enableColorHex) } - if let disabledColorHex = jsonDictionary["disabledColor"] as? String { + if let disabledColorHex = dictionary["disabledColor"] as? String { disabledColor = UIColor.mfGet(forHex: disabledColorHex) } - - if let caretViewHeight = jsonDictionary["caretViewHeight"] as? NSNumber { - rightViewHeight = caretViewHeight - } - - if let caretViewWidth = jsonDictionary["caretViewWidth"] as? NSNumber { - rightViewWidth = caretViewWidth - } - - if let buttonText = jsonDictionary["buttonText"] as? String { - setTitle(buttonText, for: .normal) - } } } From cad3555156b6242fe1409d800c099dc337521676 Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 09:40:03 -0400 Subject: [PATCH 3/5] Removed unnecessary setTitle call. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 930cdd68..d9a51c19 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,7 +109,6 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear - setTitle(actionMap?.optionalStringForKey(KeyTitle), for: .normal) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { From 39edb4c0555d5f2390c60a4176d2dfdcd975e11a Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 09:44:47 -0400 Subject: [PATCH 4/5] changes actionMap to json. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index d9a51c19..99a32098 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -112,7 +112,7 @@ open class CaretButton: MFCustomButton { } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { - setWithActionMap(actionMap, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) + setWithActionMap(json, delegate: delegate as? (MVMCoreActionDelegateProtocol & NSObjectProtocol), additionalData: additionalData) guard let dictionary = json else { return } From 00feea9a58f869ed52fe42d0858d8caa1538219f Mon Sep 17 00:00:00 2001 From: "Christiano, Kevin" Date: Wed, 3 Apr 2019 12:09:17 -0400 Subject: [PATCH 5/5] Added default text color for enabled and disabled states. --- MVMCoreUI/Atoms/Buttons/CaretButton.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index 99a32098..7d67afb1 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -109,6 +109,8 @@ open class CaretButton: MFCustomButton { @objc open override func setAsMolecule() { backgroundColor = .clear + setTitleColor(enabledColor, for: .normal) + setTitleColor(disabledColor, for: .disabled) } @objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { @@ -120,8 +122,8 @@ open class CaretButton: MFCustomButton { backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) } - if let enableColorHex = dictionary["enableColor"] as? String { - enabledColor = UIColor.mfGet(forHex: enableColorHex) + if let enabledColorHex = dictionary["enabledColor"] as? String { + enabledColor = UIColor.mfGet(forHex: enabledColorHex) } if let disabledColorHex = dictionary["disabledColor"] as? String {