From fa3d139742f470a97b0f41cf0d005db04092a55d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 3 Oct 2022 12:21:27 -0500 Subject: [PATCH] refactored hasError to showError Signed-off-by: Matt Bruce --- VDS/Components/Checkbox/Checkbox.swift | 10 +++++----- VDS/Components/Checkbox/CheckboxGroup.swift | 18 +++++++++--------- .../Checkbox/CheckboxGroupModel.swift | 2 +- VDS/Components/Checkbox/CheckboxModel.swift | 8 ++++---- .../RadioBox/RadioBoxGroupModel.swift | 2 +- VDS/Components/RadioButton/RadioButton.swift | 14 +++++++------- .../RadioButton/RadioButtonGroup.swift | 18 +++++++++--------- .../RadioButton/RadioButtonGroupModel.swift | 2 +- .../RadioButton/RadioButtonModel.swift | 8 ++++---- VDS/Protocols/Errorable.swift | 2 +- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 2d24d803..46e6d034 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -82,8 +82,8 @@ open class CheckboxBase: Control { @Proxy(\.model.childText) open var childText: String? - @Proxy(\.model.hasError) - open var hasError: Bool + @Proxy(\.model.showError) + open var showError: Bool @Proxy(\.model.errorText) open var errorText: String? @@ -219,8 +219,8 @@ open class CheckboxBase: Control { /// This will checkbox the state of the Selector and execute the actionBlock if provided. open func toggle() { //removed error - if hasError && isSelected == false { - hasError.toggle() + if showError && isSelected == false { + showError.toggle() } isSelected.toggle() sendActions(for: .valueChanged) @@ -354,7 +354,7 @@ open class CheckboxBase: Control { public let error = BinarySurfaceColorConfiguration() override func getColor(_ viewModel: ModelType) -> UIColor { //only show error is enabled and showError == true - let showErrorColor = !viewModel.disabled && viewModel.hasError + let showErrorColor = !viewModel.disabled && viewModel.showError if showErrorColor { return error.getColor(viewModel) diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index bdad7d36..67d87993 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -11,8 +11,8 @@ import UIKit public class CheckboxGroup: CheckboxGroupBase { public override func didSelect(_ selectedControl: Checkbox) { selectedControl.toggle() - if selectedControl.isSelected, hasError{ - hasError.toggle() + if selectedControl.isSelected, showError{ + showError.toggle() } valueChanged() } @@ -23,18 +23,18 @@ public class CheckboxGroupBase 0 - if anySelected && newHasError { - newHasError = false + if anySelected && newShowError { + newShowError = false } selectorViews.forEach { handler in - handler.hasError = newHasError + handler.showError = newShowError } - model.hasError = newHasError + model.showError = newShowError } } diff --git a/VDS/Components/Checkbox/CheckboxGroupModel.swift b/VDS/Components/Checkbox/CheckboxGroupModel.swift index e56c72d6..93e253ab 100644 --- a/VDS/Components/Checkbox/CheckboxGroupModel.swift +++ b/VDS/Components/Checkbox/CheckboxGroupModel.swift @@ -19,7 +19,7 @@ public struct DefaultCheckboxGroupModel: CheckboxGroupModel { public var surface: Surface = .light public var disabled: Bool = false public var selectors: [SelectorModelType] - public var hasError: Bool = false + public var showError: Bool = false public var errorText: String? public init() { selectors = [] } public init(selectors: [SelectorModelType]){ diff --git a/VDS/Components/Checkbox/CheckboxModel.swift b/VDS/Components/Checkbox/CheckboxModel.swift index 160aab95..fad6c1e3 100644 --- a/VDS/Components/Checkbox/CheckboxModel.swift +++ b/VDS/Components/Checkbox/CheckboxModel.swift @@ -18,7 +18,7 @@ public protocol CheckboxModel: Modelable, FormFieldable, Errorable, DataTrackabl extension CheckboxModel { public var shouldShowError: Bool { - guard hasError && !disabled && errorText?.isEmpty == false else { return false } + guard showError && !disabled && errorText?.isEmpty == false else { return false } return true } @@ -52,7 +52,7 @@ extension CheckboxModel { } public var errorModel: DefaultLabelModel? { - guard let errorText = errorText, hasError else { return nil } + guard let errorText = errorText, showError else { return nil } var model = DefaultLabelModel() model.textPosition = .left model.typograpicalStyle = .BodyMedium @@ -71,7 +71,7 @@ public struct DefaultCheckboxModel: CheckboxModel { public var childText: String? public var childTextAttributes: [any LabelAttributeModel]? - public var hasError: Bool = false + public var showError: Bool = false public var errorText: String? public var inputId: String? @@ -103,7 +103,7 @@ public struct DefaultCheckboxModel: CheckboxModel { && labelTextAttributes == equatable.labelTextAttributes && childText == equatable.childText && childTextAttributes == equatable.childTextAttributes - && hasError == equatable.hasError + && showError == equatable.showError && errorText == equatable.errorText && inputId == equatable.inputId && value == equatable.value diff --git a/VDS/Components/RadioBox/RadioBoxGroupModel.swift b/VDS/Components/RadioBox/RadioBoxGroupModel.swift index f61dae3c..2a7e9413 100644 --- a/VDS/Components/RadioBox/RadioBoxGroupModel.swift +++ b/VDS/Components/RadioBox/RadioBoxGroupModel.swift @@ -17,7 +17,7 @@ public struct DefaultRadioBoxGroupModel: RadioBoxGroupModel { public var surface: Surface = .light public var disabled: Bool = false public var selectors: [SelectorModelType] - public var hasError: Bool = false + public var showError: Bool = false public var errorText: String? public init() { selectors = [] } public init(selectors: [SelectorModelType]){ diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index d0e3100f..be4a6967 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -14,8 +14,8 @@ public class RadioButton: RadioButtonBase{ //for groups allows "toggle" open override func toggle() { //removed error - if hasError && isSelected == false { - hasError.toggle() + if showError && isSelected == false { + showError.toggle() } isSelected.toggle() } @@ -90,8 +90,8 @@ open class RadioButtonBase: Control { @Proxy(\.model.childText) open var childText: String? - @Proxy(\.model.hasError) - open var hasError: Bool + @Proxy(\.model.showError) + open var showError: Bool @Proxy(\.model.errorText) open var errorText: String? @@ -229,8 +229,8 @@ open class RadioButtonBase: Control { guard !isSelected else { return } //removed error - if hasError && isSelected == false { - hasError.toggle() + if showError && isSelected == false { + showError.toggle() } isSelected.toggle() sendActions(for: .valueChanged) @@ -346,7 +346,7 @@ open class RadioButtonBase: Control { public let error = BinarySurfaceColorConfiguration() override func getColor(_ viewModel: ModelType) -> UIColor { //only show error is enabled and showError == true - let showErrorColor = !viewModel.disabled && viewModel.hasError + let showErrorColor = !viewModel.disabled && viewModel.showError if showErrorColor { return error.getColor(viewModel) diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 8b499f73..7d48e404 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -14,8 +14,8 @@ public class RadioButtonGroup: RadioButtonGroupBase