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 { override open var isSelected: Bool {
didSet { didSet {
if !updateSelectionOnly { viewModel.selected = isSelected
viewModel.selected = isSelected _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
} }
} }
@ -144,12 +134,10 @@ import VDS
isEnabled = viewModel.enabled && !viewModel.readOnly isEnabled = viewModel.enabled && !viewModel.readOnly
isAnimated = viewModel.animated isAnimated = viewModel.animated
if viewModel.selected { //call super here to go around the didSet
updateSelectionOnly = true //in this class
isSelected = viewModel.selected super.isSelected = viewModel.selected
updateSelectionOnly = false
}
//events //events
viewModel.updateUI = { viewModel.updateUI = {
MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in

View File

@ -19,21 +19,11 @@ import VDS
var fieldKey: String? var fieldKey: String?
var fieldValue: JSONValue? var fieldValue: JSONValue?
var groupName: String? 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 { override open var isSelected: Bool {
didSet { didSet {
if !updateSelectionOnly { viewModel.checkbox.selected = isSelected
viewModel.checkbox.selected = isSelected _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
_ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
}
} }
} }
@ -76,11 +66,9 @@ import VDS
isAnimated = viewModel.checkbox.animated isAnimated = viewModel.checkbox.animated
isEnabled = viewModel.checkbox.enabled && !viewModel.checkbox.readOnly isEnabled = viewModel.checkbox.enabled && !viewModel.checkbox.readOnly
if viewModel.checkbox.selected { //call super here to go around the didSet
updateSelectionOnly = false //in this class
isSelected = viewModel.checkbox.selected super.isSelected = viewModel.checkbox.selected
updateSelectionOnly = true
}
//events //events
viewModel.checkbox.updateUI = { viewModel.checkbox.updateUI = {