From 7357a199d2adcf8a4c2bc8e864c426badf9f6886 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 29 Jun 2024 09:48:18 -0500 Subject: [PATCH 1/9] fixes for VDS TileContainer update Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift | 3 +-- MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift index 8ed4fd55..7d0968df 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift @@ -137,8 +137,7 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{ extension Tilelet: MVMCoreUIViewConstrainingProtocol { - // Investigate later. - //public func horizontalAlignment() -> UIStackView.Alignment { .leading } + public func horizontalAlignment() -> UIStackView.Alignment { .leading } public func isClippable() -> Bool { return false diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift index cf5d382b..561d45b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift @@ -44,7 +44,9 @@ open class TileletModel: TileContainerBaseModel, Molec case directionalIcon case textWidth case textPercentage + case aspectRatio } + required public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString @@ -86,8 +88,10 @@ open class TileletModel: TileContainerBaseModel, Molec } else { subTitleColor = .primary } - + try super.init(from: decoder) + //Tilelet default is .none, not ratio1x1 (TileContainer) + aspectRatio = try container.decodeIfPresent(Tilelet.AspectRatio.self, forKey: .aspectRatio) ?? .none } public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.EyebrowModel? { From f3efb91fee0792860241f80e9acc21a595b5dfb6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 1 Jul 2024 11:12:57 -0500 Subject: [PATCH 2/9] remove horizontalAlignment Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift | 2 -- MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift | 3 --- 2 files changed, 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift b/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift index 6296f640..eb5020c1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift @@ -135,8 +135,6 @@ open class TileContainer: VDS.TileContainer, VDSMoleculeViewProtocol{ } extension TileContainer: MVMCoreUIViewConstrainingProtocol { - public func horizontalAlignment() -> UIStackView.Alignment { .leading } - public func isClippable() -> Bool { return false } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift index 7d0968df..bd2c0c73 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift @@ -136,9 +136,6 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{ } extension Tilelet: MVMCoreUIViewConstrainingProtocol { - - public func horizontalAlignment() -> UIStackView.Alignment { .leading } - public func isClippable() -> Bool { return false } From dee11d77329758178587f1740c44af625a0afaeb Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 1 Jul 2024 11:13:18 -0500 Subject: [PATCH 3/9] aspectRatio set to .none Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift index b8b64f3d..0e7c6032 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift @@ -67,7 +67,7 @@ open class TileContainerBaseModel, Molec case directionalIcon case textWidth case textPercentage - case aspectRatio } required public init(from decoder: Decoder) throws { @@ -90,8 +89,6 @@ open class TileletModel: TileContainerBaseModel, Molec } try super.init(from: decoder) - //Tilelet default is .none, not ratio1x1 (TileContainer) - aspectRatio = try container.decodeIfPresent(Tilelet.AspectRatio.self, forKey: .aspectRatio) ?? .none } public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.EyebrowModel? { From 9e712aa21333a76b382c29f10030cced19c00018 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 3 Jul 2024 09:33:57 -0400 Subject: [PATCH 4/9] Digital ACT191 defect CXTDT-578423 - Fix to missing navigation line when the subnav tabs are manually hidden. --- .../Managers/SubNav/SubNavManagerController.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index d5e0182e..7ac663d6 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -137,7 +137,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open override func pageShown() { // Currently not calling super until we can decouple page shown logics for managers. - hideNavigationBarLine(true) + hideNavigationBarLine(!tabs.isHidden) } open override func viewWillDisappear(_ animated: Bool) { @@ -148,7 +148,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - hideNavigationBarLine(true) + hideNavigationBarLine(!tabs.isHidden) } /// ensures margin for tabs are correct private func updateTabsMargin() { @@ -263,7 +263,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } tabs.selectIndex(index, animated: true) self.index = nil - hideNavigationBarLine(true) + hideNavigationBarLine(!tabs.isHidden) } public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { @@ -354,12 +354,12 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open func newDataReceived(in viewController: UIViewController) { manager?.newDataReceived?(in: viewController) - hideNavigationBarLine(true) + hideNavigationBarLine(!tabs.isHidden) } public func willDisplay(_ viewController: UIViewController) { manager?.willDisplay?(viewController) - hideNavigationBarLine(true) + hideNavigationBarLine(!tabs.isHidden) } public func displayedViewController(_ viewController: UIViewController) { From aa773dc8f544cd6502e532593443c96d940eb572 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 3 Jul 2024 11:42:08 -0500 Subject: [PATCH 5/9] added base FormField model class Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 4 + .../Atoms/FormFields/FormFieldModel.swift | 110 ++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 3433e17b..39bd239c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -581,6 +581,7 @@ EA41F4AC2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */; }; EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */; }; EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */; }; + EA5DBDAB2C35B6C500290DF8 /* FormFieldModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5DBDAA2C35B6C500290DF8 /* FormFieldModel.swift */; }; EA6642912BCDA97300D81DC4 /* TileContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6642902BCDA97300D81DC4 /* TileContainer.swift */; }; EA6642932BCDA97D00D81DC4 /* TileContainerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6642922BCDA97D00D81DC4 /* TileContainerModel.swift */; }; EA6E8B952B504A43000139B4 /* ButtonGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6E8B942B504A43000139B4 /* ButtonGroup.swift */; }; @@ -1201,6 +1202,7 @@ EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicRuleFormFieldEffectModel.swift; sourceTree = ""; }; EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButton.swift; sourceTree = ""; }; EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButtonModel.swift; sourceTree = ""; }; + EA5DBDAA2C35B6C500290DF8 /* FormFieldModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormFieldModel.swift; sourceTree = ""; }; EA6642902BCDA97300D81DC4 /* TileContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileContainer.swift; sourceTree = ""; }; EA6642922BCDA97D00D81DC4 /* TileContainerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileContainerModel.swift; sourceTree = ""; }; EA6E8B942B504A43000139B4 /* ButtonGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonGroup.swift; sourceTree = ""; }; @@ -2487,6 +2489,7 @@ D2BEFEF5248A954C00FAB3A9 /* FormFields */ = { isa = PBXGroup; children = ( + EA5DBDAA2C35B6C500290DF8 /* FormFieldModel.swift */, D2BEFEF6248A957A00FAB3A9 /* Tags */, D29DF22B21E6A0FA003B2FB9 /* TextFields */, ); @@ -3292,6 +3295,7 @@ D28BA7432480284E00B75CB8 /* TabBar.swift in Sources */, AA3561AE24C96B9000452EB1 /* ListRightVariableRightCaretAllTextAndLinks.swift in Sources */, AA26850C244840AE00CE34CC /* HeadersH2TinyButton.swift in Sources */, + EA5DBDAB2C35B6C500290DF8 /* FormFieldModel.swift in Sources */, 011D95AB2405C553000E3791 /* FormItemProtocol.swift in Sources */, D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */, 0A25209824645B76000FA9F6 /* TextViewEntryFieldModel.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift new file mode 100644 index 00000000..b15c23d6 --- /dev/null +++ b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift @@ -0,0 +1,110 @@ +// +// FormFieldModel.swift +// MVMCoreUI +// +// Created by Matt Bruce on 7/3/24. +// Copyright © 2024 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class FormFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, UIUpdatableModelProtocol { + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public class var identifier: String { "" } + public var id: String = UUID().uuidString + + public var backgroundColor: Color? + public var accessibilityIdentifier: String? + + public var enabled: Bool = true + public var required: Bool = true + public var readOnly: Bool = false + public var showError: Bool? + public var errorMessage: String? + + public var fieldKey: String? + public var groupName: String = FormValidator.defaultGroupName + public var baseValue: AnyHashable? + + public var isValid: Bool? = true { + didSet { updateUI?() } + } + + /// Temporary binding mechanism for the view to update on enable changes. + public var updateUI: ActionBlock? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init() {} + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case id + case moleculeName + case accessibilityIdentifier + case errorMessage + case enabled + case readOnly + case required + case fieldKey + case groupName + } + + //-------------------------------------------------- + // MARK: - Validation Methods + //-------------------------------------------------- + + open func formFieldValue() -> AnyHashable? { + fatalError("developer must implement") + } + + open func formFieldServerValue() -> AnyHashable? { + return formFieldValue() + } + + public func setValidity(_ valid: Bool, errorMessage: String?) { + + if let ruleErrorMessage = errorMessage, fieldKey != nil { + self.errorMessage = ruleErrorMessage + } + + self.isValid = valid + updateUI?() + } + + //-------------------------------------------------- + // MARK: - Codable + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString + accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) + errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) + enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true + required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) ?? true + readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false + fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(id, forKey: .id) + try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) + try container.encodeIfPresent(errorMessage, forKey: .errorMessage) + try container.encodeIfPresent(fieldKey, forKey: .fieldKey) + try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encode(readOnly, forKey: .readOnly) + try container.encode(enabled, forKey: .enabled) + try container.encode(required, forKey: .required) + } +} From 4eba94f413fdd93fc6e88b0a5ef988dd6216ab64 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 10 Jul 2024 12:05:07 -0500 Subject: [PATCH 6/9] refactored to use formfieldmodel Signed-off-by: Matt Bruce --- .../Atoms/FormFields/FormFieldModel.swift | 14 ++- .../TextFields/EntryFieldModel.swift | 98 +++---------------- 2 files changed, 24 insertions(+), 88 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift index b15c23d6..190d3a01 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift @@ -29,6 +29,13 @@ import Foundation public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? + public var dynamicErrorMessage: String? { + didSet { + isValid = dynamicErrorMessage?.isEmpty ?? true + updateUIDynamicError?() + } + } + public var isValid: Bool? = true { didSet { updateUI?() } } @@ -36,6 +43,9 @@ import Foundation /// Temporary binding mechanism for the view to update on enable changes. public var updateUI: ActionBlock? + // TODO: Remove once updateUI is fixed with isSelected + public var updateUIDynamicError: ActionBlock? + //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- @@ -63,7 +73,7 @@ import Foundation //-------------------------------------------------- open func formFieldValue() -> AnyHashable? { - fatalError("developer must implement") + fatalError("developer must implement") } open func formFieldServerValue() -> AnyHashable? { @@ -95,7 +105,7 @@ import Foundation groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName } - public func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 6f58cf64..1ef00628 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -9,79 +9,39 @@ import Foundation -@objcMembers open class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, UIUpdatableModelProtocol, ClearableModelProtocol { +@objcMembers open class EntryFieldModel: FormFieldModel, ClearableModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - public class var identifier: String { "" } - public var id: String = UUID().uuidString - - public var backgroundColor: Color? - public var accessibilityIdentifier: String? public var shouldClearText: Bool = false - public var dynamicErrorMessage: String? { - didSet { - isValid = dynamicErrorMessage?.isEmpty ?? true - updateUIDynamicError?() - } - } - public var errorMessage: String? public var errorTextColor: Color? - public var enabled: Bool = true - public var required: Bool = true - public var readOnly: Bool = false - public var showError: Bool? public var hideBorders = false public var locked: Bool? public var selected: Bool? - public var text: String? - public var fieldKey: String? - public var groupName: String = FormValidator.defaultGroupName - public var baseValue: AnyHashable? public var wasInitiallySelected: Bool = false + public var text: String? public var title: String? public var feedback: String? public var shouldMaskRecordedView: Bool? = true //used to drive the EntryFieldView UI - public var titleStateLabel: FormLabelModel - public var feedbackStateLabel: FormLabelModel - - public var isValid: Bool? = true { - didSet { updateUI?() } - } - - /// Temporary binding mechanism for the view to update on enable changes. - public var updateUI: ActionBlock? - - // TODO: Remove once updateUI is fixed with isSelected - public var updateUIDynamicError: ActionBlock? + public var titleStateLabel = FormLabelModel(text: "") + public var feedbackStateLabel = FormLabelModel(text: "") //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- private enum CodingKeys: String, CodingKey { - case id - case moleculeName case backgroundColor - case accessibilityIdentifier case title - case enabled - case readOnly case feedback - case errorMessage case errorTextColor case locked case selected - case showError case hideBorders case text - case fieldKey - case groupName - case required case shouldMaskRecordedView } @@ -92,7 +52,7 @@ import Foundation // MARK: - Validation Methods //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { + open override func formFieldValue() -> AnyHashable? { guard enabled else { return nil } if dynamicErrorMessage != nil { @@ -100,30 +60,15 @@ import Foundation } return text } - - open func formFieldServerValue() -> AnyHashable? { - return formFieldValue() - } - - public func setValidity(_ valid: Bool, errorMessage: String?) { - - if let ruleErrorMessage = errorMessage, fieldKey != nil { - self.errorMessage = ruleErrorMessage - } - - self.isValid = valid - updateUI?() - } //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- public init(with text: String) { + super.init() self.text = text baseValue = text - self.titleStateLabel = FormLabelModel(text: "") - self.feedbackStateLabel = FormLabelModel(text: "") setDefaults() } @@ -131,7 +76,7 @@ import Foundation // MARK: - Initializers //-------------------------------------------------- public func clear() { - self.text = "" + text = "" } //-------------------------------------------------- @@ -139,54 +84,35 @@ import Foundation //-------------------------------------------------- required public init(from decoder: Decoder) throws { + try super.init(from: decoder) let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback) - errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) errorTextColor = try typeContainer.decodeIfPresent(Color.self, forKey: .errorTextColor) - enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true - required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) ?? true - readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false locked = try typeContainer.decodeIfPresent(Bool.self, forKey: .locked) selected = try typeContainer.decodeIfPresent(Bool.self, forKey: .selected) text = try typeContainer.decodeIfPresent(String.self, forKey: .text) hideBorders = try typeContainer.decodeIfPresent(Bool.self, forKey: .hideBorders) ?? false baseValue = text - fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) shouldMaskRecordedView = try typeContainer.decodeIfPresent(Bool.self, forKey: .shouldMaskRecordedView) ?? shouldMaskRecordedView - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName - } - self.titleStateLabel = FormLabelModel(text: title ?? "") - self.feedbackStateLabel = FormLabelModel(model: LabelModel(text: feedback ?? "", + titleStateLabel = FormLabelModel(text: title ?? "") + feedbackStateLabel = FormLabelModel(model: LabelModel(text: feedback ?? "", fontStyle: FormLabelModel.defaultFontStyle, textColor: Color(uiColor: .mvmCoolGray6))) setDefaults() } - public func encode(to encoder: Encoder) throws { + open override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(id, forKey: .id) - try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) - try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(feedback, forKey: .feedback) try container.encodeIfPresent(text, forKey: .text) try container.encodeIfPresent(locked, forKey: .locked) - try container.encodeIfPresent(showError, forKey: .showError) try container.encodeIfPresent(selected, forKey: .selected) try container.encodeIfPresent(errorTextColor, forKey: .errorTextColor) - try container.encodeIfPresent(errorMessage, forKey: .errorMessage) - try container.encodeIfPresent(fieldKey, forKey: .fieldKey) - try container.encodeIfPresent(groupName, forKey: .groupName) - - try container.encode(readOnly, forKey: .readOnly) - try container.encode(enabled, forKey: .enabled) - try container.encode(required, forKey: .required) try container.encode(hideBorders, forKey: .hideBorders) try container.encode(shouldMaskRecordedView, forKey: .shouldMaskRecordedView) } From 797d044913630835064d203cec7d0946ab9c78f4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 10 Jul 2024 12:54:50 -0500 Subject: [PATCH 7/9] added inverted Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift index 190d3a01..ca6f1e52 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/FormFieldModel.swift @@ -7,6 +7,7 @@ // import Foundation +import VDS @objcMembers open class FormFieldModel: MoleculeModelProtocol, FormFieldProtocol, FormRuleWatcherFieldProtocol, UIUpdatableModelProtocol { @@ -28,6 +29,9 @@ import Foundation public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? + + public var inverted: Bool = false + public var surface: Surface { inverted ? .dark : .light } public var dynamicErrorMessage: String? { didSet { @@ -66,6 +70,7 @@ import Foundation case required case fieldKey case groupName + case inverted } //-------------------------------------------------- @@ -103,6 +108,10 @@ import Foundation readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName + + if let inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) { + self.inverted = inverted + } } open func encode(to encoder: Encoder) throws { @@ -116,5 +125,6 @@ import Foundation try container.encode(readOnly, forKey: .readOnly) try container.encode(enabled, forKey: .enabled) try container.encode(required, forKey: .required) + try container.encode(inverted, forKey: .inverted) } } From 0ab9ad37a8b36925f004647ef5f008c9a6c06cf6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 10 Jul 2024 14:36:47 -0500 Subject: [PATCH 8/9] added extension Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift index 2b12cead..974cca8c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift @@ -96,3 +96,17 @@ open class TooltipModel: MoleculeModelProtocol { } } + +extension TooltipModel { + public func toVDSTooltipModel() -> Tooltip.TooltipModel { + var moleculeView: MoleculeViewProtocol? + if let molecule, let view = ModelRegistry.createMolecule(molecule) { + moleculeView = view + } + return .init(closeButtonText: closeButtonText, + title: title, + content: content, + contentView: moleculeView + ) + } +} From cadded321776a8b1265558cbbef8797e13cee132 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Jul 2024 12:09:52 -0500 Subject: [PATCH 9/9] added more enums Signed-off-by: Matt Bruce --- .../Atomic/Extensions/VDS-Enums+Codable.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index f4eb5500..8f565216 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -25,21 +25,31 @@ extension VDS.ButtonIcon.Size: Codable {} extension VDS.ButtonIcon.BadgeIndicatorModel.ExpandDirection: Codable {} extension VDS.ButtonIcon.SurfaceType: Codable {} extension VDS.ButtonGroup.Alignment: Codable {} +extension VDS.CarouselScrollbar.Layout: Codable {} +extension VDS.DatePicker.DateFormat: Codable {} +extension VDS.EntryFieldBase.HelperTextPlacement: Codable {} extension VDS.Icon.Name: Codable {} extension VDS.Icon.Size: Codable {} +extension VDS.InputField.CreditCardType: Codable {} +extension VDS.InputField.DateFormat: Codable {} +extension VDS.InputField.FieldType: Codable {} +extension VDS.Line.Style: Codable {} +extension VDS.Line.Orientation: Codable {} extension VDS.Tabs.Orientation: Codable {} extension VDS.Tabs.IndicatorPosition: Codable {} extension VDS.Tabs.Overflow: Codable {} extension VDS.Tabs.Size: Codable {} +extension VDS.TextArea.Height: Codable {} extension VDS.TextLink.Size: Codable {} extension VDS.TextLinkCaret.IconPosition: Codable {} extension VDS.TileContainerBase.AspectRatio: Codable {} extension VDS.Tilelet.Padding: Codable {} extension VDS.TitleLockup.TextAlignment: Codable {} +extension VDS.Toggle.TextSize: Codable {} +extension VDS.Toggle.TextPosition: Codable {} +extension VDS.Toggle.TextWeight: Codable {} extension VDS.Tooltip.FillColor: Codable {} extension VDS.Tooltip.Size: Codable {} -extension VDS.Line.Style: Codable {} -extension VDS.Line.Orientation: Codable {} extension VDS.Use: Codable {} extension VDS.Button.Size: RawRepresentableCodable {