From a4b550cf0394cf811931f44a90f2e7a4ed6d100f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 10:19:01 -0500 Subject: [PATCH 01/14] first cut of textEntry Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 316 ++++++------------ .../TextFields/TextViewEntryFieldModel.swift | 29 +- 2 files changed, 113 insertions(+), 232 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 46e4e233..415f1bb4 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -7,123 +7,63 @@ // import UIKit +import VDS - -class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDelegate { - //-------------------------------------------------- - // MARK: - Outlets - //-------------------------------------------------- - - open private(set) var textView: TextView = { - let textView = TextView() - textView.setContentCompressionResistancePriority(.required, for: .vertical) - return textView - }() - - //-------------------------------------------------- +class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFieldDelegate { + //------------------------------------------------------ // MARK: - Properties - //-------------------------------------------------- + //------------------------------------------------------ + open var viewModel: TextViewEntryFieldModel! + open var delegateObject: MVMCoreUIDelegateObject? + open var additionalData: [AnyHashable : Any]? + + // Form Validation + var fieldKey: String? + var fieldValue: JSONValue? + var groupName: String? - private var observingForChange: Bool = false + //-------------------------------------------------- + // MARK: - Stored Properties + //-------------------------------------------------- + public var isValid: Bool = true + + private var isEditting: Bool = false { + didSet { + viewModel.selected = isEditting + } + } //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- - - public var textViewEntryFieldModel: TextViewEntryFieldModel? { - model as? TextViewEntryFieldModel - } - - public override var isEnabled: Bool { - get { super.isEnabled } - set (enabled) { - super.isEnabled = enabled - - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.textView.isEnabled = enabled - if self.textView.isShowingPlaceholder { - self.textView.textColor = self.textView.placeholderTextColor - } else { - self.textView.textColor = (self.textView.isEnabled ? self.textViewEntryFieldModel?.enabledTextColor : self.textViewEntryFieldModel?.disabledTextColor)?.uiColor - } - } - } - } - - public override var showError: Bool { - get { super.showError } - set (error) { - - if error { - textView.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textView_error_message") ?? "", textView.text ?? "", entryFieldModel?.errorMessage ?? "") - } else { - textView.accessibilityValue = nil - } - - super.showError = error - } - } - /// The text of this textView. open override var text: String? { - get { textViewEntryFieldModel?.text } - set { - textView.text = newValue - textViewEntryFieldModel?.text = newValue + didSet { + viewModel?.text = text } } /// Placeholder access for the textView. public var placeholder: String? { - get { textViewEntryFieldModel?.placeholder } + get { viewModel?.placeholder } set { textView.placeholder = newValue ?? "" - textViewEntryFieldModel?.placeholder = newValue - textView.setPlaceholderIfAvailable() + viewModel?.placeholder = newValue } } - //-------------------------------------------------- - // MARK: - Constraint - //-------------------------------------------------- - - public var heightConstraint: NSLayoutConstraint? - private var topConstraint: NSLayoutConstraint? - private var leadingConstraint: NSLayoutConstraint? - private var trailingConstraint: NSLayoutConstraint? - private var bottomConstraint: NSLayoutConstraint? - - private func adjustMarginConstraints(constant: CGFloat) { - - topConstraint?.constant = constant - leadingConstraint?.constant = constant - trailingConstraint?.constant = constant - bottomConstraint?.constant = constant + override var errorText: String? { + get { + viewModel.dynamicErrorMessage ?? viewModel.errorMessage + } + set {} } - //-------------------------------------------------- // MARK: - Delegate Properties //-------------------------------------------------- /// The delegate and block for validation. Validates if the text that the user has entered. - public weak var observingTextViewDelegate: ObservingTextFieldDelegate? { - didSet { - if observingTextViewDelegate != nil && !observingForChange { - observingForChange = true - NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextView.textDidChangeNotification, object: textView) - NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextView.textDidEndEditingNotification, object: textView) - NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextView.textDidBeginEditingNotification, object: textView) - - } else if observingTextViewDelegate == nil && observingForChange { - observingForChange = false - NotificationCenter.default.removeObserver(self, name: UITextView.textDidChangeNotification, object: textView) - NotificationCenter.default.removeObserver(self, name: UITextView.textDidEndEditingNotification, object: textView) - NotificationCenter.default.removeObserver(self, name: UITextView.textDidBeginEditingNotification, object: textView) - } - } - } + public weak var observingTextViewDelegate: ObservingTextFieldDelegate? /// If you're using a ViewController, you must set this to it public weak var uiTextViewDelegate: UITextViewDelegate? { @@ -136,102 +76,49 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele uiTextViewDelegate = delegate } - open func setupTextViewToolbar() { - let observingDelegate = observingTextViewDelegate ?? self - textView.inputAccessoryView = UIToolbar.getToolbarWithDoneButton(delegate: observingDelegate, - action: #selector(observingDelegate.dismissFieldInput)) - } - //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- - - @objc open override func setupFieldContainerContent(_ container: UIView) { + override func setup() { + super.setup() - container.addSubview(textView) + publisher(for: .valueChanged) + .sink { [weak self] control in + guard let self else { return } + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + }.store(in: &subscribers) - topConstraint = textView.topAnchor.constraint(equalTo: container.topAnchor, constant: Padding.Three) - leadingConstraint = textView.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: Padding.Three) - trailingConstraint = container.trailingAnchor.constraint(equalTo: textView.trailingAnchor, constant: Padding.Three) - bottomConstraint = container.bottomAnchor.constraint(equalTo: textView.bottomAnchor, constant: Padding.Three) + textView + .publisher(for: .editingDidBegin) + .sink { [weak self] textView in + guard let self else { return } + isEditting = true + + }.store(in: &subscribers) - topConstraint?.isActive = true - leadingConstraint?.isActive = true - trailingConstraint?.isActive = true - bottomConstraint?.isActive = true - - heightConstraint = textView.heightAnchor.constraint(equalToConstant: 0) - accessibilityElements = [textView] + textView + .publisher(for: .editingDidEnd) + .sink { [weak self] textView in + guard let self else { return } + isEditting = false + if let valid = viewModel.isValid { + isValid = valid + } + showError = !isValid + + }.store(in: &subscribers) + + //String(format: MVMCoreUIUtility.hardcodedString(withKey: "textView_error_message") ?? "", textView.text ?? "", entryFieldModel?.errorMessage ?? "") } - - open override func updateView(_ size: CGFloat) { - super.updateView(size) - textView.updateView(size) - } - - open override func reset() { - super.reset() - textView.reset() - adjustMarginConstraints(constant: Padding.Three) - heightConstraint?.constant = 0 - heightConstraint?.isActive = false - } - - //-------------------------------------------------- - // MARK: - Methods - //-------------------------------------------------- - - /// Validates the text of the entry field. - @objc public override func validateText() { - text = textView.text - super.validateText() - } - - /// Executes on UITextView.textDidBeginEditingNotification - @objc override func startEditing() { - super.startEditing() - _ = textView.becomeFirstResponder() - } - - /// Executes on UITextView.textDidChangeNotification (each character entry) - @objc override func valueChanged() { - super.valueChanged() - validateText() - } - - /// Executes on UITextView.textDidEndEditingNotification - @objc override func endInputing() { - super.endInputing() - - // Don't show error till user starts typing. - guard text?.count ?? 0 != 0 else { - showError = false - return - } - - if let isValid = textViewEntryFieldModel?.isValid { - self.isValid = isValid - } - - showError = !isValid - } - //-------------------------------------------------- // MARK: - MoleculeViewProtocol //-------------------------------------------------- + open func updateView(_ size: CGFloat) {} + + open func viewModelDidUpdate() { - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - - guard let model = model as? TextViewEntryFieldModel else { return } - - if let height = model.height { - heightConstraint?.constant = height - heightConstraint?.isActive = true - } - - text = model.text + text = viewModel.text uiTextViewDelegate = delegateObject?.uiTextViewDelegate observingTextViewDelegate = delegateObject?.observingTextFieldDelegate @@ -239,17 +126,12 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele accessibilityLabel = accessibilityText } - textView.isEditable = model.editable - textView.textAlignment = model.textAlignment + textView.isEditable = viewModel.editable + textView.textAlignment = viewModel.textAlignment textView.accessibilityIdentifier = model.accessibilityIdentifier - textView.textColor = model.enabled ? model.enabledTextColor.uiColor : model.disabledTextColor.uiColor - textView.font = model.fontStyle.getFont() - textView.placeholder = model.placeholder ?? "" - textView.placeholderFontStyle = model.placeholderFontStyle - textView.placeholderTextColor = model.placeholderTextColor.uiColor - textView.setPlaceholderIfAvailable() + textView.placeholder = viewModel.placeholder ?? "" - switch model.type { + switch viewModel.type { case .secure, .password: textView.isSecureTextEntry = true @@ -266,40 +148,60 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele default: break } + if (viewModel.selected ?? false) && !viewModel.wasInitiallySelected { + + viewModel.wasInitiallySelected = true + isEditting = true + } + /// No point in configuring if the TextView is Read-only. if textView.isEditable { - FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - setupTextViewToolbar() + FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) - if isSelected { + if isEditting { DispatchQueue.main.async { - _ = self.textView.becomeFirstResponder() + _ = self.becomeFirstResponder() } } } - if model.hideBorders { - adjustMarginConstraints(constant: 0) + viewModel.updateUI = { + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + guard let self = self else { return } + + if isEditting { + updateValidation(viewModel.isValid ?? true) + + } else if viewModel.isValid ?? true && showError { + showError = false + } + isEnabled = viewModel.enabled + }) } - updateAccessibility(model: model) + + viewModel.updateUIDynamicError = { + MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in + guard let self = self else { return } + + let validState = viewModel.isValid ?? false + if !validState && viewModel.shouldClearText { + text = "" + viewModel.shouldClearText = false + } + updateValidation(validState) + }) + } + } - func updateAccessibility(model: TextViewEntryFieldModel) { + private func updateValidation(_ isValid: Bool) { + let previousValidity = self.isValid + self.isValid = isValid - var message = "" - - if let titleText = model.accessibilityText ?? model.title { - message += "\(titleText) \( model.enabled ? String(format: (MVMCoreUIUtility.hardcodedString(withKey: "textfield_optional")) ?? "") : "" ) \(self.textView.isEnabled ? "" : MVMCoreUIUtility.hardcodedString(withKey: "textfield_disabled_state") ?? "")" + if previousValidity && !isValid { + showError = true + } else if (!previousValidity && isValid) { + showError = false } - - if let feedback = model.feedback { - message += ", " + feedback - } - - if let errorMessage = errorLabel.text { - message += ", " + errorMessage - } - - textView.accessibilityLabel = message } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index 42da3ca2..fa941d10 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -17,12 +17,9 @@ class TextViewEntryFieldModel: TextEntryFieldModel { public override class var identifier: String { "textView" } public var accessibilityText: String? - public var fontStyle: Styler.Font = Styler.Font.RegularBodyLarge - public var height: CGFloat? - public var placeholderTextColor: Color = Color(uiColor: .mvmCoolGray3) - public var placeholderFontStyle: Styler.Font = Styler.Font.RegularMicro public var editable: Bool = true public var showsPlaceholder: Bool = false + public var tooltip: TooltipModel? //-------------------------------------------------- // MARK: - Keys @@ -30,11 +27,8 @@ class TextViewEntryFieldModel: TextEntryFieldModel { private enum CodingKeys: String, CodingKey { case accessibilityText - case fontStyle - case height - case placeholderFontStyle - case placeholderTextColor case editable + case tooltip } //-------------------------------------------------- @@ -45,34 +39,19 @@ class TextViewEntryFieldModel: TextEntryFieldModel { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - if let placeholderFontStyle = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .placeholderFontStyle) { - self.placeholderFontStyle = placeholderFontStyle - } - - if let placeholderTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .placeholderTextColor) { - self.placeholderTextColor = placeholderTextColor - } - - if let fontStyle = try typeContainer.decodeIfPresent(Styler.Font.self, forKey: .fontStyle) { - self.fontStyle = fontStyle - } - if let editable = try typeContainer.decodeIfPresent(Bool.self, forKey: .editable) { self.editable = editable } accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - height = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .height) + tooltip = try typeContainer.decodeIfPresent(TooltipModel.self, forKey: .tooltip) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) - try container.encodeIfPresent(height, forKey: .height) - try container.encode(fontStyle, forKey: .fontStyle) try container.encode(editable, forKey: .editable) - try container.encode(placeholderFontStyle, forKey: .placeholderFontStyle) - try container.encode(placeholderTextColor, forKey: .placeholderTextColor) + try container.encodeIfPresent(tooltip, forKey: .tooltip) } } From 9e9a1ab853e497a28f64856e3fdc89640fd686b3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 11:23:14 -0500 Subject: [PATCH 02/14] added properties from model Signed-off-by: Matt Bruce --- .../FormFields/TextFields/TextViewEntryField.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 415f1bb4..21eb169f 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -102,10 +102,9 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi guard let self else { return } isEditting = false if let valid = viewModel.isValid { - isValid = valid + updateValidation(valid) } - showError = !isValid - + }.store(in: &subscribers) //String(format: MVMCoreUIUtility.hardcodedString(withKey: "textView_error_message") ?? "", textView.text ?? "", entryFieldModel?.errorMessage ?? "") @@ -119,6 +118,13 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi open func viewModelDidUpdate() { text = viewModel.text + labelText = viewModel.title + helperText = viewModel.feedback + isEnabled = viewModel.enabled + isReadOnly = viewModel.readOnly + isRequired = viewModel.required + tooltipModel = viewModel.tooltip?.toVDSTooltipModel() + uiTextViewDelegate = delegateObject?.uiTextViewDelegate observingTextViewDelegate = delegateObject?.observingTextFieldDelegate From c7a4bf72c31c200f1798220148835921843a9f80 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 12:00:54 -0500 Subject: [PATCH 03/14] added more propeties Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 2 ++ .../TextFields/TextViewEntryFieldModel.swift | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 21eb169f..382c418c 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -124,6 +124,8 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi isReadOnly = viewModel.readOnly isRequired = viewModel.required tooltipModel = viewModel.tooltip?.toVDSTooltipModel() + width = viewModel.width + transparentBackground = viewModel.transparentBackground uiTextViewDelegate = delegateObject?.uiTextViewDelegate observingTextViewDelegate = delegateObject?.observingTextFieldDelegate diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index fa941d10..cfcef654 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -20,7 +20,9 @@ class TextViewEntryFieldModel: TextEntryFieldModel { public var editable: Bool = true public var showsPlaceholder: Bool = false public var tooltip: TooltipModel? - + public var transparentBackground: Bool = false + public var width: CGFloat? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -29,6 +31,8 @@ class TextViewEntryFieldModel: TextEntryFieldModel { case accessibilityText case editable case tooltip + case transparentBackground + case width } //-------------------------------------------------- @@ -39,12 +43,11 @@ class TextViewEntryFieldModel: TextEntryFieldModel { try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - if let editable = try typeContainer.decodeIfPresent(Bool.self, forKey: .editable) { - self.editable = editable - } - + editable = try typeContainer.decodeIfPresent(Bool.self, forKey: .editable) ?? true accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) tooltip = try typeContainer.decodeIfPresent(TooltipModel.self, forKey: .tooltip) + transparentBackground = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparentBackground) ?? false + width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } public override func encode(to encoder: Encoder) throws { @@ -53,5 +56,7 @@ class TextViewEntryFieldModel: TextEntryFieldModel { try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encode(editable, forKey: .editable) try container.encodeIfPresent(tooltip, forKey: .tooltip) + try container.encode(transparentBackground, forKey: .transparentBackground) + try container.encodeIfPresent(width, forKey: .width) } } From 7ec685136b271e003d2362449540014fd005fa49 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 12:22:28 -0500 Subject: [PATCH 04/14] added more properties Signed-off-by: Matt Bruce --- .../FormFields/TextFields/TextViewEntryField.swift | 3 +++ .../TextFields/TextViewEntryFieldModel.swift | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 382c418c..9016ae5c 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -118,6 +118,9 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi open func viewModelDidUpdate() { text = viewModel.text + minHeight = viewModel.minHeight + maxLength = viewModel.maxLength + labelText = viewModel.title helperText = viewModel.feedback isEnabled = viewModel.enabled diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index cfcef654..fb1c2167 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -7,7 +7,7 @@ // import UIKit - +import VDS class TextViewEntryFieldModel: TextEntryFieldModel { //-------------------------------------------------- @@ -20,9 +20,11 @@ class TextViewEntryFieldModel: TextEntryFieldModel { public var editable: Bool = true public var showsPlaceholder: Bool = false public var tooltip: TooltipModel? + public var minHeight: VDS.TextArea.Height = .twoX + public var maxLength: Int? public var transparentBackground: Bool = false public var width: CGFloat? - + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -30,6 +32,8 @@ class TextViewEntryFieldModel: TextEntryFieldModel { private enum CodingKeys: String, CodingKey { case accessibilityText case editable + case minHeight + case maxLength case tooltip case transparentBackground case width @@ -44,6 +48,8 @@ class TextViewEntryFieldModel: TextEntryFieldModel { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) editable = try typeContainer.decodeIfPresent(Bool.self, forKey: .editable) ?? true + minHeight = try typeContainer.decodeIfPresent(VDS.TextArea.Height.self, forKey: .minHeight) ?? .twoX + maxLength = try typeContainer.decodeIfPresent(Int.self, forKey: .maxLength) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) tooltip = try typeContainer.decodeIfPresent(TooltipModel.self, forKey: .tooltip) transparentBackground = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparentBackground) ?? false @@ -55,6 +61,8 @@ class TextViewEntryFieldModel: TextEntryFieldModel { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encode(editable, forKey: .editable) + try container.encode(minHeight, forKey: .minHeight) + try container.encodeIfPresent(maxLength, forKey: .maxLength) try container.encodeIfPresent(tooltip, forKey: .tooltip) try container.encode(transparentBackground, forKey: .transparentBackground) try container.encodeIfPresent(width, forKey: .width) From 0abc903793562c411c8a9b649b51b13327d5e2d5 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 12:52:53 -0500 Subject: [PATCH 05/14] turn off required Signed-off-by: Matt Bruce --- .../Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 9016ae5c..6d5a45d4 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -81,6 +81,8 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi //-------------------------------------------------- override func setup() { super.setup() + //turn off internal required rule + useRequiredRule = false publisher(for: .valueChanged) .sink { [weak self] control in From fedf1760ec9921434c2f482e1b135799f9e7b6a2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Jul 2024 09:33:21 -0500 Subject: [PATCH 06/14] made public/open Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 67 +++++++++++++------ .../TextFields/TextViewEntryFieldModel.swift | 2 +- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 6d5a45d4..58c3cbc6 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -9,7 +9,7 @@ import UIKit import VDS -class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFieldDelegate { +open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFieldDelegate, ViewMaskingProtocol { //------------------------------------------------------ // MARK: - Properties //------------------------------------------------------ @@ -18,9 +18,9 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi open var additionalData: [AnyHashable : Any]? // Form Validation - var fieldKey: String? - var fieldValue: JSONValue? - var groupName: String? + open var fieldKey: String? + open var fieldValue: JSONValue? + open var groupName: String? //-------------------------------------------------- // MARK: - Stored Properties @@ -36,15 +36,12 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- - /// The text of this textView. - open override var text: String? { - didSet { - viewModel?.text = text - } + open var shouldMaskWhileRecording: Bool { + return viewModel.shouldMaskRecordedView ?? false } - + /// Placeholder access for the textView. - public var placeholder: String? { + open var placeholder: String? { get { viewModel?.placeholder } set { textView.placeholder = newValue ?? "" @@ -52,26 +49,34 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi } } - override var errorText: String? { + /// The text of this textView. + open override var text: String? { + didSet { + viewModel?.text = text + } + } + + open override var errorText: String? { get { viewModel.dynamicErrorMessage ?? viewModel.errorMessage } set {} } + //-------------------------------------------------- // MARK: - Delegate Properties //-------------------------------------------------- /// The delegate and block for validation. Validates if the text that the user has entered. - public weak var observingTextViewDelegate: ObservingTextFieldDelegate? + open weak var observingTextViewDelegate: ObservingTextFieldDelegate? /// If you're using a ViewController, you must set this to it - public weak var uiTextViewDelegate: UITextViewDelegate? { + open weak var uiTextViewDelegate: UITextViewDelegate? { get { textView.delegate } set { textView.delegate = newValue } } - @objc public func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) { + @objc open func setBothTextDelegates(to delegate: (UITextViewDelegate & ObservingTextFieldDelegate)?) { observingTextViewDelegate = delegate uiTextViewDelegate = delegate } @@ -79,7 +84,7 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi //-------------------------------------------------- // MARK: - Lifecycle //-------------------------------------------------- - override func setup() { + open override func setup() { super.setup() //turn off internal required rule useRequiredRule = false @@ -135,29 +140,33 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi uiTextViewDelegate = delegateObject?.uiTextViewDelegate observingTextViewDelegate = delegateObject?.observingTextFieldDelegate - if let accessibilityText = model.accessibilityText { + if let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText } - + containerView.accessibilityIdentifier = viewModel.accessibilityIdentifier textView.isEditable = viewModel.editable textView.textAlignment = viewModel.textAlignment - textView.accessibilityIdentifier = model.accessibilityIdentifier textView.placeholder = viewModel.placeholder ?? "" switch viewModel.type { case .secure, .password: textView.isSecureTextEntry = true - + textView.shouldMaskWhileRecording = true + case .numberSecure: textView.isSecureTextEntry = true textView.keyboardType = .numberPad - + textView.shouldMaskWhileRecording = true + case .number: textView.keyboardType = .numberPad case .email: textView.keyboardType = .emailAddress +// case .securityCode, .creditCard: +// textView.shouldMaskWhileRecording = true + default: break } @@ -218,3 +227,19 @@ class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingTextFi } } } + +internal struct ViewMasking { + static var shouldMaskWhileRecording: UInt8 = 0 +} + +extension VDS.TextView: ViewMaskingProtocol { + public var shouldMaskWhileRecording: Bool { + get { + return (objc_getAssociatedObject(self, &ViewMasking.shouldMaskWhileRecording) as? Bool) ?? false + } + set { + objc_setAssociatedObject(self, &ViewMasking.shouldMaskWhileRecording, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } +} + diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index fb1c2167..fc7dc46e 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -9,7 +9,7 @@ import UIKit import VDS -class TextViewEntryFieldModel: TextEntryFieldModel { +public class TextViewEntryFieldModel: TextEntryFieldModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- From c8d817948b76f3a32cf7d1149b4a481d2ab8fcd2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Jul 2024 14:57:56 -0500 Subject: [PATCH 07/14] bug in rule Signed-off-by: Matt Bruce --- MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift index da818e64..e4cfb2aa 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift @@ -49,7 +49,7 @@ public class RuleVDSModel: VDSRuleBase { public override func isValid(_ formField: FormFieldProtocol) -> Bool { let value = formField.formFieldValue() as? ValueType let valid = rule.isValid(value: value) - if let field = fields.first, valid { + if let field = fields.first, !valid { errorMessage = [field: rule.errorMessage] } else { errorMessage = nil From b5f61953df66ae2d698ef4b947c0a62a01900017 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Jul 2024 14:58:05 -0500 Subject: [PATCH 08/14] updated textViewEntry Signed-off-by: Matt Bruce --- .../Atoms/FormFields/TextFields/TextViewEntryField.swift | 3 +++ .../FormFields/TextFields/TextViewEntryFieldModel.swift | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 58c3cbc6..be7f3e54 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -176,6 +176,9 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT isEditting = true } + /// append any internal rules: + viewModel.rules = rules + /// No point in configuring if the TextView is Read-only. if textView.isEditable { FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index fc7dc46e..338f276c 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -9,7 +9,7 @@ import UIKit import VDS -public class TextViewEntryFieldModel: TextEntryFieldModel { +public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalValidatableProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -25,6 +25,11 @@ public class TextViewEntryFieldModel: TextEntryFieldModel { public var transparentBackground: Bool = false public var width: CGFloat? + //-------------------------------------------------- + // MARK: - FormFieldInternalValidatableProtocol + //-------------------------------------------------- + open var rules: [AnyRule]? + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- From 1a23c97a735c4361c354462c28c3680c069638b3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Jul 2024 15:03:46 -0500 Subject: [PATCH 09/14] updated FormField Signed-off-by: Matt Bruce --- MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift index 8b578fb3..8490cd69 100644 --- a/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift @@ -37,7 +37,7 @@ public extension FormFieldProtocol { } public protocol FormFieldInternalValidatableProtocol: FormFieldProtocol { - associatedtype ValueType + associatedtype ValueType = AnyHashable var rules: [AnyRule]? { get set } var internalRules: [RuleAnyModelProtocol]? { get } } From 5ebdbd24f1acfc6155328dec98f2e94e6aa8d053 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 08:15:17 -0500 Subject: [PATCH 10/14] rearranged methods for commenting Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index be7f3e54..a39e1c97 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -113,15 +113,32 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT } }.store(in: &subscribers) - - //String(format: MVMCoreUIUtility.hardcodedString(withKey: "textView_error_message") ?? "", textView.text ?? "", entryFieldModel?.errorMessage ?? "") } - //-------------------------------------------------- - // MARK: - MoleculeViewProtocol - //-------------------------------------------------- - open func updateView(_ size: CGFloat) {} + open override func updateView() { + super.updateView() + switch viewModel.type { + case .secure, .password: + textView.isSecureTextEntry = true + textView.shouldMaskWhileRecording = true + case .numberSecure: + textView.isSecureTextEntry = true + textView.keyboardType = .numberPad + textView.shouldMaskWhileRecording = true + + case .number: + textView.keyboardType = .numberPad + + case .email: + textView.keyboardType = .emailAddress +//uncomment out once inputField branch is merged and update this logic +// case .securityCode, .creditCard: +// textView.shouldMaskWhileRecording = true + + default: break + } + } open func viewModelDidUpdate() { text = viewModel.text @@ -147,29 +164,7 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT textView.isEditable = viewModel.editable textView.textAlignment = viewModel.textAlignment textView.placeholder = viewModel.placeholder ?? "" - - switch viewModel.type { - case .secure, .password: - textView.isSecureTextEntry = true - textView.shouldMaskWhileRecording = true - - case .numberSecure: - textView.isSecureTextEntry = true - textView.keyboardType = .numberPad - textView.shouldMaskWhileRecording = true - - case .number: - textView.keyboardType = .numberPad - - case .email: - textView.keyboardType = .emailAddress - -// case .securityCode, .creditCard: -// textView.shouldMaskWhileRecording = true - - default: break - } - + if (viewModel.selected ?? false) && !viewModel.wasInitiallySelected { viewModel.wasInitiallySelected = true @@ -229,6 +224,11 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT showError = false } } + + //-------------------------------------------------- + // MARK: - MoleculeViewProtocol + //-------------------------------------------------- + open func updateView(_ size: CGFloat) {} } internal struct ViewMasking { From 66464cebc3f6f5707d72f88e45835b4f2c41750b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 10:39:04 -0500 Subject: [PATCH 11/14] comment Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index a39e1c97..a76e9451 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -115,30 +115,6 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT }.store(in: &subscribers) } - open override func updateView() { - super.updateView() - switch viewModel.type { - case .secure, .password: - textView.isSecureTextEntry = true - textView.shouldMaskWhileRecording = true - - case .numberSecure: - textView.isSecureTextEntry = true - textView.keyboardType = .numberPad - textView.shouldMaskWhileRecording = true - - case .number: - textView.keyboardType = .numberPad - - case .email: - textView.keyboardType = .emailAddress -//uncomment out once inputField branch is merged and update this logic -// case .securityCode, .creditCard: -// textView.shouldMaskWhileRecording = true - - default: break - } - } open func viewModelDidUpdate() { text = viewModel.text @@ -171,6 +147,28 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT isEditting = true } + switch viewModel.type { + case .secure, .password: + textView.isSecureTextEntry = true + textView.shouldMaskWhileRecording = true + + case .numberSecure: + textView.isSecureTextEntry = true + textView.keyboardType = .numberPad + textView.shouldMaskWhileRecording = true + + case .number: + textView.keyboardType = .numberPad + + case .email: + textView.keyboardType = .emailAddress +//uncomment out once inputField branch is merged and update this logic +// case .securityCode, .creditCard: +// textView.shouldMaskWhileRecording = true + + default: break + } + /// append any internal rules: viewModel.rules = rules From bdaa4b5ea716889e3fca3a68c75826780503a4f9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 11:09:40 -0500 Subject: [PATCH 12/14] added extra check to ensure you aren't duplicating rules Signed-off-by: Matt Bruce --- MVMCoreUI/FormUIHelpers/FormValidator.swift | 6 ++++++ .../FormUIHelpers/Rules/Rules/RuleVDSModel.swift | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index b01c7ad4..e68b87a9 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -56,6 +56,12 @@ import MVMCore //find the group if let formGroup = formRules?.first(where: {$0.groupName == field.groupName}) { + var appendingRules = [RulesProtocol]() + internalRules.forEach { internalRule in + if !formGroup.rules.contains(where: { internalRule.type == $0.type && internalRule.fields == $0.fields } ) { + appendingRules.append(internalRule) + } + } formGroup.rules.append(contentsOf: internalRules) } else { //create the new group diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift index e4cfb2aa..5443cda4 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleVDSModel.swift @@ -9,12 +9,15 @@ import Foundation import VDS -open class VDSRuleBase: RuleAnyModelProtocol { +open class VDSRuleBase: RuleAnyModelProtocol { open var ruleId: String? + open var ruleType: String open var errorMessage: [String : String]? open var fields = [String]() - public init(){} - + public init(){ + ruleType = Self.identifier + } + public var type: String { ruleType } open func isValid(_ formField: any FormFieldProtocol) -> Bool { fatalError() } @@ -26,7 +29,7 @@ public class RuleVDSModel: VDSRuleBase { // MARK: - Properties //-------------------------------------------------- public var rule: AnyRule - + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -34,8 +37,8 @@ public class RuleVDSModel: VDSRuleBase { public init(field: String, rule: AnyRule) { self.rule = rule super.init() + self.ruleType = rule.ruleType self.fields = [field] - self.ruleId = "\(rule.self)-\(Int.random(in: 1...1000))" } required init(from decoder: any Decoder) throws { @@ -57,3 +60,4 @@ public class RuleVDSModel: VDSRuleBase { return valid } } + From c794add84d5679401a9a4cd116fabb538f8baab9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 13:44:03 -0500 Subject: [PATCH 13/14] removed duplicate struct for view masking protocol Signed-off-by: Matt Bruce --- .../TextFields/TextViewEntryField.swift | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index a76e9451..1cacbeae 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -148,25 +148,28 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT } switch viewModel.type { - case .secure, .password: + case .secure: textView.isSecureTextEntry = true textView.shouldMaskWhileRecording = true - + case .numberSecure: textView.isSecureTextEntry = true - textView.keyboardType = .numberPad textView.shouldMaskWhileRecording = true - - case .number: textView.keyboardType = .numberPad case .email: textView.keyboardType = .emailAddress -//uncomment out once inputField branch is merged and update this logic -// case .securityCode, .creditCard: -// textView.shouldMaskWhileRecording = true - - default: break + + case .securityCode, .creditCard, .password: + textView.shouldMaskWhileRecording = true + + default: + break; + } + + // Override the preset keyboard set in type. + if let keyboardType = viewModel.assignKeyboardType() { + textView.keyboardType = keyboardType } /// append any internal rules: @@ -229,10 +232,6 @@ open class TextViewEntryField: VDS.TextArea, VDSMoleculeViewProtocol, ObservingT open func updateView(_ size: CGFloat) {} } -internal struct ViewMasking { - static var shouldMaskWhileRecording: UInt8 = 0 -} - extension VDS.TextView: ViewMaskingProtocol { public var shouldMaskWhileRecording: Bool { get { From 3e702ec0f5526695ef70b875513999d60c25c4ed Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jul 2024 13:44:19 -0500 Subject: [PATCH 14/14] removed properties that were pushed down Signed-off-by: Matt Bruce --- .../ItemDropdownEntryFieldModel.swift | 12 ----------- .../TextFields/TextViewEntryFieldModel.swift | 21 ++----------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/ItemDropdownEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/ItemDropdownEntryFieldModel.swift index eb83a48a..f6f20b9f 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/ItemDropdownEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/Item Dropdown/ItemDropdownEntryFieldModel.swift @@ -18,9 +18,6 @@ import VDS public var selectedIndex: Int? public var showInlineLabel: Bool = false public var feedbackTextPlacement: VDS.EntryFieldBase.HelperTextPlacement = .bottom - public var tooltip: TooltipModel? - public var transparentBackground: Bool = false - public var width: CGFloat? public init(with options: [String], selectedIndex: Int? = nil) { self.options = options @@ -51,9 +48,6 @@ import VDS case action case showInlineLabel case feedbackTextPlacement - case tooltip - case transparentBackground - case width } //-------------------------------------------------- @@ -73,9 +67,6 @@ import VDS showInlineLabel = try typeContainer.decodeIfPresent(Bool.self, forKey: .showInlineLabel) ?? false feedbackTextPlacement = try typeContainer.decodeIfPresent(VDS.EntryFieldBase.HelperTextPlacement.self, forKey: .feedbackTextPlacement) ?? .bottom action = try typeContainer.decodeModelIfPresent(codingKey: .action) - tooltip = try typeContainer.decodeIfPresent(TooltipModel.self, forKey: .tooltip) - transparentBackground = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparentBackground) ?? false - width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } public override func encode(to encoder: Encoder) throws { @@ -86,8 +77,5 @@ import VDS try container.encode(showInlineLabel, forKey: .showInlineLabel) try container.encode(feedbackTextPlacement, forKey: .feedbackTextPlacement) try container.encodeModelIfPresent(action, forKey: .action) - try container.encodeIfPresent(tooltip, forKey: .tooltip) - try container.encode(transparentBackground, forKey: .transparentBackground) - try container.encodeIfPresent(width, forKey: .width) } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift index 338f276c..2f47b2a6 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryFieldModel.swift @@ -9,7 +9,7 @@ import UIKit import VDS -public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalValidatableProtocol { +public class TextViewEntryFieldModel: TextEntryFieldModel { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -19,17 +19,9 @@ public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalVali public var accessibilityText: String? public var editable: Bool = true public var showsPlaceholder: Bool = false - public var tooltip: TooltipModel? public var minHeight: VDS.TextArea.Height = .twoX public var maxLength: Int? - public var transparentBackground: Bool = false - public var width: CGFloat? - - //-------------------------------------------------- - // MARK: - FormFieldInternalValidatableProtocol - //-------------------------------------------------- - open var rules: [AnyRule]? - + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- @@ -39,9 +31,6 @@ public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalVali case editable case minHeight case maxLength - case tooltip - case transparentBackground - case width } //-------------------------------------------------- @@ -56,9 +45,6 @@ public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalVali minHeight = try typeContainer.decodeIfPresent(VDS.TextArea.Height.self, forKey: .minHeight) ?? .twoX maxLength = try typeContainer.decodeIfPresent(Int.self, forKey: .maxLength) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - tooltip = try typeContainer.decodeIfPresent(TooltipModel.self, forKey: .tooltip) - transparentBackground = try typeContainer.decodeIfPresent(Bool.self, forKey: .transparentBackground) ?? false - width = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .width) } public override func encode(to encoder: Encoder) throws { @@ -68,8 +54,5 @@ public class TextViewEntryFieldModel: TextEntryFieldModel, FormFieldInternalVali try container.encode(editable, forKey: .editable) try container.encode(minHeight, forKey: .minHeight) try container.encodeIfPresent(maxLength, forKey: .maxLength) - try container.encodeIfPresent(tooltip, forKey: .tooltip) - try container.encode(transparentBackground, forKey: .transparentBackground) - try container.encodeIfPresent(width, forKey: .width) } }