diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index 4a812a57..e8105d3e 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -18,12 +18,12 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi // MARK: - Properties //-------------------------------------------------- - var model: MoleculeModelProtocol? - var buttonModel: ButtonModel? { + open var model: MoleculeModelProtocol? + public var buttonModel: ButtonModel? { get { model as? ButtonModel } } - var onClickCancellable: Cancellable? + internal var onClickCancellable: Cancellable? //-------------------------------------------------- // MARK: - Initializers @@ -58,14 +58,14 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi } /// The primary styling for a button. Should be used for main buttons - public func stylePrimary() { - let buttonModel = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) + open func stylePrimary() { + model = ButtonModel(primaryButtonWith: "", action: ActionNoopModel()) use = .primary } /// The secondary styling for a button. Should be used for secondary buttons - public func styleSecondary() { - let buttonModel = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) + open func styleSecondary() { + model = ButtonModel(secondaryButtonWith: "", action: ActionNoopModel()) use = .secondary } @@ -81,26 +81,25 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MoleculeVi self.accessibilityIdentifier = accessibilityIdentifier } - setTitle(model.title, for: .normal) - if let accessibilityText = model.accessibilityText { - accessibilityLabel = accessibilityText - } - + text = model.title isEnabled = model.enabled size = model.size // if let backgroundColor = model.backgroundColor { // self.backgroundColor = backgroundColor.uiColor // } + if let accessibilityText = model.accessibilityText { + accessibilityLabel = accessibilityText + } + + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) + + set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) model.updateUI = { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { self?.isEnabled = model.enabled }) } - - FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - - set(with: model.action, delegateObject: delegateObject, additionalData: additionalData) } //--------------------------------------------------