removed selected inputId
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
81ed479c87
commit
2148014664
@ -27,7 +27,7 @@ public class RadioSwatchGroup: RadioSwatchGroupBase<DefaultRadioSwatchGroupModel
|
||||
|
||||
label.text = newSelectedModel.text
|
||||
replace(viewModel: newSelectedModel)
|
||||
selectedInputId = newSelectedModel.inputId
|
||||
sendActions(for: .valueChanged)
|
||||
}
|
||||
|
||||
}
|
||||
@ -37,22 +37,8 @@ public class RadioSwatchGroupBase<GroupModelType: RadioSwatchGroupModel, ModelHa
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
@Proxy(\.model.selectedInputId)
|
||||
public var selectedInputId: String? {
|
||||
didSet {
|
||||
sendActions(for: .valueChanged)
|
||||
}
|
||||
}
|
||||
|
||||
public var selectedModel: ModelHandlerType.ModelType? {
|
||||
guard let selectedInputId else { return nil }
|
||||
if let index = model.selectors.firstIndex(where: { element in
|
||||
return element.inputId == selectedInputId
|
||||
}) {
|
||||
return model.selectors[index]
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return model.selectedModel
|
||||
}
|
||||
|
||||
public var onChange: Blocks.ActionBlock?
|
||||
|
||||
@ -28,7 +28,6 @@ public struct DefaultRadioSwatchGroupModel: RadioSwatchGroupModel {
|
||||
public var surface: Surface = .light
|
||||
public var disabled: Bool = false
|
||||
public var selectors: [SelectorModelType]
|
||||
public var selectedInputId: String?
|
||||
public init() { selectors = [] }
|
||||
public init(selectors: [SelectorModelType]){
|
||||
self.selectors = selectors
|
||||
|
||||
@ -15,15 +15,13 @@ public protocol SelectorGroupModelable: Modelable, FormFieldable {
|
||||
|
||||
///MARK: Groups that allow single selections
|
||||
public protocol SelectorGroupSelectedModelable: SelectorGroupModelable {
|
||||
var selectedInputId: String? { get set }
|
||||
var selectedModel: SelectorModelType? { get }
|
||||
}
|
||||
|
||||
extension SelectorGroupSelectedModelable {
|
||||
public var selectedModel: SelectorModelType? {
|
||||
guard let selectedInputId else { return nil }
|
||||
if let index = selectors.firstIndex(where: { element in
|
||||
return element.inputId == selectedInputId
|
||||
return element.selected == true
|
||||
}) {
|
||||
return selectors[index]
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user