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
|
import VDS
|
||||||
|
|
||||||
@objcMembers open class TwoButtonView: VDS.View, VDSMoleculeViewProtocol {
|
@objcMembers open class TwoButtonView: VDS.View, VDSMoleculeViewProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -31,29 +31,36 @@ import VDS
|
|||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
addSubview(buttonGroup)
|
addSubview(buttonGroup)
|
||||||
buttonGroup.pinToSuperView()
|
buttonGroup.pinToSuperView()
|
||||||
|
heightConstraint = height(constant: VDS.Button.Size.large.height, priority: .required)
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func setDefaults() {
|
||||||
|
super.setDefaults()
|
||||||
buttonGroup.alignment = .center
|
buttonGroup.alignment = .center
|
||||||
buttonGroup.rowQuantityPhone = 2
|
buttonGroup.rowQuantityPhone = 2
|
||||||
buttonGroup.rowQuantityTablet = 2
|
buttonGroup.rowQuantityTablet = 2
|
||||||
heightConstraint = height(constant: VDS.Button.Size.large.height, priority: .required)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func reset() {
|
||||||
|
buttonGroup.reset()
|
||||||
|
super.reset()
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open override func reset() {
|
|
||||||
super.reset()
|
|
||||||
buttonGroup.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
guard let model = model as? TwoButtonViewModel,
|
guard let model = model as? TwoButtonViewModel,
|
||||||
let buttonModel = model.primaryButton ?? model.secondaryButton
|
let buttonModel = model.primaryButton ?? model.secondaryButton
|
||||||
else { return 0 }
|
else { return 0 }
|
||||||
|
|
||||||
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - VDSMoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
public func viewModelDidUpdate() {
|
public func viewModelDidUpdate() {
|
||||||
var buttons = [PillButton]()
|
var buttons = [PillButton]()
|
||||||
if let secondaryModel = viewModel.secondaryButton {
|
if let secondaryModel = viewModel.secondaryButton {
|
||||||
@ -65,7 +72,7 @@ import VDS
|
|||||||
primaryButton.set(with: primaryModel, delegateObject, additionalData)
|
primaryButton.set(with: primaryModel, delegateObject, additionalData)
|
||||||
buttons.append(primaryButton)
|
buttons.append(primaryButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonGroup.childWidth = viewModel.fillContainer ? .percentage(100) : nil
|
buttonGroup.childWidth = viewModel.fillContainer ? .percentage(100) : nil
|
||||||
|
|
||||||
if buttons.count != buttonGroup.buttons.count {
|
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
|
heightConstraint?.constant = primaryButton.size == .small || secondaryButton.size == .small ? VDS.Button.Size.small.height : VDS.Button.Size.large.height
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MVMCoreUIViewConstrainingProtocol
|
// MARK: - MVMCoreUIViewConstrainingProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -87,7 +94,5 @@ import VDS
|
|||||||
// MARK: - MVMCoreViewProtocol
|
// MARK: - MVMCoreViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public func updateView(_ size: CGFloat) {
|
public func updateView(_ size: CGFloat) {}
|
||||||
setNeedsUpdate()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,21 +32,20 @@ import VDS
|
|||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
addSubview(buttonGroup)
|
addSubview(buttonGroup)
|
||||||
buttonGroup.pinToSuperView()
|
buttonGroup.pinToSuperView()
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func setDefaults() {
|
||||||
|
super.setDefaults()
|
||||||
buttonGroup.alignment = .center
|
buttonGroup.alignment = .center
|
||||||
buttonGroup.rowQuantityPhone = 2
|
buttonGroup.rowQuantityPhone = 2
|
||||||
buttonGroup.rowQuantityTablet = 2
|
buttonGroup.rowQuantityTablet = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - MVMCoreViewProtocol
|
|
||||||
//--------------------------------------------------
|
|
||||||
open override func reset() {
|
open override func reset() {
|
||||||
super.reset()
|
|
||||||
buttonGroup.reset()
|
buttonGroup.reset()
|
||||||
|
super.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateView(_ size: CGFloat) { }
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Stack Manipulation
|
// MARK: - Stack Manipulation
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -90,7 +89,8 @@ import VDS
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - MoleculeViewProtocol
|
// MARK: - MoleculeViewProtocol
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
open func updateView(_ size: CGFloat) { }
|
||||||
|
|
||||||
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
guard let model = model as? TwoButtonViewModel,
|
guard let model = model as? TwoButtonViewModel,
|
||||||
let buttonModel = model.primaryButton ?? model.secondaryButton
|
let buttonModel = model.primaryButton ?? model.secondaryButton
|
||||||
@ -99,6 +99,9 @@ import VDS
|
|||||||
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
return PillButton.estimatedHeight(with: buttonModel, delegateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - VDSMoleculeViewProtocol
|
||||||
|
//--------------------------------------------------
|
||||||
public func viewModelDidUpdate() {
|
public func viewModelDidUpdate() {
|
||||||
buttons.removeAll()
|
buttons.removeAll()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user