Removed super call for setWithJSON. Provided more functionality for atom steup.

This commit is contained in:
Christiano, Kevin 2019-04-01 13:28:15 -04:00
parent c5233a680d
commit 16c644e12d

View File

@ -52,7 +52,7 @@ open class CaretButton: MFCustomButton {
public func setEnabled(_ enabled: Bool) { public func setEnabled(_ enabled: Bool) {
super.isEnabled = enabled super.isEnabled = enabled
changeCaretColor() changeCaretColor()
} }
@ -112,21 +112,31 @@ open class CaretButton: MFCustomButton {
} }
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegate: NSObject?, additionalData: [AnyHashable: Any]?) { @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 } guard let jsonDictionary = json else { return }
if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String { if let backgroundColorHex = jsonDictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex) backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
} }
if let enableColorHex = jsonDictionary["enableColor"] as? String { if let enableColorHex = jsonDictionary["enabledColor"] as? String {
enabledColor = UIColor.mfGet(forHex: enableColorHex) enabledColor = UIColor.mfGet(forHex: enableColorHex)
} }
if let disabledColorHex = jsonDictionary["disabledColor"] as? String { if let disabledColorHex = jsonDictionary["disabledColor"] as? String {
disabledColor = UIColor.mfGet(forHex: disabledColorHex) 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)
}
} }
} }