Updates to Button
This commit is contained in:
parent
8e35e8036a
commit
741bf0501b
@ -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)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user