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
|
// MARK: - UICollectionViewDelegateFlowLayout
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -105,18 +105,20 @@ extension SelectorGroupSelectedModelHandlerable {
|
|||||||
public func didSelect(_ selectedControl: ModelHandlerType) {
|
public func didSelect(_ selectedControl: ModelHandlerType) {
|
||||||
//only changes local model in control,
|
//only changes local model in control,
|
||||||
//this is now disconnected from the parent model
|
//this is now disconnected from the parent model
|
||||||
selectorViews.forEach { control in
|
for (index, control) in selectorViews.enumerated() {
|
||||||
//only change the old and new
|
//only change the old and new
|
||||||
if control == selectedControl {
|
if control == selectedControl {
|
||||||
if var cached = getCachedSelector(viewModel: control.model) {
|
let updated = model.selectors[index].copyWith {
|
||||||
cached.selected = true
|
$0.selected = true
|
||||||
replace(viewModel: cached)
|
|
||||||
}
|
}
|
||||||
|
model.selectors[index] = updated
|
||||||
|
|
||||||
} else if control.isSelected {
|
} else if control.isSelected {
|
||||||
if var cached = getCachedSelector(viewModel: control.model) {
|
let updated = model.selectors[index].copyWith {
|
||||||
cached.selected = false
|
$0.selected = false
|
||||||
replace(viewModel: cached)
|
|
||||||
}
|
}
|
||||||
|
model.selectors[index] = updated
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user