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