Fix for the reset() issue with default properties being reset for buttonGroup
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
558a3d7c55
commit
33dc411743
@ -10,7 +10,7 @@ import UIKit
|
||||
import VDS
|
||||
|
||||
@objcMembers open class TwoButtonView: VDS.View, VDSMoleculeViewProtocol {
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -31,29 +31,36 @@ import VDS
|
||||
isAccessibilityElement = false
|
||||
addSubview(buttonGroup)
|
||||
buttonGroup.pinToSuperView()
|
||||
heightConstraint = height(constant: VDS.Button.Size.large.height, priority: .required)
|
||||
}
|
||||
|
||||
open override func setDefaults() {
|
||||
super.setDefaults()
|
||||
buttonGroup.alignment = .center
|
||||
buttonGroup.rowQuantityPhone = 2
|
||||
buttonGroup.rowQuantityTablet = 2
|
||||
heightConstraint = height(constant: VDS.Button.Size.large.height, priority: .required)
|
||||
}
|
||||
|
||||
|
||||
open override func reset() {
|
||||
buttonGroup.reset()
|
||||
super.reset()
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
buttonGroup.reset()
|
||||
}
|
||||
|
||||
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
guard let model = model as? TwoButtonViewModel,
|
||||
let buttonModel = model.primaryButton ?? model.secondaryButton
|
||||
else { return 0 }
|
||||
let buttonModel = model.primaryButton ?? model.secondaryButton
|
||||
else { return 0 }
|
||||
|
||||
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - VDSMoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
public func viewModelDidUpdate() {
|
||||
var buttons = [PillButton]()
|
||||
if let secondaryModel = viewModel.secondaryButton {
|
||||
@ -65,7 +72,7 @@ import VDS
|
||||
primaryButton.set(with: primaryModel, delegateObject, additionalData)
|
||||
buttons.append(primaryButton)
|
||||
}
|
||||
|
||||
|
||||
buttonGroup.childWidth = viewModel.fillContainer ? .percentage(100) : nil
|
||||
|
||||
if buttons.count != buttonGroup.buttons.count {
|
||||
@ -74,7 +81,7 @@ import VDS
|
||||
|
||||
heightConstraint?.constant = primaryButton.size == .small || secondaryButton.size == .small ? VDS.Button.Size.small.height : VDS.Button.Size.large.height
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MVMCoreUIViewConstrainingProtocol
|
||||
//--------------------------------------------------
|
||||
@ -87,7 +94,5 @@ import VDS
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
public func updateView(_ size: CGFloat) {
|
||||
setNeedsUpdate()
|
||||
}
|
||||
public func updateView(_ size: CGFloat) {}
|
||||
}
|
||||
|
||||
@ -32,21 +32,20 @@ import VDS
|
||||
isAccessibilityElement = false
|
||||
addSubview(buttonGroup)
|
||||
buttonGroup.pinToSuperView()
|
||||
}
|
||||
|
||||
open override func setDefaults() {
|
||||
super.setDefaults()
|
||||
buttonGroup.alignment = .center
|
||||
buttonGroup.rowQuantityPhone = 2
|
||||
buttonGroup.rowQuantityTablet = 2
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
open override func reset() {
|
||||
super.reset()
|
||||
buttonGroup.reset()
|
||||
super.reset()
|
||||
}
|
||||
|
||||
open func updateView(_ size: CGFloat) { }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Stack Manipulation
|
||||
//--------------------------------------------------
|
||||
@ -90,7 +89,8 @@ import VDS
|
||||
//--------------------------------------------------
|
||||
// MARK: - MoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
open func updateView(_ size: CGFloat) { }
|
||||
|
||||
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||
guard let model = model as? TwoButtonViewModel,
|
||||
let buttonModel = model.primaryButton ?? model.secondaryButton
|
||||
@ -99,6 +99,9 @@ import VDS
|
||||
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - VDSMoleculeViewProtocol
|
||||
//--------------------------------------------------
|
||||
public func viewModelDidUpdate() {
|
||||
buttons.removeAll()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user