final changes before vacation
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
c05f35de03
commit
81ed479c87
@ -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
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user