converted to property

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-04-26 17:00:43 -05:00
parent 8cbef2e910
commit ff51eb6f51
4 changed files with 108 additions and 86 deletions

View File

@ -21,13 +21,38 @@ open class CheckboxGroup: SelectorGroupHandlerBase<Checkbox> {
}
public override var selectorViews: [Checkbox] {
willSet {
mainStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
}
didSet {
for selector in selectorViews {
if !mainStackView.arrangedSubviews.contains(selector) {
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
}
mainStackView.addArrangedSubview(selector)
}
}
}
public var selectorModels: [CheckboxModel]? {
didSet {
if let selectorModels {
selectorViews = selectorModels.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
}
mainStackView.addArrangedSubview(selector)
}
}
}
@ -117,24 +142,5 @@ extension CheckboxGroup {
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
}
}
}
}

View File

@ -15,18 +15,41 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBox> {
// MARK: - Public Properties
//--------------------------------------------------
public override var selectorViews: [RadioBox] {
willSet {
mainStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
}
didSet {
for selector in selectorViews {
if !mainStackView.arrangedSubviews.contains(selector) {
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
}
mainStackView.addArrangedSubview(selector)
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
}
mainStackView.addArrangedSubview(selector)
}
}
}
public var selectorModels: [RadioBoxModel]? {
didSet {
if let selectorModels {
selectorViews = selectorModels.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
}
}
}
}
}
//--------------------------------------------------
// MARK: - Private Properties
//--------------------------------------------------
@ -119,21 +142,4 @@ extension RadioBoxGroup {
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
}
}
}
}

View File

@ -15,13 +15,38 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButton> {
// MARK: - Public Properties
//--------------------------------------------------
public override var selectorViews: [RadioButton] {
willSet {
mainStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
}
didSet {
for selector in selectorViews {
if !mainStackView.arrangedSubviews.contains(selector) {
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
selector.onClick = { [weak self] handler in
self?.didSelect(handler)
}
mainStackView.addArrangedSubview(selector)
}
}
}
public var selectorModels: [RadioButtonModel]? {
didSet {
if let selectorModels {
selectorViews = selectorModels.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
}
mainStackView.addArrangedSubview(selector)
}
}
}
@ -122,23 +147,4 @@ extension RadioButtonGroup {
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
}
}
}
}

View File

@ -20,6 +20,28 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
collectionView.reloadData()
}
}
public var selectorModels: [RadioSwatchModel]? {
didSet {
if let selectorModels {
selectorViews = selectorModels.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
}
}
}
}
}
//--------------------------------------------------
// MARK: - Private Properties
@ -200,23 +222,5 @@ extension RadioSwatchGroup {
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
}
}
}
}