diff --git a/MVMCoreUI/Atoms/Buttons/Link.swift b/MVMCoreUI/Atoms/Buttons/Link.swift index 685ba233..6abcd48a 100644 --- a/MVMCoreUI/Atoms/Buttons/Link.swift +++ b/MVMCoreUI/Atoms/Buttons/Link.swift @@ -47,6 +47,20 @@ import UIKit context?.addLine(to: CGPoint(x: x + textRect.size.width, y: y)) context?.strokePath() } + + public override func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.setWithModel(model, delegateObject, additionalData) + guard let model = model as? LinkModel else { return } + setTitle(model.title, for: .normal) + setTitleColor(model.textColor.uiColor, for: .normal) + setTitleColor(model.disabledColor.uiColor, for: .disabled) + isEnabled = model.enabled + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) + } + + public static func estimatedHeight(forRow molecule: ModuleMoleculeModel?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 31.0 + } } // MARK: - MVMCoreViewProtocol @@ -80,57 +94,6 @@ extension Link { } } -extension Link: ModelMoleculeViewProtocol { - - public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { - guard let model = model as? LinkModel else { return } - setTitle(model.title, for: .normal) - setTitleColor(model.textColor.uiColor, for: .normal) - setTitleColor(model.disabledColor.uiColor, for: .disabled) - isEnabled = model.enabled - backgroundColor = model.backgroundColor?.uiColor - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) - } - - public static func estimatedHeight(forRow molecule: ModuleMoleculeModel?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 31.0 - } -} - - -// MARK: - MVMCoreUIMoleculeViewProtocol -extension Link { - - public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData) - self.additionalData = additionalData - self.delegateObject = delegateObject - buttonDelegate = delegateObject?.buttonDelegate - - guard let dictionary = json else { return } - actionMap = dictionary - - if let disabledColorHex = dictionary["disabledColor"] as? String { - setTitleColor(.mfGet(forHex: disabledColorHex), for: .disabled) - } - - if let colorHex = dictionary[KeyTextColor] as? String { - setTitleColor(.mfGet(forHex: colorHex), for: .normal) - } - - if let title = dictionary.optionalStringForKey(KeyTitle) { - setTitle(title, for: .normal) - } - if let enabled = dictionary[KeyEnabled] as? Bool { - isEnabled = enabled - } - } - - public static func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { - return 31 - } -} - // MARK: - MVMCoreUIViewConstrainingProtocol extension Link: MVMCoreUIViewConstrainingProtocol { diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index e50e492f..7909d1dd 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -69,7 +69,7 @@ public typealias ButtonAction = (Button) -> () buttonAction?(self) } - public func setWithAction(_ actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + public func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.actionModel = actionModel buttonDelegate = delegateObject?.buttonDelegate