diff --git a/MVMCoreUI/Atoms/Buttons/CaretButton.swift b/MVMCoreUI/Atoms/Buttons/CaretButton.swift index c85093d4..7d67afb1 100644 --- a/MVMCoreUI/Atoms/Buttons/CaretButton.swift +++ b/MVMCoreUI/Atoms/Buttons/CaretButton.swift @@ -52,7 +52,7 @@ open class CaretButton: MFCustomButton { public func setEnabled(_ enabled: Bool) { super.isEnabled = enabled - + changeCaretColor() } @@ -109,34 +109,25 @@ 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]?) { - - guard let jsonDictionary = json else { return } + setWithActionMap(json, 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["enabledColor"] as? String { - enabledColor = UIColor.mfGet(forHex: enableColorHex) + if let enabledColorHex = dictionary["enabledColor"] as? String { + enabledColor = UIColor.mfGet(forHex: enabledColorHex) } - 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) - } } }