final changes before vacation

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-31 16:24:45 -05:00
parent c05f35de03
commit 81ed479c87
2 changed files with 9 additions and 17 deletions

View File

@ -184,16 +184,6 @@ public class RadioSwatchGroupBase<GroupModelType: RadioSwatchGroupModel, ModelHa
}
}
public func getCachedSelector(viewModel: ModelHandlerType.ModelType) -> ModelHandlerType.ModelType? {
if let index = model.selectors.firstIndex(where: { element in
return element.inputId == viewModel.inputId
}) {
return model.selectors[index]
} else {
return nil
}
}
//--------------------------------------------------
// MARK: - UICollectionViewDelegateFlowLayout
//--------------------------------------------------

View File

@ -105,18 +105,20 @@ extension SelectorGroupSelectedModelHandlerable {
public func didSelect(_ selectedControl: ModelHandlerType) {
//only changes local model in control,
//this is now disconnected from the parent model
selectorViews.forEach { control in
for (index, control) in selectorViews.enumerated() {
//only change the old and new
if control == selectedControl {
if var cached = getCachedSelector(viewModel: control.model) {
cached.selected = true
replace(viewModel: cached)
let updated = model.selectors[index].copyWith {
$0.selected = true
}
model.selectors[index] = updated
} else if control.isSelected {
if var cached = getCachedSelector(viewModel: control.model) {
cached.selected = false
replace(viewModel: cached)
let updated = model.selectors[index].copyWith {
$0.selected = false
}
model.selectors[index] = updated
}
}