added model extensions on selectorviews
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
0be4e04091
commit
8cbef2e910
@ -82,3 +82,59 @@ open class CheckboxGroup: SelectorGroupHandlerBase<Checkbox> {
|
||||
}
|
||||
}
|
||||
|
||||
extension CheckboxGroup {
|
||||
public struct CheckboxModel : Surfaceable, Disabling, Initable, FormFieldable, Errorable {
|
||||
|
||||
public var disabled: Bool
|
||||
public var surface: Surface
|
||||
public var inputId: String?
|
||||
public var value: AnyHashable?
|
||||
public var accessibileText: String?
|
||||
public var labelText: String?
|
||||
public var labelTextAttributes: [any LabelAttributeModel]?
|
||||
public var childText: String?
|
||||
public var childTextAttributes: [any LabelAttributeModel]?
|
||||
public var selected: Bool
|
||||
public var showError: Bool
|
||||
public var errorText: String?
|
||||
|
||||
public init(disabled: Bool, surface: Surface = .light, inputId: String? = nil, value: AnyHashable? = nil, accessibileText: String? = nil, labelText: String? = nil, labelTextAttributes: [any LabelAttributeModel]? = nil, childText: String? = nil, childTextAttributes: [any LabelAttributeModel]? = nil, selected: Bool = false, showError: Bool = false, errorText: String? = nil) {
|
||||
self.disabled = disabled
|
||||
self.surface = surface
|
||||
self.inputId = inputId
|
||||
self.value = value
|
||||
self.accessibileText = accessibileText
|
||||
self.labelText = labelText
|
||||
self.labelTextAttributes = labelTextAttributes
|
||||
self.childText = childText
|
||||
self.childTextAttributes = childTextAttributes
|
||||
self.selected = selected
|
||||
self.showError = showError
|
||||
self.errorText = errorText
|
||||
}
|
||||
|
||||
public init() {
|
||||
self.init(disabled: false)
|
||||
}
|
||||
}
|
||||
|
||||
public func setSelectorViewModels(models: [CheckboxModel]) {
|
||||
selectorViews = models.map { model in
|
||||
return Checkbox().with {
|
||||
$0.disabled = model.disabled
|
||||
$0.surface = model.surface
|
||||
$0.inputId = model.inputId
|
||||
$0.value = model.value
|
||||
$0.accessibilityLabel = model.accessibileText
|
||||
$0.labelText = model.labelText
|
||||
$0.labelTextAttributes = model.labelTextAttributes
|
||||
$0.childText = model.childText
|
||||
$0.childTextAttributes = model.childTextAttributes
|
||||
$0.isSelected = model.selected
|
||||
$0.errorText = model.errorText
|
||||
$0.showError = model.showError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -80,3 +80,60 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBox> {
|
||||
valueChanged()
|
||||
}
|
||||
}
|
||||
|
||||
extension RadioBoxGroup {
|
||||
public struct RadioBoxModel: Surfaceable, Initable, Disabling, FormFieldable {
|
||||
public var disabled: Bool
|
||||
public var surface: Surface
|
||||
public var inputId: String?
|
||||
public var value: AnyHashable?
|
||||
public var accessibileText: String?
|
||||
public var text: String
|
||||
public var textAttributes: [any LabelAttributeModel]?
|
||||
public var subText: String?
|
||||
public var subTextAttributes: [any LabelAttributeModel]?
|
||||
public var subTextRight: String?
|
||||
public var subTextRightAttributes: [any LabelAttributeModel]?
|
||||
public var selected: Bool
|
||||
|
||||
public init(disabled: Bool, surface: Surface = .light, inputId: String? = nil, value: AnyHashable? = nil,
|
||||
text: String = "", textAttributes: [any LabelAttributeModel]? = nil,
|
||||
subText: String? = nil, subTextAttributes: [any LabelAttributeModel]? = nil,
|
||||
subTextRight: String? = nil, subTextRightAttributes: [any LabelAttributeModel]? = nil,
|
||||
selected: Bool = false, errorText: String? = nil, accessibileText: String? = nil) {
|
||||
self.disabled = disabled
|
||||
self.surface = surface
|
||||
self.inputId = inputId
|
||||
self.value = value
|
||||
self.text = text
|
||||
self.textAttributes = textAttributes
|
||||
self.subText = subText
|
||||
self.subTextAttributes = subTextAttributes
|
||||
self.subTextRight = subTextRight
|
||||
self.subTextRightAttributes = subTextRightAttributes
|
||||
self.selected = selected
|
||||
self.accessibileText = accessibileText
|
||||
}
|
||||
|
||||
public init() {
|
||||
self.init(disabled: false)
|
||||
}
|
||||
}
|
||||
|
||||
public func setSelectorViewModels(models: [RadioBoxModel]) {
|
||||
selectorViews = models.map { model in
|
||||
return RadioBox().with {
|
||||
$0.accessibilityLabel = model.accessibileText
|
||||
$0.text = model.text
|
||||
$0.textAttributes = model.textAttributes
|
||||
$0.subText = model.subText
|
||||
$0.subTextAttributes = model.subTextAttributes
|
||||
$0.subTextRight = model.subText
|
||||
$0.subTextRightAttributes = model.subTextAttributes
|
||||
$0.disabled = model.disabled
|
||||
$0.inputId = model.inputId
|
||||
$0.isSelected = model.selected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,3 +86,59 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButton> {
|
||||
radioButton.isSelected.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
extension RadioButtonGroup {
|
||||
public struct RadioButtonModel: Surfaceable, Disabling, Initable, FormFieldable, Errorable {
|
||||
|
||||
public var disabled: Bool
|
||||
public var surface: Surface
|
||||
public var inputId: String?
|
||||
public var value: AnyHashable?
|
||||
public var accessibileText: String?
|
||||
public var labelText: String?
|
||||
public var labelTextAttributes: [any LabelAttributeModel]?
|
||||
public var childText: String?
|
||||
public var childTextAttributes: [any LabelAttributeModel]?
|
||||
public var selected: Bool
|
||||
public var showError: Bool
|
||||
public var errorText: String?
|
||||
|
||||
public init(disabled: Bool, surface: Surface = .light, inputId: String? = nil, value: AnyHashable? = nil, accessibileText: String? = nil, labelText: String? = nil, labelTextAttributes: [any LabelAttributeModel]? = nil, childText: String? = nil, childTextAttributes: [any LabelAttributeModel]? = nil, selected: Bool = false, showError: Bool = false, errorText: String? = nil) {
|
||||
self.disabled = disabled
|
||||
self.surface = surface
|
||||
self.inputId = inputId
|
||||
self.value = value
|
||||
self.accessibileText = accessibileText
|
||||
self.labelText = labelText
|
||||
self.labelTextAttributes = labelTextAttributes
|
||||
self.childText = childText
|
||||
self.childTextAttributes = childTextAttributes
|
||||
self.selected = selected
|
||||
self.showError = showError
|
||||
self.errorText = errorText
|
||||
}
|
||||
|
||||
public init() {
|
||||
self.init(disabled: false)
|
||||
}
|
||||
}
|
||||
|
||||
public func setSelectorViewModels(models: [RadioButtonModel]) {
|
||||
selectorViews = models.map { model in
|
||||
return RadioButton().with {
|
||||
$0.disabled = model.disabled
|
||||
$0.surface = model.surface
|
||||
$0.inputId = model.inputId
|
||||
$0.value = model.value
|
||||
$0.accessibilityLabel = model.accessibileText
|
||||
$0.labelText = model.labelText
|
||||
$0.labelTextAttributes = model.labelTextAttributes
|
||||
$0.childText = model.childText
|
||||
$0.childTextAttributes = model.childTextAttributes
|
||||
$0.isSelected = model.selected
|
||||
$0.errorText = model.errorText
|
||||
$0.showError = model.showError
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,3 +165,58 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
||||
valueChanged()
|
||||
}
|
||||
}
|
||||
|
||||
extension RadioSwatchGroup {
|
||||
public struct RadioSwatchModel: Surfaceable, Disabling, Initable {
|
||||
public var disabled: Bool = false
|
||||
public var surface: Surface
|
||||
public var inputId: String?
|
||||
public var value: AnyHashable?
|
||||
public var selected: Bool = false
|
||||
public var text: String
|
||||
public var fillImage: UIImage?
|
||||
public var primaryColor: UIColor?
|
||||
public var secondaryColor: UIColor?
|
||||
public var strikethrough: Bool = false
|
||||
public var accessibileText: String?
|
||||
|
||||
public init(disabled: Bool, surface: Surface = .light, inputId: String? = nil, value: AnyHashable? = nil, selected: Bool = false,
|
||||
text: String = "", fillImage: UIImage? = nil, primaryColor: UIColor? = nil, secondaryColor: UIColor? = nil,
|
||||
strikethrough: Bool = false, accessibileText: String? = nil) {
|
||||
self.disabled = disabled
|
||||
self.surface = surface
|
||||
self.inputId = inputId
|
||||
self.value = value
|
||||
self.selected = selected
|
||||
self.text = text
|
||||
self.fillImage = fillImage
|
||||
self.primaryColor = primaryColor
|
||||
self.secondaryColor = secondaryColor
|
||||
self.strikethrough = strikethrough
|
||||
self.accessibileText = accessibileText
|
||||
}
|
||||
|
||||
public init() {
|
||||
self.init(disabled: false)
|
||||
}
|
||||
}
|
||||
|
||||
public func setSelectorViewModels(models: [RadioSwatchModel]) {
|
||||
selectorViews = models.map { model in
|
||||
return RadioSwatch().with {
|
||||
$0.accessibilityLabel = model.accessibileText
|
||||
$0.text = model.text
|
||||
$0.fillImage = model.fillImage
|
||||
$0.primaryColor = model.primaryColor
|
||||
$0.secondaryColor = model.secondaryColor
|
||||
$0.strikethrough = model.strikethrough
|
||||
$0.disabled = model.disabled
|
||||
$0.surface = model.surface
|
||||
$0.inputId = model.inputId
|
||||
$0.value = model.value
|
||||
$0.isSelected = model.selected
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user