From 2a589b1e2257696cf553887401c26dbc1aecc3a2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 29 Aug 2023 14:00:23 -0500 Subject: [PATCH] more comments Signed-off-by: Matt Bruce --- VDS/BaseClasses/Selector/SelectorBase.swift | 1 + VDS/Components/Checkbox/CheckboxGroup.swift | 1 + .../RadioButton/RadioButtonGroup.swift | 1 + .../TextFields/EntryFieldBase.swift | 2 ++ .../TextFields/InputField/InputField.swift | 20 +++++++++++++------ .../TextFields/TextArea/TextArea.swift | 15 ++++++++------ 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/VDS/BaseClasses/Selector/SelectorBase.swift b/VDS/BaseClasses/Selector/SelectorBase.swift index 6279c10d..6a938b15 100644 --- a/VDS/BaseClasses/Selector/SelectorBase.swift +++ b/VDS/BaseClasses/Selector/SelectorBase.swift @@ -58,6 +58,7 @@ open class SelectorBase: Control, SelectorControlable { open var size = CGSize(width: 20, height: 20) { didSet { setNeedsUpdate() }} var _showError: Bool = false + /// Whether not to show the error. open var showError: Bool { get { _showError } set { diff --git a/VDS/Components/Checkbox/CheckboxGroup.swift b/VDS/Components/Checkbox/CheckboxGroup.swift index fd1808be..34fc657d 100644 --- a/VDS/Components/Checkbox/CheckboxGroup.swift +++ b/VDS/Components/Checkbox/CheckboxGroup.swift @@ -107,6 +107,7 @@ extension CheckboxGroup { /// Array of LabelAttributeModel objects used in rendering the childText. public var childTextAttributes: [any LabelAttributeModel]? public var selected: Bool + /// Whether not to show the error. public var showError: Bool public var errorText: String? diff --git a/VDS/Components/RadioButton/RadioButtonGroup.swift b/VDS/Components/RadioButton/RadioButtonGroup.swift index 74553ebe..c0d7a433 100644 --- a/VDS/Components/RadioButton/RadioButtonGroup.swift +++ b/VDS/Components/RadioButton/RadioButtonGroup.swift @@ -121,6 +121,7 @@ extension RadioButtonGroup { /// Array of LabelAttributeModel objects used in rendering the childText. public var childTextAttributes: [any LabelAttributeModel]? public var selected: Bool + /// Whether not to show the error. public var showError: Bool public var errorText: String? diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index b6519f28..07bdba89 100644 --- a/VDS/Components/TextFields/EntryFieldBase.swift +++ b/VDS/Components/TextFields/EntryFieldBase.swift @@ -135,6 +135,7 @@ open class EntryFieldBase: Control, Changeable { open var helperText: String? { didSet { setNeedsUpdate() }} + /// Whether not to show the error. open var showError: Bool = false { didSet { setNeedsUpdate() }} /// Override UIControl state to add the .error state if showError is true. @@ -277,6 +278,7 @@ open class EntryFieldBase: Control, Changeable { //-------------------------------------------------- // MARK: - Public Methods //-------------------------------------------------- + /// Container for the area in which the user interacts. open func getContainer() -> UIView { return containerView } diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index ad6367ef..d77927ae 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -51,30 +51,35 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { } }() - open var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { - $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) - $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) - }.eraseToAnyColorable() - internal var minWidthConstraint: NSLayoutConstraint? //-------------------------------------------------- // MARK: - Public Properties //-------------------------------------------------- + /// Label to render the successText. open var successLabel = Label().with { $0.setContentCompressionResistancePriority(.required, for: .vertical) $0.textPosition = .left $0.textStyle = .bodySmall } + /// UITextField shown in the InputField. open var textField = UITextField().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.font = TextStyle.bodyLarge.font } + + /// Color configuration for the textField. + open var textFieldTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { + $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) + $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) + }.eraseToAnyColorable() + /// Representing the type of input. open var type: FieldType = .text { didSet { setNeedsUpdate() }} var _showError: Bool = false + /// Whether not to show the error. open override var showError: Bool { get { _showError } set { @@ -86,6 +91,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { } var _showSuccess: Bool = false + /// Whether not to show the success. open var showSuccess: Bool { get { _showSuccess } set { @@ -106,9 +112,10 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { return state } } - + /// If given, this will be shown if showSuccess if true. open var successText: String? { didSet { setNeedsUpdate() }} + /// Determines the placement of the helper text. open var helperTextPlacement: HelperTextPlacement = .bottom { didSet { setNeedsUpdate() }} //-------------------------------------------------- @@ -158,6 +165,7 @@ open class InputField: EntryFieldBase, UITextFieldDelegate { helperTextPlacement = .bottom } + /// Container for the area in which the user interacts. open override func getContainer() -> UIView { inputFieldStackView.addArrangedSubview(containerView) return inputFieldStackView diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 5a31fb1e..4b4bd85b 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -34,6 +34,9 @@ open class TextArea: EntryFieldBase { //-------------------------------------------------- // MARK: - Private Properties //-------------------------------------------------- + internal var minWidthConstraint: NSLayoutConstraint? + internal var textViewHeightConstraint: NSLayoutConstraint? + internal var inputFieldStackView: UIStackView = { return UIStackView().with { $0.translatesAutoresizingMaskIntoConstraints = false @@ -47,22 +50,21 @@ open class TextArea: EntryFieldBase { // MARK: - Public Properties //-------------------------------------------------- override var containerSize: CGSize { CGSize(width: 45, height: 88) } - - private var textView = UITextView().with { + + /// UITextView shown in the TextArea. + open var textView = UITextView().with { $0.translatesAutoresizingMaskIntoConstraints = false $0.font = TextStyle.bodyLarge.font $0.sizeToFit() $0.isScrollEnabled = false } + /// Color configuration for the textView. open var textViewTextColorConfiguration: AnyColorable = ViewColorConfiguration().with { $0.setSurfaceColors(VDSColor.interactiveDisabledOnlight, VDSColor.interactiveDisabledOndark, forDisabled: true) $0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false) }.eraseToAnyColorable() { didSet { setNeedsUpdate() }} - - internal var minWidthConstraint: NSLayoutConstraint? - internal var textViewHeightConstraint: NSLayoutConstraint? - + //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- @@ -89,6 +91,7 @@ open class TextArea: EntryFieldBase { textView.text = "" } + /// Container for the area in which the user interacts. open override func getContainer() -> UIView { inputFieldStackView.addArrangedSubview(containerView) return inputFieldStackView