use super instead of var

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-08-02 08:53:15 -05:00
parent 5e116e3c91
commit 5a3f04aa5f
2 changed files with 11 additions and 35 deletions

View File

@ -38,20 +38,10 @@ import VDS
}
}
/// Disables all selection logic when setting the value of isSelected, reducing it to a stored property.
open var updateSelectionOnly: Bool = false
/**
The represented state of the Checkbox.
Setting updateSelectionOnly to true bypasses the animation logic inherent with setting this property.
*/
override open var isSelected: Bool {
didSet {
if !updateSelectionOnly {
viewModel.selected = isSelected
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
viewModel.selected = isSelected
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
}
@ -144,12 +134,10 @@ import VDS
isEnabled = viewModel.enabled && !viewModel.readOnly
isAnimated = viewModel.animated
if viewModel.selected {
updateSelectionOnly = true
isSelected = viewModel.selected
updateSelectionOnly = false
}
//call super here to go around the didSet
//in this class
super.isSelected = viewModel.selected
//events
viewModel.updateUI = {
MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in

View File

@ -19,21 +19,11 @@ import VDS
var fieldKey: String?
var fieldValue: JSONValue?
var groupName: String?
/// Disables all selection logic when setting the value of isSelected, reducing it to a stored property.
open var updateSelectionOnly: Bool = false
/**
The represented state of the Checkbox.
Setting updateSelectionOnly to true bypasses the animation logic inherent with setting this property.
*/
override open var isSelected: Bool {
didSet {
if !updateSelectionOnly {
viewModel.checkbox.selected = isSelected
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
viewModel.checkbox.selected = isSelected
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
}
@ -76,11 +66,9 @@ import VDS
isAnimated = viewModel.checkbox.animated
isEnabled = viewModel.checkbox.enabled && !viewModel.checkbox.readOnly
if viewModel.checkbox.selected {
updateSelectionOnly = false
isSelected = viewModel.checkbox.selected
updateSelectionOnly = true
}
//call super here to go around the didSet
//in this class
super.isSelected = viewModel.checkbox.selected
//events
viewModel.checkbox.updateUI = {