From bb2fbe4bdd2bcc09cd5a0208d3a69116212d6e33 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 27 Sep 2024 12:13:09 -0400 Subject: [PATCH 01/13] Added missing accessibility identifier --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroup.swift | 5 ++++- .../Atomic/Atoms/Buttons/ButtonGroupModel.swift | 5 +++++ .../Atomic/Atoms/Buttons/ImageButtonModel.swift | 6 +++++- .../Atomic/Atoms/FormFields/Tags/TagModel.swift | 8 ++++++-- .../Atomic/Atoms/FormFields/Tags/TagsModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift | 4 +++- MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift | 3 +++ .../Atomic/Atoms/Selectors/RadioButton.swift | 4 +++- .../Atomic/Atoms/Selectors/RadioButtons.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift | 8 ++++++-- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/BadgeIndicator.swift | 3 +++ .../Atomic/Atoms/Views/BadgeIndicatorModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 7 +++++-- MVMCoreUI/Atomic/Atoms/Views/ButtonIcon.swift | 3 +++ .../Atomic/Atoms/Views/ButtonIconModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/CalendarView.swift | 3 +++ .../Atomic/Atoms/Views/CalendarViewModel.swift | 8 +++++++- MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift | 6 +++++- .../CarouselIndicatorModel.swift | 4 ++++ MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift | 3 +++ .../Atomic/Atoms/Views/CheckboxLabelModel.swift | 3 ++- .../Atoms/Views/CircularProgressBarModel.swift | 8 ++++++-- MVMCoreUI/Atomic/Atoms/Views/Icon.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/IconModel.swift | 2 ++ MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift | 2 ++ MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 3 +++ .../Atomic/Atoms/Views/Label/LabelModel.swift | 6 +++++- .../Atomic/Atoms/Views/LeftRightLabelModel.swift | 3 ++- MVMCoreUI/Atomic/Atoms/Views/Line.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/LineModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift | 3 +++ .../Atomic/Atoms/Views/LoadingSpinnerModel.swift | 8 ++++++-- .../Atomic/Atoms/Views/MultiProgressModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/Pagination.swift | 3 +++ .../Atomic/Atoms/Views/PaginationModel.swift | 11 ++++++++++- MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift | 3 +++ .../Atomic/Atoms/Views/ProgressBarModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/StarModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift | 4 +++- .../Atomic/Atoms/Views/TileContainerModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/Tooltip.swift | 3 +++ MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift | 15 ++++++++++----- .../Atomic/Atoms/Views/Video/VideoModel.swift | 4 ++++ MVMCoreUI/Atomic/Atoms/Views/WebViewModel.swift | 6 +++++- MVMCoreUI/Atomic/Atoms/Views/WheelModel.swift | 8 ++++++-- .../Molecules/Breadcrumbs/Breadcrumbs.swift | 3 +++ .../Molecules/Breadcrumbs/BreadcrumbsModel.swift | 13 +++++++++++++ .../LockUps/LockUpsPlanNamesModel.swift | 6 +++++- .../LockUps/LockupsPlanSMLXLModel.swift | 6 +++++- .../DesignedComponents/LockUps/TitleLockup.swift | 3 +++ .../LockUps/TitleLockupModel.swift | 6 +++++- .../Doughnut/DoughnutChartItemModel.swift | 5 ++++- .../Molecules/Doughnut/DoughnutChartModel.swift | 3 ++- .../ImageHeadlineBodyModel.swift | 3 ++- .../RadioButtonLabel.swift | 4 ++++ .../RadioButtonLabelModel.swift | 5 +++-- .../HorizontalCombinationViews/TabBar.swift | 7 +++++++ .../HorizontalCombinationViews/TabBarModel.swift | 10 +++++++++- .../HorizontalCombinationViews/Tabs.swift | 3 +++ .../HorizontalCombinationViews/TabsModel.swift | 6 +++++- .../TwoButtonView.swift | 4 ++++ .../TwoButtonViewModel.swift | 6 +++++- .../HorizontalCombinationViews/TwoLinkView.swift | 4 ++++ .../TwoLinkViewModel.swift | 6 +++++- .../ActionDetailWithImageModel.swift | 3 ++- .../LeftRightViews/CornerLabelsModel.swift | 4 ++++ .../HeadlineBodyLinkToggleModel.swift | 1 + .../ToggleMolecules/HeadlineBodyToggleModel.swift | 1 + .../ToggleMolecules/LabelToggleModel.swift | 6 +++++- .../NavigationBar/NavigationItemModel.swift | 6 +++++- .../NotificationXButtonModel.swift | 6 +++++- .../EyebrowHeadlineBodyLinkModel.swift | 4 ++++ .../HeadlineBodyButtonModel.swift | 6 +++++- .../HeadlineBodyLinkModel.swift | 3 ++- .../HeadlineBodyModel.swift | 4 ++++ .../StringAndMoleculeModel.swift | 6 +++++- .../ThreeHeadlineBodyLinkModel.swift | 6 +++++- .../Atomic/Organisms/Carousel/CarouselModel.swift | 6 +++++- MVMCoreUI/BaseClasses/BarButtonItem.swift | 3 +++ MVMCoreUI/BaseClasses/CollectionViewCell.swift | 4 ++++ MVMCoreUI/BaseClasses/TableViewCell.swift | 4 ++++ MVMCoreUI/Containers/Views/ContainerModel.swift | 7 ++++++- 88 files changed, 376 insertions(+), 60 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroup.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroup.swift index d71d40be..f1416afa 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroup.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroup.swift @@ -38,7 +38,10 @@ open class ButtonGroup: VDS.ButtonGroup, VDSMoleculeViewProtocol { return PillButton.estimatedHeight(with: buttonModel, delegateObject) } - public func viewModelDidUpdate() { + public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface isEnabled = viewModel.enabled alignment = viewModel.alignment diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroupModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroupModel.swift index 028c9f22..c0e26b31 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroupModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonGroupModel.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore import VDS public class ButtonGroupModel: ParentMoleculeModelProtocol { @@ -17,6 +18,7 @@ public class ButtonGroupModel: ParentMoleculeModelProtocol { public static var identifier: String = "buttonGroup" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var children: [MoleculeModelProtocol] { buttons } @@ -38,6 +40,7 @@ public class ButtonGroupModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case buttons case alignment @@ -56,6 +59,7 @@ public class ButtonGroupModel: ParentMoleculeModelProtocol { 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) surface = try typeContainer.decodeIfPresent(Surface.self, forKey: .surface) ?? .light enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true buttons = try typeContainer.decodeModels(codingKey: .buttons) @@ -70,6 +74,7 @@ public class ButtonGroupModel: ParentMoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(surface, forKey: .surface) try container.encode(enabled, forKey: .enabled) try container.encodeModels(buttons, forKey: .buttons) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift index 134a42b9..f0b7986a 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ImageButtonModel.swift @@ -15,7 +15,8 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro public static var identifier: String = "imageButton" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var image: ImageViewModel? @@ -45,6 +46,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case image case backgroundColor case accessibilityText @@ -64,6 +66,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) image = try typeContainer.decodeIfPresent(ImageViewModel.self, forKey: .image) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) @@ -91,6 +94,7 @@ open class ImageButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGro var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(image, forKey: .image) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift index 40cb98b7..efc381ed 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagModel.swift @@ -12,13 +12,15 @@ import MVMCore @objcMembers public class TagModel: MoleculeModelProtocol { public static var identifier: String = "tag" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var label: LabelModel public var action: ActionModelProtocol? public var backgroundColor: Color? - + private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case label case action @@ -42,6 +44,7 @@ import MVMCore 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) label = try typeContainer.decode(LabelModel.self, forKey: .label) action = try typeContainer.decodeModelIfPresent(codingKey: .action) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -50,6 +53,7 @@ import MVMCore public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(label, forKey: .label) try container.encodeModelIfPresent(action, forKey: .action) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift index 22ce1d9a..5d141401 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/TagsModel.swift @@ -12,12 +12,14 @@ import MVMCore @objcMembers public class TagsModel: MoleculeModelProtocol { public static var identifier: String = "tags" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var tags: [TagModel] private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case tags @@ -34,6 +36,7 @@ import MVMCore 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) tags = try typeContainer.decode([TagModel].self, forKey: .tags) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) } @@ -41,6 +44,7 @@ import MVMCore public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tags, forKey: .tags) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index 728a295b..db369ff6 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -123,6 +123,9 @@ import VDS public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } //forms FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) groupName = viewModel.groupName diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift index 91040f77..b7a55cff 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkboxes.swift @@ -28,6 +28,9 @@ open class Checkboxes: VDS.CheckboxGroup, VDSMoleculeViewProtocol { // MARK: - MoleculeViewProtocol public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface showError = viewModel.showError isEnabled = viewModel.enabled && !viewModel.readOnly diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift index 815f2959..14539d95 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift @@ -28,7 +28,9 @@ import VDS //-------------------------------------------------- public func viewModelDidUpdate() { - + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } text = viewModel.text subText = viewModel.subText subTextRight = viewModel.subTextRight diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift index 88a0fb34..1c2d6a18 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBoxes.swift @@ -28,6 +28,9 @@ open class RadioBoxes: VDS.RadioBoxGroup, VDSMoleculeViewProtocol { // MARK: - MoleculeViewProtocol public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } boxes = viewModel.boxes surface = viewModel.surface selectorModels = viewModel.boxes.convertToVDSRadioBoxModel(surface: surface) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 6cfbdb5b..12c65b03 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -93,7 +93,9 @@ import VDS } open func viewModelDidUpdate() { - + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } //events viewModel.updateUI = { MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift index bc41f8bb..48c2ab39 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButtons.swift @@ -28,6 +28,9 @@ open class RadioButtons: VDS.RadioButtonGroup, VDSMoleculeViewProtocol { // MARK: - MoleculeViewProtocol public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } showError = viewModel.showError isEnabled = viewModel.isEnabled surface = viewModel.surface diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index feaf3399..bdabfab3 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -103,6 +103,9 @@ public typealias ActionBlockConfirmation = () -> (Bool) } public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) isOn = viewModel.selected diff --git a/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift index 4970ce24..c9bde7a5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ArrowModel.swift @@ -19,7 +19,8 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol { } public var moleculeName: String? public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var disabledColor: Color = Color(uiColor: .mvmCoolGray3) public var color: Color = Color(uiColor: .mvmBlack) @@ -59,6 +60,7 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case disabledColor @@ -79,7 +81,8 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol { 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) + if let disabledColor = try typeContainer.decodeIfPresent(Color.self, forKey: .disabledColor) { self.disabledColor = disabledColor } @@ -116,6 +119,7 @@ open class ArrowModel: MoleculeModelProtocol, EnableableModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(disabledColor, forKey: .disabledColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 5e8c2e25..81203d47 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -27,6 +27,9 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } text = viewModel.text maxWidth = viewModel.maxWidth numberOfLines = viewModel.numberOfLines diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicator.swift index 3eb78919..035dac50 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicator.swift @@ -25,6 +25,9 @@ open class BadgeIndicator: VDS.BadgeIndicator, VDSMoleculeViewProtocol { //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface number = viewModel.number fillColor = viewModel.fillColor diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift index bdc724b6..980c38a5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeIndicatorModel.swift @@ -17,7 +17,8 @@ open class BadgeIndicatorModel: MoleculeModelProtocol { public static var identifier: String { "badgeIndicator" } public var id: String = UUID().uuidString public var backgroundColor: Color? - + public var accessibilityIdentifier: String? + //-------------------------------------------------- // MARK: - VDS Properties //-------------------------------------------------- @@ -43,6 +44,7 @@ open class BadgeIndicatorModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case inverted case accessibilityText case number @@ -67,6 +69,7 @@ open class BadgeIndicatorModel: MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) self.init() id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString + accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) number = try container.decodeIfPresent(Int.self, forKey: .number) @@ -91,6 +94,7 @@ open class BadgeIndicatorModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(inverted, forKey: .inverted) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(number, forKey: .number) try container.encodeIfPresent(fillColor, forKey: .fillColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index e04cc47e..34ed444c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -16,7 +16,8 @@ open class BadgeModel: MoleculeModelProtocol { public static var identifier: String = "badge" public var id: String = UUID().uuidString public var backgroundColor: Color? - + public var accessibilityIdentifier: String? + //-------------------------------------------------- // MARK: - VDS Properties //-------------------------------------------------- @@ -28,13 +29,14 @@ open class BadgeModel: MoleculeModelProtocol { public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case id, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth + case id, accessibilityIdentifier, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth } required public convenience init(from decoder: Decoder) throws { self.init() let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString + accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) text = try container.decode(String.self, forKey: .text) accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red @@ -48,6 +50,7 @@ open class BadgeModel: MoleculeModelProtocol { try container.encode(id, forKey: .id) try container.encode(text, forKey: .text) try container.encode(accessibilityText, forKey: .accessibilityText) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(fillColor, forKey: .fillColor) try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ButtonIcon.swift b/MVMCoreUI/Atomic/Atoms/Views/ButtonIcon.swift index 50802ff9..8a7c691e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ButtonIcon.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ButtonIcon.swift @@ -25,6 +25,9 @@ open class ButtonIcon: VDS.ButtonIcon, VDSMoleculeViewProtocol { //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface onClick = { [weak self] control in diff --git a/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift index aefa9dfe..daca2fab 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ButtonIconModel.swift @@ -16,7 +16,8 @@ open class ButtonIconModel: ButtonModelProtocol, MoleculeModelProtocol { public static var identifier: String = "buttonIcon" public var id: String = UUID().uuidString public var backgroundColor: Color? - + public var accessibilityIdentifier: String? + //-------------------------------------------------- // MARK: - VDS Properties //-------------------------------------------------- @@ -77,6 +78,7 @@ open class ButtonIconModel: ButtonModelProtocol, MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case inverted case accessibilityText case action @@ -105,6 +107,7 @@ open class ButtonIconModel: ButtonModelProtocol, MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) action = try container.decodeModel(codingKey: .action) id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString + accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) badgeIndicator = try container.decodeIfPresent(BadgeIndicatorModel.self, forKey: .badgeIndicator) @@ -128,6 +131,7 @@ open class ButtonIconModel: ButtonModelProtocol, MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(badgeIndicator, forKey: .badgeIndicator) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CalendarView.swift b/MVMCoreUI/Atomic/Atoms/Views/CalendarView.swift index 9a0850e8..cdb6f953 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CalendarView.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CalendarView.swift @@ -22,6 +22,9 @@ open class CalendarView: VDS.CalendarBase, VDSMoleculeViewProtocol { //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } if let _selectedDate = viewModel.selectedDate { selectedDate = _selectedDate } diff --git a/MVMCoreUI/Atomic/Atoms/Views/CalendarViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CalendarViewModel.swift index 3abb4cc5..e861e669 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CalendarViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CalendarViewModel.swift @@ -16,6 +16,7 @@ open class CalendarViewModel: MoleculeModelProtocol { public static var identifier: String = "calendar" public var id: String = UUID().uuidString public var backgroundColor: Color? + public var accessibilityIdentifier: String? public var dateFormatter: DateFormatter = { let formatter = DateFormatter() @@ -51,6 +52,8 @@ open class CalendarViewModel: MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier + case moleculeName case inverted case dateFormat case hideContainerBorder @@ -76,7 +79,8 @@ open class CalendarViewModel: MoleculeModelProtocol { let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString inverted = try container.decodeIfPresent(Bool.self, forKey: .inverted) ?? false - + accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) + hideContainerBorder = try container.decodeIfPresent(Bool.self, forKey: .hideContainerBorder) hideCurrentDateIndicator = try container.decodeIfPresent(Bool.self, forKey: .hideCurrentDateIndicator) @@ -111,7 +115,9 @@ open class CalendarViewModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(inverted, forKey: .inverted) try container.encode(dateFormat, forKey: .dateFormat) try container.encode(hideContainerBorder, forKey: .hideContainerBorder) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift index 380328d5..bd2dc02c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CaretViewModel.swift @@ -16,6 +16,7 @@ import MVMCore public static var identifier: String = "caretView" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var strokeColor: Color = Color(uiColor: .mvmBlack) public var strokeColor_inverted: Color = Color(uiColor: .mvmWhite) @@ -30,6 +31,7 @@ import MVMCore private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case strokeColor @@ -54,7 +56,8 @@ import MVMCore 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) + if let strokeColor = try typeContainer.decodeIfPresent(Color.self, forKey: .strokeColor) { self.strokeColor = strokeColor } @@ -84,6 +87,7 @@ import MVMCore var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(strokeColor, forKey: .strokeColor) try container.encode(strokeColor_inverted, forKey: .strokeColor_inverted) try container.encode(inverted, forKey: .inverted) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index d7381d64..9973332c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -19,6 +19,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro } public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var moleculeName: String? @@ -48,6 +49,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case currentIndex @@ -70,6 +72,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro 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) moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -118,6 +121,7 @@ open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelPro 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(backgroundColor, forKey: .backgroundColor) try container.encode(currentIndex, forKey: .currentIndex) try container.encode(alwaysSendAction, forKey: .alwaysSendAction) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift index 1892c3fb..80b39269 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift @@ -31,6 +31,9 @@ import VDS // MARK: - Atomic //-------------------------------------------------- open func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface updateCheckbox() diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index fca5cf31..b4d972fa 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -14,7 +14,8 @@ import VDS open class var identifier: String { "checkboxLabel" } public var moleculeName: String = CheckboxLabelModel.identifier @DecodableDefault.UUIDString public var id: String - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var checkbox: CheckboxModel public var label: LabelModel? diff --git a/MVMCoreUI/Atomic/Atoms/Views/CircularProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CircularProgressBarModel.swift index b2f37e68..307b3bcd 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CircularProgressBarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CircularProgressBarModel.swift @@ -14,7 +14,8 @@ public class CircularProgressBarModel: GraphSizeBase, MoleculeModelProtocol { public static var identifier: String = "circularProgress" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var percent: Int = 0 public var diameter: CGFloat? = 64 public var lineWidth: CGFloat? = 4 @@ -31,6 +32,7 @@ public class CircularProgressBarModel: GraphSizeBase, MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case percent case size @@ -48,7 +50,8 @@ public class CircularProgressBarModel: GraphSizeBase, MoleculeModelProtocol { super.init() 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) + percent = try typeContainer.decode(Int.self, forKey: .percent) if let size = try typeContainer.decodeIfPresent(GraphSize.self, forKey: .size) { @@ -89,6 +92,7 @@ public class CircularProgressBarModel: GraphSizeBase, MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(percent, forKey: .percent) try container.encodeIfPresent(size, forKey: .size) try container.encodeIfPresent(diameter, forKey: .diameter) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Icon.swift b/MVMCoreUI/Atomic/Atoms/Views/Icon.swift index 1ed0c376..8074178a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Icon.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Icon.swift @@ -31,6 +31,9 @@ open class Icon: VDS.Icon, VDSMoleculeViewProtocol{ // MARK: - Public //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface color = viewModel.color.uiColor size = viewModel.size diff --git a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift index ee45a6df..dd5d4f98 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift @@ -21,6 +21,8 @@ open class IconModel: MoleculeModelProtocol { public var backgroundColor: Color? + public var accessibilityIdentifier: String? + /// A representation that will be used to render the icon with corresponding name. public var name: Icon.Name diff --git a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift index 3a827cbe..e39c5b37 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ImageViewModel.swift @@ -18,6 +18,7 @@ public var backgroundColor: Color? public var moleculeName: String = ImageViewModel.identifier public var image: String + public var accessibilityIdentifier: String? public var accessibilityText: String? public var fallbackImage: String? public var imageFormat: String? @@ -47,6 +48,7 @@ private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case image diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 82928c0f..a8247d25 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -182,6 +182,9 @@ public typealias ActionBlock = () -> () } public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } shouldMaskWhileRecording = viewModel.shouldMaskRecordedView ?? false text = viewModel.text hero = viewModel.hero diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 20e9d501..1dc84098 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -14,7 +14,8 @@ import VDS open class var identifier: String { "label" } public var id: String - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var text: String public var accessibilityText: String? @@ -38,6 +39,7 @@ import VDS private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case text case accessibilityText @@ -88,6 +90,7 @@ import VDS 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) text = try typeContainer.decode(String.self, forKey: .text) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) @@ -115,6 +118,7 @@ import VDS var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(text, forKey: .text) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(textColor, forKey: .textColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift index 2f442dc8..0005203a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LeftRightLabelModel.swift @@ -16,7 +16,8 @@ import UIKit public static var identifier: String = "leftRightLabelView" public var moleculeName: String = LeftRightLabelModel.identifier @DecodableDefault.UUIDString public var id: String - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var leftText: LabelModel public var rightText: LabelModel? diff --git a/MVMCoreUI/Atomic/Atoms/Views/Line.swift b/MVMCoreUI/Atomic/Atoms/Views/Line.swift index 20be7af0..b3f05b8c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Line.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Line.swift @@ -93,6 +93,9 @@ import VDS // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- open func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } surface = viewModel.surface style = VDS.Line.Style(rawValue: viewModel.type.rawValue) ?? .primary orientation = viewModel.orientation diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 4bdcefe0..7253a5b4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -55,6 +55,7 @@ public class LineModel: MoleculeModelProtocol, Invertable { public static var identifier: String = "line" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var type: Style = .secondary @@ -83,6 +84,7 @@ public class LineModel: MoleculeModelProtocol, Invertable { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case type case frequency @@ -99,7 +101,8 @@ public class LineModel: MoleculeModelProtocol, Invertable { 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) + if let type = try typeContainer.decodeIfPresent(Style.self, forKey: .type) { self.type = type } @@ -124,6 +127,7 @@ public class LineModel: MoleculeModelProtocol, Invertable { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(type, forKey: .type) try container.encode(inverted, forKey: .inverted) try container.encodeIfPresent(frequency, forKey: .frequency) diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift index 5b1fbe73..0f109715 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinner.swift @@ -22,6 +22,9 @@ open class LoadingSpinner: VDS.Loader, VDSMoleculeViewProtocol { // MARK: - Public Functions //-------------------------------------------------- open func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } size = Int(viewModel.diameter) surface = viewModel.surface } diff --git a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift index 6959bc8f..2b3e4ffc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LoadingSpinnerModel.swift @@ -16,7 +16,8 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { //-------------------------------------------------- public static var identifier: String = "loadingSpinner" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var inverted: Bool = false public var diameter: CGFloat = 40 @@ -27,6 +28,7 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case strokeColor case diameter @@ -47,7 +49,8 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { 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) + if let diameter = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .diameter) { self.diameter = diameter } @@ -65,6 +68,7 @@ open class LoadingSpinnerModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(diameter, forKey: .diameter) try container.encodeIfPresent(inverted, forKey: .inverted) } diff --git a/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift b/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift index d664afa6..e3a656e4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/MultiProgressModel.swift @@ -22,7 +22,8 @@ import Foundation public static var identifier: String = "multiProgressBar" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var progressList: [SingleProgressBarModel] public var backgroundColor: Color? public var thickness: CGFloat? @@ -30,6 +31,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case progressList case thickness @@ -44,6 +46,7 @@ import Foundation 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) progressList = try typeContainer.decode([SingleProgressBarModel].self, forKey: .progressList) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) thickness = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .thickness) @@ -54,6 +57,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(progressList, forKey: .progressList) try container.encodeIfPresent(thickness, forKey: .thickness) try container.encodeIfPresent(roundedCorners, forKey: .roundedCorners) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift index 7cb8c0c2..de6869eb 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Pagination.swift @@ -39,6 +39,9 @@ import VDS } open func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } isEnabled = viewModel.enabled surface = viewModel.surface total = viewModel.totalPages diff --git a/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift b/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift index 7027c7bb..3171d9b5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/PaginationModel.swift @@ -19,7 +19,8 @@ open class PaginationModel: MoleculeModelProtocol { open var moleculeName: String { Self.identifier } open var backgroundColor: Color? open var id: String = UUID().uuidString - + open var accessibilityIdentifier: String? + open var totalPages: Int = 0 open var selectedPage: Int = 0 open var enabled: Bool = true @@ -31,6 +32,9 @@ open class PaginationModel: MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { + case id + case moleculeName + case accessibilityIdentifier case totalPages case selectedPage case enabled @@ -43,6 +47,8 @@ open class PaginationModel: MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) + id = try container.decode(String.self, forKey: .id) + accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) totalPages = try container.decode(Int.self, forKey: .totalPages) selectedPage = try container.decodeIfPresent(Int.self, forKey: .selectedPage) ?? 0 enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled) ?? false @@ -51,6 +57,9 @@ open class PaginationModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(id, forKey: .id) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(totalPages, forKey: .totalPages) try container.encode(selectedPage, forKey: .selectedPage) try container.encode(enabled, forKey: .enabled) diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift index c806ce4b..4d60fbb9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBar.swift @@ -75,6 +75,9 @@ import Foundation guard let progressBarModel = model as? ProgressBarModel else { return } self.progressBarModel = progressBarModel + if let accessibilityIdentifier = model.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } thickness = progressBarModel.thickness ?? 8 progress = Float((progressBarModel.percent) / 100.0) progressTintColor = progressBarModel.color.uiColor diff --git a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift index 5e6a42c1..00e796b9 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/ProgressBarModel.swift @@ -11,7 +11,8 @@ import Foundation @objcMembers open class ProgressBarModel: MoleculeModelProtocol { open class var identifier: String { "progressBar" } public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + @Percent public var percent: CGFloat public var color: Color = Color(uiColor: .mfCerulean()) public var backgroundColor: Color? = Color(uiColor: .mfLightSilver()) @@ -20,6 +21,7 @@ import Foundation private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case roundedCorners case thickness @@ -35,6 +37,7 @@ import Foundation 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) percent = try typeContainer.decode(CGFloat.self, forKey: .percent) if let color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) { self.color = color @@ -50,6 +53,7 @@ import Foundation var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(percent, forKey: .percent) try container.encode(color, forKey: .color) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift b/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift index 7b427cde..9368c2f1 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/StarModel.swift @@ -14,7 +14,8 @@ open class StarModel: MoleculeModelProtocol { //-------------------------------------------------- public static var identifier: String = "star" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? @Percent public var percent: CGFloat = 0 public var borderColor: Color? @@ -26,6 +27,7 @@ open class StarModel: MoleculeModelProtocol { //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case percent @@ -47,6 +49,7 @@ open class StarModel: MoleculeModelProtocol { 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) if let percent = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .percent) { self.percent = percent } @@ -63,6 +66,7 @@ open class StarModel: MoleculeModelProtocol { try container.encode(id, forKey: .id) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(percent, forKey: .percent) try container.encodeIfPresent(borderColor, forKey: .borderColor) try container.encodeIfPresent(fillColor, forKey: .fillColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift b/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift index 10e6400a..560274b7 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/StarsModel.swift @@ -14,7 +14,8 @@ import MVMCore //-------------------------------------------------- public static var identifier: String = "stars" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var starBackgroundColor: Color? public var stars: [StarModel] @@ -28,6 +29,7 @@ import MVMCore //-------------------------------------------------- private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case moleculeName case backgroundColor case starBackgroundColor @@ -53,6 +55,7 @@ import MVMCore 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) stars = try typeContainer.decode([StarModel].self, forKey: .stars) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) starBackgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .starBackgroundColor) @@ -70,6 +73,7 @@ import MVMCore var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(stars, forKey: .stars) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(starBackgroundColor, forKey: .starBackgroundColor) diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift b/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift index 106af38c..3cc0020e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileContainer.swift @@ -40,7 +40,9 @@ open class TileContainer: VDS.TileContainer, VDSMoleculeViewProtocol{ // MARK: - Public //-------------------------------------------------- public func viewModelDidUpdate() { - + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } if let moleculeModel = viewModel.molecule { if let molecule, moleculeModel.moleculeName == molecule.model?.moleculeName { diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift index 0e7c6032..f729c36a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileContainerModel.swift @@ -70,8 +70,10 @@ open class TileContainerBaseModel Bool { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 9221eb44..6f04263e 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -63,6 +63,9 @@ import VDS //------------------------------------------------- open func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } borderLine = viewModel.borderLine if let minWidth = viewModel.minWidth { self.minWidth = minWidth diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 072913f6..1bd0a498 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -13,7 +13,8 @@ open class TabsModel: MoleculeModelProtocol { public static var identifier: String = "tabs" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + open var tabs: [TabItemModel] open var style: Surface? @@ -33,6 +34,7 @@ open class TabsModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case tabs case backgroundColor case selectedIndex @@ -53,6 +55,7 @@ open class TabsModel: MoleculeModelProtocol { 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) tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs) style = try typeContainer.decodeIfPresent(Surface.self, forKey: .style) @@ -94,6 +97,7 @@ open class TabsModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(tabs, forKey: .tabs) try container.encode(selectedIndex, forKey: .selectedIndex) try container.encode(fillContainer, forKey: .fillContainer) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift index f57c5801..236adcba 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonView.swift @@ -64,6 +64,10 @@ import VDS // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } + var buttons = [PillButton]() if let secondaryModel = viewModel.secondaryButton { secondaryButton.set(with: secondaryModel, delegateObject, additionalData) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift index 5f7b423c..c9e658fb 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoButtonViewModel.swift @@ -16,6 +16,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { public static var identifier: String = "twoButtonView" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var primaryButton: ButtonModel? public var secondaryButton: ButtonModel? @@ -39,6 +40,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case primaryButton case secondaryButton @@ -62,7 +64,8 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { 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) + //set context value for 'primary' style to be set for the primaryButton in case the //property is not returned in the JSON and once decoded, this value is removed from the context try decoder.setContext(value: Use.primary, for: "style") { @@ -81,6 +84,7 @@ public class TwoButtonViewModel: ParentMoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(primaryButton, forKey: .primaryButton) try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift index a9890618..25b8c43f 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkView.swift @@ -105,6 +105,10 @@ import VDS // MARK: - VDSMoleculeViewProtocol //-------------------------------------------------- public func viewModelDidUpdate() { + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } + buttons.removeAll() if let model = viewModel.leftLink { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift index 893d2753..11a70e82 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TwoLinkViewModel.swift @@ -11,7 +11,8 @@ import Foundation public class TwoLinkViewModel: ParentMoleculeModelProtocol { public static var identifier: String = "twoLinkView" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var rightLink: LinkModel? public var leftLink: LinkModel? @@ -21,6 +22,7 @@ public class TwoLinkViewModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case rightLink case leftLink @@ -34,6 +36,7 @@ public class TwoLinkViewModel: ParentMoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) rightLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .rightLink) leftLink = try typeContainer.decodeIfPresent(LinkModel.self, forKey: .leftLink) @@ -43,6 +46,7 @@ public class TwoLinkViewModel: ParentMoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(rightLink, forKey: .rightLink) try container.encodeIfPresent(leftLink, forKey: .leftLink) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift index 2e7b7500..90b840a4 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ActionDetailWithImageModel.swift @@ -12,7 +12,8 @@ public class ActionDetailWithImageModel: MoleculeModelProtocol { public static var identifier: String = "actionDetailWithImage" public var moleculeName: String = ActionDetailWithImageModel.identifier @DecodableDefault.UUIDString public var id: String - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var headlineBodyButton: HeadlineBodyButtonModel public var image: ImageViewModel diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift index ad45061e..5ccd99e7 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/CornerLabelsModel.swift @@ -12,6 +12,7 @@ import MVMCore public class CornerLabelsModel: ParentMoleculeModelProtocol { public static var identifier: String = "cornerLabels" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var topLeftLabel: LabelModel? public var topRightLabel: LabelModel? @@ -41,6 +42,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case backgroundColor case topLeftLabel case topRightLabel @@ -53,6 +55,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) molecule = try typeContainer.decodeModelIfPresent(codingKey: .molecule) topLeftLabel = try typeContainer.decodeMoleculeIfPresent(codingKey: .topLeftLabel) @@ -64,6 +67,7 @@ public class CornerLabelsModel: ParentMoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModelIfPresent(molecule, forKey: .molecule) try container.encodeModelIfPresent(topLeftLabel, forKey: .topLeftLabel) diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift index 84a03adf..dcf97828 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyLinkToggleModel.swift @@ -11,6 +11,7 @@ public class HeadlineBodyLinkToggleModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLinkToggle" public var moleculeName: String = HeadlineBodyLinkToggleModel.identifier @DecodableDefault.UUIDString public var id: String + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var headlineBodyLink: HeadlineBodyLinkModel public var toggle: ToggleModel diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift index 1555c957..78d16e46 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/HeadlineBodyToggleModel.swift @@ -13,6 +13,7 @@ open class HeadlineBodyToggleModel: MoleculeModelProtocol, ParentMoleculeModelPr public static var identifier: String = "headlineBodyToggle" public var moleculeName: String = HeadlineBodyToggleModel.identifier @DecodableDefault.UUIDString public var id: String + public var accessibilityIdentifier: String? open var backgroundColor: Color? open var headlineBody: HeadlineBodyModel open var toggle: ToggleModel diff --git a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index fe8cc16a..8ac46345 100644 --- a/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Atomic/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -13,7 +13,8 @@ public class LabelToggleModel: MoleculeModelProtocol { public static var identifier: String = "labelToggle" public var moleculeName: String = LabelToggleModel.identifier public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel @@ -26,6 +27,7 @@ public class LabelToggleModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case label case toggle @@ -34,6 +36,7 @@ public class LabelToggleModel: MoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey:.backgroundColor) label = try typeContainer.decode(LabelModel.self, forKey:.label) toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle) @@ -43,6 +46,7 @@ public class LabelToggleModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(label, forKey: .label) try container.encode(toggle, forKey: .toggle) diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index f38e3d10..a22ddd98 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -20,7 +20,8 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc open class var identifier: String { "navigationBar" } public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + open var title: String? open var hidden: Bool? open var hidesSystemBackButton: Bool? @@ -85,6 +86,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case title case hidden case backgroundColor @@ -107,6 +109,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc 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) title = try typeContainer.decodeIfPresent(String.self, forKey: .title) hidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .hidden) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) @@ -126,6 +129,7 @@ open class NavigationItemModel: NavigationItemModelProtocol, MoleculeModelProtoc var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(title, forKey: .title) try container.encodeIfPresent(hidden, forKey: .hidden) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift index 0206b79d..d639d060 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift @@ -13,13 +13,15 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco public static var identifier: String = "notificationXButton" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var action: ActionModelProtocol = ActionNoopModel() private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case action } @@ -30,6 +32,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco public required 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) if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) { self.action = action } @@ -39,6 +42,7 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeModel(action, forKey: .action) } } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift index 14008a5d..f1845eaf 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLinkModel.swift @@ -14,6 +14,7 @@ public class EyebrowHeadlineBodyLinkModel: ParentMoleculeModelProtocol { public static var identifier: String = "eyebrowHeadlineBodyLink" public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var moleculeName: String = EyebrowHeadlineBodyLinkModel.identifier public var backgroundColor: Color? public var eyebrow: LabelModel? @@ -70,6 +71,7 @@ public class EyebrowHeadlineBodyLinkModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case eyebrow case headline @@ -84,6 +86,7 @@ public class EyebrowHeadlineBodyLinkModel: ParentMoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) eyebrow = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .eyebrow) headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline) @@ -100,6 +103,7 @@ public class EyebrowHeadlineBodyLinkModel: ParentMoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(eyebrow, forKey: .eyebrow) try container.encodeModelIfPresent(headline, forKey: .headline) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift index 347277fd..5fa3eea7 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyButtonModel.swift @@ -15,7 +15,8 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyButton" public var moleculeName: String = HeadlineBodyButtonModel.identifier public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var headlineBody: HeadlineBodyModel @@ -49,6 +50,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case headlineBody case button @@ -62,6 +64,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody) button = try typeContainer.decode(ButtonModel.self, forKey: .button) @@ -73,6 +76,7 @@ public class HeadlineBodyButtonModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(headlineBody, forKey: .headlineBody) try container.encode(button, forKey: .button) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift index 6c2113bf..a1e035e8 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyLinkModel.swift @@ -17,7 +17,8 @@ public class HeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "headlineBodyLink" public var moleculeName: String = HeadlineBodyLinkModel.identifier @DecodableDefault.UUIDString public var id: String - + public var accessibilityIdentifier: String? + public var headlineBody: HeadlineBodyModel public var link: LinkModel public var backgroundColor: Color? diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index 80893c44..4363e975 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -15,6 +15,7 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol { public static var identifier: String = "headlineBody" public var moleculeName: String = HeadlineBodyModel.identifier public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var headline: LabelModel? public var body: LabelModel? public var style: Style? @@ -69,6 +70,7 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case headline case body case style @@ -78,6 +80,7 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol { 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) headline = try typeContainer.decodeMoleculeIfPresent(codingKey: .headline) body = try typeContainer.decodeMoleculeIfPresent(codingKey: .body) style = try typeContainer.decodeIfPresent(Style.self, forKey: .style) @@ -88,6 +91,7 @@ open class HeadlineBodyModel: ParentMoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(headline, forKey: .headline) try container.encodeIfPresent(body, forKey: .body) try container.encodeIfPresent(style, forKey: .style) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift index 8ffc24e4..0d14f583 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeModel.swift @@ -14,7 +14,8 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public static var identifier: String = "stringAndMoleculeModel" public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var string: String public var molecule: MoleculeModelProtocol @@ -37,6 +38,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case string case molecule @@ -50,6 +52,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public required 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) string = try typeContainer.decode(String.self, forKey: .string) molecule = try typeContainer.decodeModel(codingKey: .molecule) @@ -59,6 +62,7 @@ public class StringAndMoleculeModel: MoleculeModelProtocol { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(string, forKey: .string) try container.encodeModel(molecule, forKey: .molecule) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLinkModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLinkModel.swift index 8f413429..bd7e119a 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/ThreeHeadlineBodyLinkModel.swift @@ -17,7 +17,8 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol { public static var identifier: String = "threeHeadlineBodyLink" public var moleculeName: String = ThreeHeadlineBodyLinkModel.identifier public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var headline1: LabelModel @@ -45,6 +46,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol { private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case headline1 case headline2 @@ -60,6 +62,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol { 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) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) headline1 = try typeContainer.decode(LabelModel.self, forKey: .headline1) headline2 = try typeContainer.decode(LabelModel.self, forKey: .headline2) @@ -72,6 +75,7 @@ public class ThreeHeadlineBodyLinkModel: MoleculeModelProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encode(headline1, forKey: .headline1) try container.encode(headline2, forKey: .headline2) diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift index 58ee28e6..e57634b2 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/CarouselModel.swift @@ -19,7 +19,8 @@ import UIKit } public var id: String = UUID().uuidString - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var molecules: [MoleculeModelProtocol & CarouselItemModelProtocol] public var index: Int = 0 @@ -85,6 +86,7 @@ import UIKit private enum CodingKeys: String, CodingKey { case id case moleculeName + case accessibilityIdentifier case backgroundColor case molecules case index @@ -115,6 +117,7 @@ import UIKit 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) molecules = try typeContainer.decodeModels(codingKey: .molecules) index = try typeContainer.decodeIfPresent(Int.self, forKey: .index) ?? 0 selectable = try typeContainer.decodeIfPresent(Bool.self, forKey: .selectable) ?? false @@ -153,6 +156,7 @@ import UIKit var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeModels(molecules, forKey: .molecules) try container.encodeIfPresent(spacing, forKey: .spacing) diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index d759b147..e5fdeca6 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -30,6 +30,9 @@ public typealias BarButtonAction = (BarButtonItem) -> () open func set(with model: MoleculeModelProtocol & NavigationButtonModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.model = model + if let accessibilityIdentifier = model.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } buttonDelegate = delegateObject?.buttonDelegate actionDelegate?.buttonAction = { sender in Task(priority: .userInitiated) { diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index c57afd41..0507bd5c 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -79,6 +79,10 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo self.backgroundColor = backgroundColor.uiColor } + if let accessibilityIdentifier = (model as? MoleculeModelProtocol)?.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } + // align if needed. if let model = model as? ContainerModelProtocol { containerHelper.set(with: model, for: molecule as? MVMCoreUIViewConstrainingProtocol) diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index f5bb8bf1..e18c3497 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -140,6 +140,10 @@ import UIKit self.listItemModel = model styleLine(with: model.style) + + if let accessibilityIdentifier = model.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } // Add the caret if there is an action and it's not declared hidden. if !customAccessoryView { diff --git a/MVMCoreUI/Containers/Views/ContainerModel.swift b/MVMCoreUI/Containers/Views/ContainerModel.swift index b9549bf8..fca6834e 100644 --- a/MVMCoreUI/Containers/Views/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/ContainerModel.swift @@ -6,6 +6,7 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // +import MVMCore open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProtocol { @@ -14,6 +15,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto //-------------------------------------------------- public var id: String = UUID().uuidString + public var accessibilityIdentifier: String? public var hasStableId = false public var horizontalAlignment: UIStackView.Alignment? @@ -34,6 +36,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto private enum CodingKeys: String, CodingKey { case id + case accessibilityIdentifier case horizontalAlignment case useHorizontalMargins case leftPadding @@ -78,7 +81,8 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - + accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) + if let id = try typeContainer.decodeIfPresent(String.self, forKey: .id) { self.id = id hasStableId = true @@ -103,6 +107,7 @@ open class ContainerModel: ContainerModelProtocol, Codable, ModelComparisonProto open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment) try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment) try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins) From 65bf81830e3cdbd012c8c57179128874f0d00381 Mon Sep 17 00:00:00 2001 From: "Hedden, Kyle Matthew" Date: Tue, 1 Oct 2024 20:24:32 -0400 Subject: [PATCH 02/13] Digital ACT192 story ONEAPP-11359: Lift the minimum supported iOS version number to 15. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- .../Atomic/Organisms/Carousel/Carousel.swift | 20 +++++++++---------- .../Templates/MoleculeListTemplate.swift | 11 ++++------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index f3ba25ce..4d2b2bad 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3625,7 +3625,7 @@ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3655,7 +3655,7 @@ FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../SharedFrameworks"; INFOPLIST_FILE = MVMCoreUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 14.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift index f84bdfc5..6476e8fa 100644 --- a/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift +++ b/MVMCoreUI/Atomic/Organisms/Carousel/Carousel.swift @@ -176,17 +176,15 @@ open class Carousel: View { MVMCoreLoggingHandler.shared()?.handleDebugMessage("[\(Self.self)] [\(ObjectIdentifier(self).hashValue)]\noriginal model: \(originalModel?.debugDescription ?? "none")\nnew model: \(model)") - if #available(iOS 15.0, *) { - if hasSameCellRegistration(with: carouselModel, delegateObject: delegateObject) { - // Prevents a carousel reset while still updating the cell backing data through reconfigureItems. - MVMCoreLoggingHandler.shared()?.handleDebugMessage("[\(Self.self)] Model is visually equivalent. Skipping rebuild...") - prepareMolecules(with: carouselModel) - FormValidator.setupValidation(for: carouselModel, delegate: delegateObject?.formHolderDelegate) - updateModelIndex() // Ensure the new model indexing matches the old. - pagingView?.currentIndex = pageIndex // Trigger a paging view render. - collectionView.reconfigureItems(at: collectionView.indexPathsForVisibleItems) - return - } + guard !hasSameCellRegistration(with: carouselModel, delegateObject: delegateObject) else { + // Prevents a carousel reset while still updating the cell backing data through reconfigureItems. + MVMCoreLoggingHandler.shared()?.handleDebugMessage("[\(Self.self)] Model is visually equivalent. Skipping rebuild...") + prepareMolecules(with: carouselModel) + FormValidator.setupValidation(for: carouselModel, delegate: delegateObject?.formHolderDelegate) + updateModelIndex() // Ensure the new model indexing matches the old. + pagingView?.currentIndex = pageIndex // Trigger a paging view render. + collectionView.reconfigureItems(at: collectionView.indexPathsForVisibleItems) + return } MVMCoreLoggingHandler.shared()?.handleDebugMessage("[\(Self.self)] Model is new. Rebuilding carousel.") diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index 3e78dc86..2b78b7cd 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -272,13 +272,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol debugLog("Refreshing rows \(indexPaths.map { $0.row })") - if #available(iOS 15.0, *) { - // All rows should have been layed out already on the first newDataBuildScreen reload with the getMoleculeInfoList call. Therefore, we can be safe to assume the top level cell configuration will not be modified and only the child content will be updated allowing us to leverage this more efficient method. - tableView.reconfigureRows(at: indexPaths) - } else { - // A full reload can cause a flicker / animation. Better to avoid with above reconfigure method. - tableView.reloadRows(at: indexPaths, with: .automatic) - } + // All rows should have been layed out already on the first newDataBuildScreen reload with the getMoleculeInfoList call. Therefore, we can be safe to assume the top level cell configuration will not be modified and only the child content will be updated allowing us to leverage this more efficient method. + // A full reload can cause a flicker / animation when fetching an entirely new cell. Better to avoid with reconfigure method. + tableView.reconfigureRows(at: indexPaths) + if let selectedIndex = selectedIndex { tableView.selectRow(at: selectedIndex, animated: false, scrollPosition: .none) } From 69d057c45a4182abaf57dc82781e039c5113e51b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 4 Oct 2024 12:03:18 -0500 Subject: [PATCH 03/13] added in model conversion to textStyle Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Extensions/VDS-LabelAttributeModel.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-LabelAttributeModel.swift b/MVMCoreUI/Atomic/Extensions/VDS-LabelAttributeModel.swift index 6b31175c..12f7f9cd 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-LabelAttributeModel.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-LabelAttributeModel.swift @@ -69,6 +69,8 @@ extension LabelAttributeFontModel: VDSLabelAttributeConvertable { var textStyle: TextStyle? if let found = style?.vdsTextStyle() { textStyle = found + } else if let name, let size, let font = UIFont(name: name, size: size) { + textStyle = TextStyle.convert(font: font) } else if let name, let found = TextStyle(rawValue: name) { textStyle = found } From c737ca134479f3e47ebd335eed951507fea47e02 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Oct 2024 09:08:05 -0500 Subject: [PATCH 04/13] added textColor Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 1 + MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 81203d47..9957101f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -31,6 +31,7 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { self.accessibilityIdentifier = accessibilityIdentifier } text = viewModel.text + textColor = viewModel.textColor maxWidth = viewModel.maxWidth numberOfLines = viewModel.numberOfLines fillColor = viewModel.fillColor diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 34ed444c..52e43e9a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -22,6 +22,7 @@ open class BadgeModel: MoleculeModelProtocol { // MARK: - VDS Properties //-------------------------------------------------- public var text: String = "" + public var textColor: Badge.TextColor? = nil public var accessibilityText: String? public var maxWidth: CGFloat? public var numberOfLines: Int = 1 @@ -29,7 +30,7 @@ open class BadgeModel: MoleculeModelProtocol { public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case id, accessibilityIdentifier, text, accessibilityText, fillColor, surface, numberOfLines, maxWidth + case id, accessibilityIdentifier, text, textColor, accessibilityText, fillColor, surface, numberOfLines, maxWidth } required public convenience init(from decoder: Decoder) throws { @@ -38,6 +39,9 @@ open class BadgeModel: MoleculeModelProtocol { id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) text = try container.decode(String.self, forKey: .text) + if let foundTextColor = try container.decodeIfPresent(Color.self, forKey: .textColor) { + textColor = .custom(foundTextColor.uiColor) + } accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light @@ -55,6 +59,12 @@ open class BadgeModel: MoleculeModelProtocol { try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) try container.encodeIfPresent(maxWidth, forKey: .maxWidth) + switch textColor { + case .custom(let color): + try container.encode(Color(uiColor: color), forKey: .textColor) + default: + break + } } public func isEqual(to model: any ModelComparisonProtocol) -> Bool { From 3b2dc2d447df877707739ded63d8a877eb534f94 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Oct 2024 09:08:20 -0500 Subject: [PATCH 05/13] updated to use badgeModel Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift | 2 +- MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift index 151d8567..439f295e 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Tilelet.swift @@ -51,7 +51,7 @@ open class Tilelet: VDS.Tilelet, VDSMoleculeViewProtocol{ eyebrowModel = viewModel.eyebrowModel(delegateObject: delegateObject, additionalData: additionalData) titleModel = viewModel.titleModel(delegateObject: delegateObject, additionalData: additionalData) subTitleModel = viewModel.subTitleModel(delegateObject: delegateObject, additionalData: additionalData) - badgeModel = viewModel.badge + badgeModel = viewModel.badgeModel() descriptiveIconModel = viewModel.descriptiveIcon directionalIconModel = viewModel.directionalIcon //setup action diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift index f7b69c47..6802e5a7 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift @@ -18,7 +18,7 @@ open class TileletModel: TileContainerBaseModel, Molec public var id: String = UUID().uuidString public var backgroundColor: Color? - public var badge: Tilelet.BadgeModel? + public var badge: BadgeModel? public var eyebrow: LabelModel? public var eyebrowColor: TitleLockup.TextColor = .primary public var title: LabelModel? @@ -49,7 +49,7 @@ open class TileletModel: TileContainerBaseModel, Molec 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 - badge = try container.decodeIfPresent(Tilelet.BadgeModel.self, forKey: .badge) + badge = try container.decodeIfPresent(BadgeModel.self, forKey: .badge) eyebrow = try container.decodeIfPresent(LabelModel.self, forKey: .eyebrow) title = try container.decodeIfPresent(LabelModel.self, forKey: .title) subTitle = try container.decodeIfPresent(LabelModel.self, forKey: .subTitle) @@ -91,6 +91,17 @@ open class TileletModel: TileContainerBaseModel, Molec try super.init(from: decoder) } + public func badgeModel() -> Tilelet.BadgeModel? { + guard let badge else { return nil } + return .init(text: badge.text, + textColor: badge.textColor, + fillColor: badge.fillColor, + surface: badge.surface, + numberOfLines: badge.numberOfLines, + maxWidth: badge.maxWidth + ) + } + public func eyebrowModel(delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Tilelet.EyebrowModel? { guard let eyebrow else { return nil } let attrs = eyebrow.attributes?.toVDSLabelAttributeModel(delegateObject: delegateObject, additionalData: additionalData) From 54b50bffd3d01a36a8375fa2cc7de6f534c0c3d0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Oct 2024 09:08:30 -0500 Subject: [PATCH 06/13] added fillColor codable Signed-off-by: Matt Bruce --- .../Atomic/Extensions/VDS-Enums+Codable.swift | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 6c6ae71f..ab286f35 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -16,7 +16,6 @@ import MVMCore //-------------------------------------------------- extension VDS.Surface: Codable {} -extension VDS.Badge.FillColor: Codable {} extension VDS.BadgeIndicator.FillColor: Codable {} extension VDS.BadgeIndicator.Kind: Codable {} extension VDS.BadgeIndicator.MaximumDigits: Codable {} @@ -294,6 +293,54 @@ extension VDS.TitleLockup.TextColor: Codable { } } +extension VDS.Badge.FillColor: Codable { + enum CodingKeys: String, CodingKey { + case type + case color + } + + enum CustomColorType: String, Codable { + case red, yellow, green, orange, blue, black, white + case custom + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(CustomColorType.self, forKey: .type) + + switch type { + case .red: + self = .red + case .yellow: + self = .yellow + case .green: + self = .green + case .orange: + self = .orange + case .blue: + self = .blue + case .black: + self = .black + case .white: + self = .white + case .custom: + let color = try container.decode(Color.self, forKey: .color) + self = .custom(color.uiColor) + } + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + switch self { + case .custom(let color): + try container.encode(CustomColorType.custom.rawValue, forKey: .type) + try container.encode(Color(uiColor: color), forKey: .color) + default: + try container.encode("\(self)", forKey: .type) + } + } +} + extension VDS.TitleLockup.TitleTextColor: Codable { enum CodingKeys: String, CodingKey { From bf2a3e7e5b29367708ae1f4303004619192166ee Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Oct 2024 09:10:04 -0500 Subject: [PATCH 07/13] removed isDark Signed-off-by: Matt Bruce --- MVMCoreUI/Categories/UIColor+MFConvenience.h | 4 ++-- MVMCoreUI/Categories/UIColor+MFConvenience.m | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 10e9433d..503efac8 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -183,8 +183,8 @@ // Returns a gradient lighter color; + (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color; -// Returns if the color is dark or not -- (BOOL)isDark; +//// Returns if the color is dark or not +//- (BOOL)isDark; #pragma mark - Hex String diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index d10672a8..65ddc44b 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -387,11 +387,11 @@ return [UIColor whiteColor]; } -- (BOOL)isDark { - CGFloat greyScale = 0; - [self getWhite:&greyScale alpha:nil]; - return greyScale < 0.5; -} +//- (BOOL)isDark { +// CGFloat greyScale = 0; +// [self getWhite:&greyScale alpha:nil]; +// return greyScale < 0.5; +//} #pragma mark - Hex String From f66dc668180113d51fd7889d6315f4bfd5aad844 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 8 Oct 2024 09:18:23 -0500 Subject: [PATCH 08/13] undid comment Signed-off-by: Matt Bruce --- MVMCoreUI/Categories/UIColor+MFConvenience.h | 4 ++-- MVMCoreUI/Categories/UIColor+MFConvenience.m | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.h b/MVMCoreUI/Categories/UIColor+MFConvenience.h index 503efac8..10e9433d 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.h +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.h @@ -183,8 +183,8 @@ // Returns a gradient lighter color; + (nonnull UIColor *)mfGradientColor:(nullable UIColor *)color; -//// Returns if the color is dark or not -//- (BOOL)isDark; +// Returns if the color is dark or not +- (BOOL)isDark; #pragma mark - Hex String diff --git a/MVMCoreUI/Categories/UIColor+MFConvenience.m b/MVMCoreUI/Categories/UIColor+MFConvenience.m index 65ddc44b..d10672a8 100644 --- a/MVMCoreUI/Categories/UIColor+MFConvenience.m +++ b/MVMCoreUI/Categories/UIColor+MFConvenience.m @@ -387,11 +387,11 @@ return [UIColor whiteColor]; } -//- (BOOL)isDark { -// CGFloat greyScale = 0; -// [self getWhite:&greyScale alpha:nil]; -// return greyScale < 0.5; -//} +- (BOOL)isDark { + CGFloat greyScale = 0; + [self getWhite:&greyScale alpha:nil]; + return greyScale < 0.5; +} #pragma mark - Hex String From 3a06f7b43e44df772f50f9ddbfcb6881ea512e5f Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 14 Oct 2024 11:03:24 -0400 Subject: [PATCH 09/13] Digital ACT191 defect CXTDT-626309 - Update to default header h2 padding --- .../Headers/H2/HeadersH2ButtonsModel.swift | 6 ------ .../Headers/H2/HeadersH2CaretLinkModel.swift | 6 ------ .../Headers/H2/HeadersH2LinkModel.swift | 8 +------- .../Headers/H2/HeadersH2NoButtonsBodyTextModel.swift | 6 ------ .../Headers/H2/HeadersH2PricingTwoRowsModel.swift | 6 ------ .../Headers/H2/HeadersH2TinyButtonModel.swift | 6 ------ 6 files changed, 1 insertion(+), 37 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift index 6d9bef90..accd139e 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift @@ -47,12 +47,6 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo //-------------------------------------------------- public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } if titleLockup.title.fontStyle == nil { titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift index 1cb89f84..6675abcf 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift @@ -42,12 +42,6 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent // MARK: - Methods //-------------------------------------------------- public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } if titleLockup.title.fontStyle == nil { titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift index 8ff7df5e..1a95bf73 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift @@ -46,13 +46,7 @@ public class HeadersH2LinkModel: HeaderModel, ParentMoleculeModelProtocol { //-------------------------------------------------- public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } - if titleLockup.title.fontStyle == nil { + if titleLockup.title.fontStyle == nil { titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge } if titleLockup.subTitle?.fontStyle == nil { diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift index e18aafe6..95414411 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift @@ -36,12 +36,6 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol } public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } if titleLockup.title.fontStyle == nil { titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift index 1205c55c..502a4f08 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2PricingTwoRowsModel.swift @@ -57,12 +57,6 @@ public class HeadersH2PricingTwoRowsModel: HeaderModel, MoleculeModelProtocol, P // MARK: - Methods //-------------------------------------------------- public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } if headline.accessibilityTraits == nil { headline.accessibilityTraits = .header } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift index a13c6b9e..a8271b8f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift @@ -47,12 +47,6 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren //-------------------------------------------------- public override func setDefaults() { - if topPadding == nil { - topPadding = Padding.Component.VerticalMarginSpacing - } - if bottomPadding == nil { - bottomPadding = Padding.Component.VerticalMarginSpacing - } if titleLockup.title.fontStyle == nil { titleLockup.title.fontStyle = Styler.Font.RegularTitleXLarge } From 4487f9b03bcd599add30459e5acae600a7f0935a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 14 Oct 2024 15:53:31 -0500 Subject: [PATCH 10/13] refactored badge text/fill color Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Badge.swift | 4 +- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 26 +++++-- .../Atomic/Atoms/Views/TileletModel.swift | 4 +- .../Atomic/Extensions/VDS-Enums+Codable.swift | 76 ++++++++++++++----- 4 files changed, 77 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift index 9957101f..218cc6fc 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Badge.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Badge.swift @@ -31,10 +31,10 @@ open class Badge: VDS.Badge, VDSMoleculeViewProtocol { self.accessibilityIdentifier = accessibilityIdentifier } text = viewModel.text - textColor = viewModel.textColor + textColor = viewModel.textColorStyle maxWidth = viewModel.maxWidth numberOfLines = viewModel.numberOfLines - fillColor = viewModel.fillColor + fillColor = viewModel.fillColorStyle surface = viewModel.surface } diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 52e43e9a..59309c49 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -22,15 +22,16 @@ open class BadgeModel: MoleculeModelProtocol { // MARK: - VDS Properties //-------------------------------------------------- public var text: String = "" - public var textColor: Badge.TextColor? = nil + public var textColorStyle: Badge.TextColor? = nil public var accessibilityText: String? public var maxWidth: CGFloat? public var numberOfLines: Int = 1 - public var fillColor = Badge.FillColor.red + public var fillColorStyle = Badge.FillColor.red + public var fillColor: Color? public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case id, accessibilityIdentifier, text, textColor, accessibilityText, fillColor, surface, numberOfLines, maxWidth + case id, accessibilityIdentifier, text, textColor, textColorStyle, accessibilityText, fillColor, fillColorStyle, surface, numberOfLines, maxWidth } required public convenience init(from decoder: Decoder) throws { @@ -39,11 +40,20 @@ open class BadgeModel: MoleculeModelProtocol { id = try container.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString accessibilityIdentifier = try container.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) text = try container.decode(String.self, forKey: .text) - if let foundTextColor = try container.decodeIfPresent(Color.self, forKey: .textColor) { - textColor = .custom(foundTextColor.uiColor) - } accessibilityText = try container.decodeIfPresent(String.self, forKey: .accessibilityText) - fillColor = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + + //look for a textColor + if let textColor = try container.decodeIfPresent(Color.self, forKey: .textColor) { + textColorStyle = .custom(textColor.uiColor) + } + + //look for a style + fillColorStyle = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + + //look for a color and set the style + if let fillColor = try container.decodeIfPresent(Color.self, forKey: .fillColor) { + fillColorStyle = .custom(fillColor.uiColor) + } surface = try container.decodeIfPresent(Surface.self, forKey: .surface) ?? .light numberOfLines = try container.decodeIfPresent(Int.self, forKey: .numberOfLines) ?? 1 maxWidth = try container.decodeIfPresent(CGFloat.self, forKey: .maxWidth) @@ -59,7 +69,7 @@ open class BadgeModel: MoleculeModelProtocol { try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) try container.encodeIfPresent(maxWidth, forKey: .maxWidth) - switch textColor { + switch textColorStyle { case .custom(let color): try container.encode(Color(uiColor: color), forKey: .textColor) default: diff --git a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift index 6802e5a7..33575f7c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TileletModel.swift @@ -94,8 +94,8 @@ open class TileletModel: TileContainerBaseModel, Molec public func badgeModel() -> Tilelet.BadgeModel? { guard let badge else { return nil } return .init(text: badge.text, - textColor: badge.textColor, - fillColor: badge.fillColor, + textColor: badge.textColorStyle, + fillColor: badge.fillColorStyle, surface: badge.surface, numberOfLines: badge.numberOfLines, maxWidth: badge.maxWidth diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index ab286f35..b7477ed4 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -305,30 +305,64 @@ extension VDS.Badge.FillColor: Codable { } public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - let type = try container.decode(CustomColorType.self, forKey: .type) - - switch type { - case .red: - self = .red - case .yellow: - self = .yellow - case .green: - self = .green - case .orange: - self = .orange - case .blue: - self = .blue - case .black: - self = .black - case .white: - self = .white - case .custom: - let color = try container.decode(Color.self, forKey: .color) + //try legacy ones that map to real fillColor cases + if let legacy = try? LegacyFillColor(from: decoder) { + self = legacy.fillColor + + } //try to convert to a color + else if let color = try? Color(from: decoder) { self = .custom(color.uiColor) + + } //try to use new format + else { + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(CustomColorType.self, forKey: .type) + + switch type { + case .red: + self = .red + case .yellow: + self = .yellow + case .green: + self = .green + case .orange: + self = .orange + case .blue: + self = .blue + case .black: + self = .black + case .white: + self = .white + case .custom: + let color = try container.decode(Color.self, forKey: .color) + self = .custom(color.uiColor) + } } } - + + private enum LegacyFillColor: String, Decodable { + case red, yellow, green, orange, blue, black, white + + var fillColor: Badge.FillColor { + switch self { + case .red: + return .red + case .yellow: + return .yellow + case .green: + return .green + case .orange: + return .orange + case .blue: + return .blue + case .black: + return .black + case .white: + return .white + } + } + } + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) switch self { From 76b58ec88aa192f7e78d7aa449060045668f42d4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 14 Oct 2024 15:57:25 -0500 Subject: [PATCH 11/13] using type now and not the old way. Signed-off-by: Matt Bruce --- .../Atomic/Extensions/VDS-Enums+Codable.swift | 74 +++++-------------- 1 file changed, 20 insertions(+), 54 deletions(-) diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index b7477ed4..93669dc4 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -305,61 +305,27 @@ extension VDS.Badge.FillColor: Codable { } public init(from decoder: Decoder) throws { - //try legacy ones that map to real fillColor cases - if let legacy = try? LegacyFillColor(from: decoder) { - self = legacy.fillColor - - } //try to convert to a color - else if let color = try? Color(from: decoder) { - self = .custom(color.uiColor) - - } //try to use new format - else { - let container = try decoder.container(keyedBy: CodingKeys.self) - let type = try container.decode(CustomColorType.self, forKey: .type) - - switch type { - case .red: - self = .red - case .yellow: - self = .yellow - case .green: - self = .green - case .orange: - self = .orange - case .blue: - self = .blue - case .black: - self = .black - case .white: - self = .white - case .custom: - let color = try container.decode(Color.self, forKey: .color) - self = .custom(color.uiColor) - } - } - } - - private enum LegacyFillColor: String, Decodable { - case red, yellow, green, orange, blue, black, white + let container = try decoder.container(keyedBy: CodingKeys.self) + let type = try container.decode(CustomColorType.self, forKey: .type) - var fillColor: Badge.FillColor { - switch self { - case .red: - return .red - case .yellow: - return .yellow - case .green: - return .green - case .orange: - return .orange - case .blue: - return .blue - case .black: - return .black - case .white: - return .white - } + switch type { + case .red: + self = .red + case .yellow: + self = .yellow + case .green: + self = .green + case .orange: + self = .orange + case .blue: + self = .blue + case .black: + self = .black + case .white: + self = .white + case .custom: + let color = try container.decode(Color.self, forKey: .color) + self = .custom(color.uiColor) } } From 7eb1a4ff4b3de58be62253df6b1da2c6682bcbcf Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 15 Oct 2024 16:57:37 -0500 Subject: [PATCH 12/13] redid the values Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift | 13 +++-- .../Atomic/Extensions/VDS-Enums+Codable.swift | 47 ++++++++----------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift index 59309c49..de5d0dd4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/BadgeModel.swift @@ -27,11 +27,13 @@ open class BadgeModel: MoleculeModelProtocol { public var maxWidth: CGFloat? public var numberOfLines: Int = 1 public var fillColorStyle = Badge.FillColor.red - public var fillColor: Color? public var surface: Surface = .light private enum CodingKeys: String, CodingKey { - case id, accessibilityIdentifier, text, textColor, textColorStyle, accessibilityText, fillColor, fillColorStyle, surface, numberOfLines, maxWidth + case id, accessibilityIdentifier, accessibilityText + case surface, numberOfLines, maxWidth + case text, textColor + case fillColor, fillColorStyle } required public convenience init(from decoder: Decoder) throws { @@ -48,7 +50,7 @@ open class BadgeModel: MoleculeModelProtocol { } //look for a style - fillColorStyle = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColor) ?? .red + fillColorStyle = try container.decodeIfPresent(Badge.FillColor.self, forKey: .fillColorStyle) ?? .red //look for a color and set the style if let fillColor = try container.decodeIfPresent(Color.self, forKey: .fillColor) { @@ -65,10 +67,10 @@ open class BadgeModel: MoleculeModelProtocol { try container.encode(text, forKey: .text) try container.encode(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) - try container.encode(fillColor, forKey: .fillColor) try container.encode(surface, forKey: .surface) try container.encode(numberOfLines, forKey: .numberOfLines) try container.encodeIfPresent(maxWidth, forKey: .maxWidth) + try container.encode(fillColorStyle, forKey: .fillColorStyle) switch textColorStyle { case .custom(let color): try container.encode(Color(uiColor: color), forKey: .textColor) @@ -80,7 +82,8 @@ open class BadgeModel: MoleculeModelProtocol { public func isEqual(to model: any ModelComparisonProtocol) -> Bool { guard let model = model as? BadgeModel else { return false } return self.backgroundColor == model.backgroundColor - && self.fillColor == model.fillColor + && self.fillColorStyle == model.fillColorStyle + && self.textColorStyle == model.textColorStyle && self.numberOfLines == model.numberOfLines && self.text == model.text && self.surface == model.surface diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 93669dc4..1109cece 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -294,49 +294,40 @@ extension VDS.TitleLockup.TextColor: Codable { } extension VDS.Badge.FillColor: Codable { - enum CodingKeys: String, CodingKey { - case type - case color - } - - enum CustomColorType: String, Codable { - case red, yellow, green, orange, blue, black, white - case custom - } - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - let type = try container.decode(CustomColorType.self, forKey: .type) - + let container = try decoder.singleValueContainer() + let type = try container.decode(String.self) switch type { - case .red: + case "red": self = .red - case .yellow: + case "yellow": self = .yellow - case .green: + case "green": self = .green - case .orange: + case "orange": self = .orange - case .blue: + case "blue": self = .blue - case .black: + case "black": self = .black - case .white: + case "white": self = .white - case .custom: - let color = try container.decode(Color.self, forKey: .color) - self = .custom(color.uiColor) + default: + if let color = try? Color(from: decoder) { + self = .custom(color.uiColor) + } else { + self = .custom(UIColor(hexString: type)) + } } } public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) + var container = encoder.singleValueContainer() switch self { - case .custom(let color): - try container.encode(CustomColorType.custom.rawValue, forKey: .type) - try container.encode(Color(uiColor: color), forKey: .color) + case .custom(let value): + try container.encode(Color(uiColor: value)) default: - try container.encode("\(self)", forKey: .type) + try container.encode(String(reflecting: self)) } } } From 7bed914dca20a97c5975052bdb9c16153ed76388 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 16 Oct 2024 10:53:16 -0400 Subject: [PATCH 13/13] Digital ACT191 defect CXTDT-626309 - Updating fonts and spacing Digital ACT191 defect CXTDT-628092 - Fixing accessibility trait header default. --- .../Headers/H1/HeadersH1ButtonModel.swift | 3 +++ .../Headers/H1/HeadersH1NoButtonsBodyTextModel.swift | 3 +++ .../Headers/H2/HeadersH2ButtonsModel.swift | 3 +++ .../Headers/H2/HeadersH2CaretLinkModel.swift | 3 +++ .../DesignedComponents/Headers/H2/HeadersH2LinkModel.swift | 3 +++ .../Headers/H2/HeadersH2NoButtonsBodyTextModel.swift | 3 +++ .../Headers/H2/HeadersH2TinyButtonModel.swift | 3 +++ .../ListOneColumnTextWithWhitespaceDividerShort.swift | 6 +++--- .../ListOneColumnTextWithWhitespaceDividerShortModel.swift | 3 +++ .../ListOneColumnTextWithWhitespaceDividerTall.swift | 6 +++--- .../ListOneColumnTextWithWhitespaceDividerTallModel.swift | 3 +++ MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift | 4 ++-- 12 files changed, 35 insertions(+), 8 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1ButtonModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1ButtonModel.swift index 901cf057..e228ea34 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1ButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1ButtonModel.swift @@ -52,6 +52,9 @@ public class HeadersH1ButtonModel: HeaderModel, MoleculeModelProtocol, ParentMol if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1NoButtonsBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1NoButtonsBodyTextModel.swift index 05457cdf..f3191358 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1NoButtonsBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H1/HeadersH1NoButtonsBodyTextModel.swift @@ -31,6 +31,9 @@ public class HeadersH1NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } } //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift index accd139e..b40ced44 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift @@ -53,6 +53,9 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift index 6675abcf..f5277136 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift @@ -48,6 +48,9 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift index 1a95bf73..f0084f99 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift @@ -52,6 +52,9 @@ public class HeadersH2LinkModel: HeaderModel, ParentMoleculeModelProtocol { if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift index 95414411..e5889562 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2NoButtonsBodyTextModel.swift @@ -42,6 +42,9 @@ public class HeadersH2NoButtonsBodyTextModel: HeaderModel, MoleculeModelProtocol if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift index a8271b8f..5f7b4017 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift @@ -53,6 +53,9 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren if titleLockup.subTitle?.fontStyle == nil { titleLockup.subTitle?.fontStyle = Styler.Font.RegularTitleMedium } + if titleLockup.title.accessibilityTraits == nil { + titleLockup.title.accessibilityTraits = [.header] + } super.setDefaults() button.style = .secondary button.size = .small diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift index 72dc78c0..815e7ff0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShort.swift @@ -15,7 +15,7 @@ import Foundation //----------------------------------------------------- public var stack: Stack - public let headline = Label(fontStyle: .BoldTitleMedium) + public let headline = Label(fontStyle: .BoldTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) //-------------------------------------------------- @@ -24,7 +24,7 @@ import Foundation public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 8, horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -63,7 +63,7 @@ import Foundation open override func reset() { super.reset() - headline.setFontStyle(.BoldTitleMedium) + headline.setFontStyle(.BoldTitleLarge) body.setFontStyle(.RegularBodySmall) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift index 141641e5..1ee3e04f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerShortModel.swift @@ -47,6 +47,9 @@ public class ListOneColumnTextWithWhitespaceDividerShortModel: ListItemModel, Mo override public func setDefaults() { style = .shortDivider + if headline.accessibilityTraits == nil { + headline.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index 169c33c9..5c13690b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -15,7 +15,7 @@ import Foundation //----------------------------------------------------- public var stack: Stack - public let headline = Label(fontStyle: .BoldTitleMedium) + public let headline = Label(fontStyle: .BoldTitleLarge) public let body = Label(fontStyle: .RegularBodySmall) //-------------------------------------------------- @@ -24,7 +24,7 @@ import Foundation public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: headline, model: StackItemModel(horizontalAlignment: .leading)), - (view: body, model: StackItemModel(spacing: 0, horizontalAlignment: .leading))], + (view: body, model: StackItemModel(spacing: 8, horizontalAlignment: .leading))], axis: .vertical) super.init(style: style, reuseIdentifier: reuseIdentifier) } @@ -62,7 +62,7 @@ import Foundation open override func reset() { super.reset() - headline.setFontStyle(.BoldTitleMedium) + headline.setFontStyle(.BoldTitleLarge) body.setFontStyle(.RegularBodySmall) accessibilityLabel = nil } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift index 74fd2965..44225509 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -47,6 +47,9 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol override public func setDefaults() { style = .tallDivider + if headline.accessibilityTraits == nil { + headline.accessibilityTraits = [.header] + } super.setDefaults() } diff --git a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift index 3ac37b49..50692689 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/ListItemModel.swift @@ -72,9 +72,9 @@ import MVMCore case .standard: set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: Padding.Component.VerticalMarginSpacing) case .shortDivider: - set(topPadding: Padding.Component.LargeVerticalMarginSpacing, bottomPadding: Padding.Four) + set(topPadding: Padding.Component.LargeVerticalMarginSpacing, bottomPadding: Padding.Five) case .tallDivider: - set(topPadding: Padding.Twelve, bottomPadding: Padding.Four) + set(topPadding: Padding.Twelve, bottomPadding: Padding.Five) case .sectionFooter: set(topPadding: Padding.Component.VerticalMarginSpacing, bottomPadding: 0) case ListItemStyle.none: