diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 038ecb6c..64bcc3ed 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -126,7 +126,6 @@ 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB423FF18D2004C5109 /* Arrow.swift */; }; 0AE98BB723FF18E9004C5109 /* ArrowModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */; }; 0AF60F0926B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF60F0826B3316E00AC3DB4 /* MVMCoreUIUtility+Extension.swift */; }; - 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */; }; 1D6D258826899B0C00DEBB08 /* ImageButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258626899B0B00DEBB08 /* ImageButtonModel.swift */; }; 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6D258726899B0B00DEBB08 /* ImageButton.swift */; }; 22B678F929E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B678F829E7944E00CF4196 /* GetNotificationAuthStatusBehavior.swift */; }; @@ -174,8 +173,6 @@ 5870636F2ACF238E00CA18D5 /* ReadableDecodingErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5870636E2ACF238E00CA18D5 /* ReadableDecodingErrors.swift */; }; 58A9DD7D2AC2103300F5E0B0 /* ReplaceableMoleculeBehaviorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A9DD7C2AC2103300F5E0B0 /* ReplaceableMoleculeBehaviorModel.swift */; }; 608211282AC6B57E00C3FC39 /* MVMCoreUILoggingHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608211262AC6AF8200C3FC39 /* MVMCoreUILoggingHandler.swift */; }; - 7199C8162A4F3A64001568B7 /* AccessibilityHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7199C8152A4F3A64001568B7 /* AccessibilityHandler.swift */; }; - 71BE969E2AD96BE6000B5DB7 /* RotorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71BE969D2AD96BE6000B5DB7 /* RotorHandler.swift */; }; 8D070BB0241B56530099AC56 /* ListRightVariableTotalDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */; }; 8D070BB2241B56AD0099AC56 /* ListRightVariableTotalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */; }; 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */; }; @@ -302,7 +299,6 @@ AFA4932229E5EF2E001A9663 /* NotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4932129E5EF2E001A9663 /* NotificationHandler.swift */; }; AFA4933F29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4933E29E874F0001A9663 /* MVMCoreUILoggingDelegateProtocol.swift */; }; AFA4935729EE3DCC001A9663 /* AlertDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4935629EE3DCC001A9663 /* AlertDelegateProtocol.swift */; }; - AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; B4CC8FBD29DF34680005D28B /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBC29DF34680005D28B /* Badge.swift */; }; B4CC8FBF29DF34730005D28B /* BadgeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4CC8FBE29DF34730005D28B /* BadgeModel.swift */; }; @@ -589,7 +585,6 @@ EA985C3E2970938F00F2FF2E /* Tilelet.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3D2970938F00F2FF2E /* Tilelet.swift */; }; EA985C402970939A00F2FF2E /* TileletModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C3F2970939A00F2FF2E /* TileletModel.swift */; }; EA985C602970A3F000F2FF2E /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C5F2970A3F000F2FF2E /* VDS.framework */; }; - EA985C642970A40E00F2FF2E /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA985C632970A40E00F2FF2E /* VDSTypographyTokens.xcframework */; }; EA985C852981AA9C00F2FF2E /* VDS-Enums+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C842981AA9C00F2FF2E /* VDS-Enums+Codable.swift */; }; EA985C872981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C862981AB0F00F2FF2E /* VDS-Tilelet+Codable.swift */; }; EA985C892981AB7100F2FF2E /* VDS-TextStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA985C882981AB7100F2FF2E /* VDS-TextStyle.swift */; }; @@ -604,6 +599,7 @@ EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.swift */; }; EACCF38C2ABB346700E0F104 /* VDS-Interpreters.swift in Sources */ = {isa = PBXBuildFile; fileRef = EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */; }; + EAD715AA2BBC8FAF00DEDA6A /* VDSTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAD715A92BBC8FAF00DEDA6A /* VDSTokens.xcframework */; }; FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; }; /* End PBXBuildFile section */ @@ -777,8 +773,6 @@ 5870636E2ACF238E00CA18D5 /* ReadableDecodingErrors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReadableDecodingErrors.swift; sourceTree = ""; }; 58A9DD7C2AC2103300F5E0B0 /* ReplaceableMoleculeBehaviorModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplaceableMoleculeBehaviorModel.swift; sourceTree = ""; }; 608211262AC6AF8200C3FC39 /* MVMCoreUILoggingHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUILoggingHandler.swift; sourceTree = ""; }; - 7199C8152A4F3A64001568B7 /* AccessibilityHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessibilityHandler.swift; sourceTree = ""; }; - 71BE969D2AD96BE6000B5DB7 /* RotorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RotorHandler.swift; sourceTree = ""; }; 8D070BAF241B56530099AC56 /* ListRightVariableTotalDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTotalDataModel.swift; sourceTree = ""; }; 8D070BB1241B56AD0099AC56 /* ListRightVariableTotalData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableTotalData.swift; sourceTree = ""; }; 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyTextModel.swift; sourceTree = ""; }; @@ -1208,6 +1202,7 @@ EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = ""; }; EACCF38B2ABB346700E0F104 /* VDS-Interpreters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VDS-Interpreters.swift"; sourceTree = ""; }; + EAD715A92BBC8FAF00DEDA6A /* VDSTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTokens.xcframework; path = ../SharedFrameworks/VDSTokens.xcframework; sourceTree = ""; }; FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1217,10 +1212,8 @@ buildActionMask = 2147483647; files = ( D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, - AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, EA985C602970A3F000F2FF2E /* VDS.framework in Frameworks */, - 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, - EA985C642970A40E00F2FF2E /* VDSTypographyTokens.xcframework in Frameworks */, + EAD715AA2BBC8FAF00DEDA6A /* VDSTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2081,6 +2074,7 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + EAD715A92BBC8FAF00DEDA6A /* VDSTokens.xcframework */, EA985C632970A40E00F2FF2E /* VDSTypographyTokens.xcframework */, EA985C5F2970A3F000F2FF2E /* VDS.framework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index e9fd6509..dec3480c 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS import MVMCore diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift index 9aea7b17..f9261d97 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/Link/Link.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS open class Link: VDS.TextLink, VDSMoleculeViewProtocol { diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift index e5d1ae73..7334ccf5 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/PillButton.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS import MVMCore import Combine @@ -36,7 +36,7 @@ open class PillButton: VDS.Button, MVMCoreUIViewConstrainingProtocol, MFButtonPr text = viewModel.title isEnabled = viewModel.enabled size = viewModel.size - use = viewModel.style ?? .primary + use = viewModel.style surface = viewModel.inverted ? .dark : .light if let accessibilityText = viewModel.accessibilityText { accessibilityLabel = accessibilityText diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 6966f3e6..2f9ae80a 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -7,8 +7,7 @@ // import UIKit -import VDSColorTokens -import VDSFormControlsTokens +import VDSTokens @objcMembers open class RadioButton: Control, MFButtonProtocol { //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift index 1d7808bd..56827bec 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicator.swift @@ -5,7 +5,7 @@ // Created by Kevin Christiano on 1/30/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // -import VDSColorTokens +import VDSTokens open class CarouselIndicator: Control, CarouselPageControlProtocol { //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift index f5c0adeb..3631bfc0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CarouselIndicator/CarouselIndicatorModel.swift @@ -7,7 +7,7 @@ // import Foundation -import VDSColorTokens +import VDSTokens open class CarouselIndicatorModel: CarouselPagingModelProtocol, MoleculeModelProtocol, EnableableModelProtocol { //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift index 965656a6..2ce1254b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabel.swift @@ -64,9 +64,8 @@ bottomLabelConstraint.isActive = true alignCheckbox(.center) - isAccessibilityElement = true - accessibilityHint = checkbox.accessibilityHint - accessibilityTraits = checkbox.accessibilityTraits + isAccessibilityElement = false + accessibilityElements = [checkbox, label] observation = observe(\.checkbox.isSelected, options: [.new]) { [weak self] _, _ in self?.updateAccessibilityLabel() } @@ -139,6 +138,8 @@ open func updateAccessibilityLabel() { checkbox.updateAccessibilityLabel() - accessibilityLabel = [checkbox.accessibilityLabel, label.text].compactMap { $0 }.joined(separator: ",") + if let text = label.text { + checkbox.accessibilityLabel?.append(", \(text)") + } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift index a1339cf3..4fbbd712 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/IconModel.swift @@ -8,7 +8,7 @@ import Foundation import VDS -import VDSColorTokens +import VDSTokens open class IconModel: MoleculeModelProtocol { diff --git a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift index 8a473016..2cfe9b99 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/LineModel.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS public class LineModel: MoleculeModelProtocol, Invertable { diff --git a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift index f6627dd3..27400a2c 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/TooltipModel.swift @@ -8,7 +8,7 @@ import Foundation import VDS -import VDSColorTokens +import VDSTokens import MVMCore open class TooltipModel: MoleculeModelProtocol { diff --git a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift index 9e524462..3e6ed245 100644 --- a/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift +++ b/MVMCoreUI/Atomic/Extensions/VDS-Enums+Codable.swift @@ -8,7 +8,7 @@ import Foundation import VDS -import VDSColorTokens +import VDSTokens //-------------------------------------------------- // MARK: - Codable Extensions diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift index 3b4d0b7e..9590fefc 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2ButtonsModel.swift @@ -74,7 +74,7 @@ public class HeadersH2ButtonsModel: HeaderModel, MoleculeModelProtocol, ParentMo required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup) + titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup) buttons = try typeContainer.decode(TwoButtonViewModel.self, forKey: .buttons) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift index 4f7129da..784966cf 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2CaretLinkModel.swift @@ -67,7 +67,7 @@ public class HeadersH2CaretLinkModel: HeaderModel, MoleculeModelProtocol, Parent //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup) + titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup) caretLink = try typeContainer.decode(CaretLinkModel.self, forKey: .caretLink) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift index 1ec6590d..0a104f9f 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2LinkModel.swift @@ -73,7 +73,7 @@ public class HeadersH2LinkModel: HeaderModel, MoleculeModelProtocol, ParentMolec required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup) + titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup) link = try typeContainer.decode(LinkModel.self, forKey: .link) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift index 91a1c472..aba4e48b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/Headers/H2/HeadersH2TinyButtonModel.swift @@ -76,7 +76,7 @@ public class HeadersH2TinyButtonModel: HeaderModel, MoleculeModelProtocol, Paren required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - titleLockup = try typeContainer.decodeMolecule(codingKey: .titleLockup) + titleLockup = try helper.deprecatedCreate(from: decoder) ?? typeContainer.decodeMolecule(codingKey: .titleLockup) button = try typeContainer.decode(ButtonModel.self, forKey: .button) try super.init(from: decoder) } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift index 3075a2ae..a280e0b4 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/LockUps/TitleLockupModel.swift @@ -6,7 +6,7 @@ // Copyright © 2022 Verizon Wireless. All rights reserved. // -import VDSColorTokens +import VDSTokens import VDS public class TitleLockupModel: MoleculeModelProtocol, ParentMoleculeModelProtocol { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index 65b116f5..370b47a6 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 5/28/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // -import VDSColorTokens +import VDSTokens @objcMembers open class TabBar: UITabBar, MoleculeViewProtocol, TabBarProtocol, UITabBarDelegate { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift index 6e8cb4a7..13c43afc 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBarModel.swift @@ -7,7 +7,7 @@ // import Foundation -import VDSColorTokens +import VDSTokens open class TabBarModel: MoleculeModelProtocol { public static var identifier: String = "tabBar" diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index ca4ca068..5a34245d 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS @objc public protocol TabsDelegate { diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index e09761d5..a7acadf6 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -7,7 +7,7 @@ // import UIKit -import VDSColorTokens +import VDSTokens import VDS open class TabsModel: MoleculeModelProtocol { diff --git a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift index 406fe56f..2846d164 100644 --- a/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/NavigationBar/NavigationItemModel.swift @@ -6,7 +6,7 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import VDSColorTokens +import VDSTokens public enum NavigationItemStyle: String, Codable { case light diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift index 4c677029..cef93935 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift @@ -10,6 +10,7 @@ import Foundation import Combine import Dispatch import MVMCore +import VDSTokens @objcMembers open class CollapsableNotification: View { //-------------------------------------------------- @@ -50,7 +51,7 @@ import MVMCore open override func reset() { super.reset() verticalStack.reset() - backgroundColor = .mvmGreen() + backgroundColor = bottomView.backgroundColor } open func subscribeForNotifications() { @@ -98,6 +99,8 @@ import MVMCore guard let model = model as? CollapsableNotificationModel else { return } topView.set(with: model, delegateObject, additionalData) bottomView.set(with: model, delegateObject, additionalData) + topView.label.textColorConfiguration = bottomView.titleLabel.textColorConfiguration + topView.label.surface = bottomView.surface // Update top view default noop to expand. if let topAction = model.topAction, @@ -110,6 +113,7 @@ import MVMCore } } initialState() + backgroundColor = bottomView.backgroundColor } open func performBlockOperation(with block: @escaping (MVMCoreBlockOperation) -> Void) { @@ -214,7 +218,7 @@ import MVMCore extension CollapsableNotification: StatusBarUI { public func getStatusBarUI() -> (color: UIColor, style: UIStatusBarStyle) { - let color = backgroundColor ?? UIColor.mvmGreen + let color = backgroundColor ?? VDSColor.feedbackInformationBackgroundOnlight var greyScale: CGFloat = 0 topView.label.textColor.getWhite(&greyScale, alpha: nil) return (color, greyScale > 0.5 ? .lightContent : .default) @@ -226,7 +230,7 @@ extension CollapsableNotification: AccessibilityProtocol { if !topView.isHidden { return topView } else { - return bottomView.headline + return bottomView.titleLabel } } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift index 3d366347..4c87a4e4 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationModel.swift @@ -26,21 +26,13 @@ open class CollapsableNotificationModel: NotificationMoleculeModel { self.collapseTime = collapseTime } super.init(with: headline, style: style, backgroundColor: backgroundColor, body: body, button: button, closeButton: closeButton) + setDefaults() } - open override func setDefaults() { - super.setDefaults() + open func setDefaults() { if topLabel.numberOfLines == nil { topLabel.numberOfLines = 1 } - if topLabel.textColor == nil { - switch style { - case .error, .warning: - topLabel.textColor = Color(uiColor: .mvmBlack) - default: - topLabel.textColor = Color(uiColor: .mvmWhite) - } - } if topLabel.textAlignment == nil { topLabel.textAlignment = .center } @@ -69,6 +61,7 @@ open class CollapsableNotificationModel: NotificationMoleculeModel { self.initiallyCollapsed = initiallyCollapsed } try super.init(from: decoder) + setDefaults() } open override func encode(to encoder: Encoder) throws { diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift index 01c0b3d5..1a9512d1 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotificationTopView.swift @@ -52,7 +52,7 @@ import Foundation open override func reset() { super.reset() label.setFontStyle(.BoldBodySmall) - label.textColor = .white + label.textColor = .black label.textAlignment = .center } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift index 9958b59a..0fc5d5d5 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeModel.swift @@ -5,9 +5,9 @@ // Created by Scott Pfeil on 9/15/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // +import VDS - -open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { +open class NotificationMoleculeModel: MoleculeModelProtocol { /** The style of the notification: @@ -21,91 +21,48 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { case error case warning case information + + var toVDSStyle: VDS.Notification.Style { + switch self { + case .success: + .success + case .error: + .error + case .warning: + .warning + case .information: + .info + } + } } //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - + public var id: String = UUID().uuidString public class var identifier: String { "notification" } public var accessibilityIdentifier: String? public var backgroundColor: Color? public var headline: LabelModel public var body: LabelModel? public var button: ButtonModel? + public var secondaryButton: ButtonModel? public var closeButton: NotificationXButtonModel? - public var style: NotificationMoleculeModel.Style = .success + public var style: Style = .success + public var inverted: Bool = false //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(with headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, closeButton: NotificationXButtonModel? = nil) { + public init(with headline: LabelModel, style: NotificationMoleculeModel.Style = .success, backgroundColor: Color? = nil, body: LabelModel? = nil, button: ButtonModel? = nil, secondaryButton: ButtonModel? = nil, closeButton: NotificationXButtonModel? = nil) { self.headline = headline self.style = style self.backgroundColor = backgroundColor self.body = body self.button = button + self.secondaryButton = secondaryButton self.closeButton = closeButton - super.init() - } - - //-------------------------------------------------- - // MARK: - Default - //-------------------------------------------------- - - open override func setDefaults() { - useHorizontalMargins = true - useVerticalMargins = true - topPadding = PaddingTwo - bottomPadding = PaddingTwo - - if backgroundColor == nil { - switch style { - case .error: - backgroundColor = Color(uiColor: .mvmOrange) - case .warning: - backgroundColor = Color(uiColor: .mvmYellow) - case .information: - backgroundColor = Color(uiColor: .mvmBlue) - default: - backgroundColor = Color(uiColor: .mvmGreen) - } - } - if headline.textColor == nil { - switch style { - case .error, .warning: - headline.textColor = Color(uiColor: .mvmBlack) - default: - headline.textColor = Color(uiColor: .mvmWhite) - } - } - if body?.textColor == nil { - switch style { - case .error, .warning: - body?.textColor = Color(uiColor: .mvmBlack) - default: - body?.textColor = Color(uiColor: .mvmWhite) - } - } - - button?.size = .small - button?.style = .secondary - switch style { - case .error, .warning: - button?.inverted = false - default: - button?.inverted = true - } - - if closeButton?.color == nil { - switch style { - case .error, .warning: - closeButton?.color = Color(uiColor: .mvmBlack) - default: - closeButton?.color = Color(uiColor: .mvmWhite) - } - } } //-------------------------------------------------- @@ -119,7 +76,9 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { case headline case body case button + case secondaryButton case closeButton + case inverted case style } @@ -129,27 +88,34 @@ open class NotificationMoleculeModel: ContainerModel, MoleculeModelProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) headline = try typeContainer.decode(LabelModel.self, forKey: .headline) body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button) + secondaryButton = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .secondaryButton) closeButton = try typeContainer.decodeIfPresent(NotificationXButtonModel.self, forKey: .closeButton) + inverted = try typeContainer.decodeIfPresent(Bool.self, forKey: .inverted) ?? false if let style = try typeContainer.decodeIfPresent(NotificationMoleculeModel.Style.self, forKey: .style) { self.style = style } - super.init() } - open override func encode(to encoder: Encoder) throws { + open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(moleculeName, forKey: .moleculeName) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encode(headline, forKey: .headline) try container.encodeIfPresent(body, forKey: .body) try container.encodeIfPresent(button, forKey: .button) + try container.encodeIfPresent(secondaryButton, forKey: .secondaryButton) try container.encodeIfPresent(closeButton, forKey: .closeButton) + try container.encodeIfPresent(inverted, forKey: .inverted) try container.encode(style, forKey: .style) } } + +extension NotificationMoleculeModel { + public var surface: Surface { + inverted ? .dark : .light + } +} diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift index 200dea16..38c58aa9 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationMoleculeView.swift @@ -7,90 +7,101 @@ // import Foundation - -@objcMembers open class NotificationMoleculeView: Container { +import VDS +@objcMembers open class NotificationMoleculeView: VDS.Notification, VDSMoleculeViewProtocol { + + + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + open var viewModel: NotificationMoleculeModel! + public var delegateObject: MVMCoreUIDelegateObject? + public var additionalData: [AnyHashable: Any]? + + //-------------------------------------------------- + // MARK: - VDSMoleculeViewProtocol + //-------------------------------------------------- + + open func viewModelDidUpdate() { + surface = viewModel.surface + title = viewModel.headline.text + subTitle = viewModel.body?.text + + if let button = viewModel.button { + primaryButtonModel = .init(text: button.title, onClick: {[weak self] _ in + guard let self else { return } + self.executeAction(model: button, delegateObject: self.delegateObject, additionalData: self.additionalData) + }) + } + + if let secondaryButton = viewModel.secondaryButton { + secondaryButtonModel = .init(text: secondaryButton.title, onClick: {[weak self] _ in + guard let self else { return } + self.executeAction(model: secondaryButton, delegateObject: self.delegateObject, additionalData: self.additionalData) + }) + } + + if let accessibilityIdentifier = viewModel.accessibilityIdentifier { + self.accessibilityIdentifier = accessibilityIdentifier + } + + if let closeButton = viewModel.closeButton { + onCloseClick = { [weak self] _ in + guard let self else { return } + self.executeAction(model: closeButton, delegateObject: self.delegateObject, additionalData: self.additionalData) } + } + + hideCloseButton = viewModel.closeButton == nil + style = viewModel.style.toVDSStyle + } + //-------------------------------------------------- // MARK: - Outlets //-------------------------------------------------- - - public let headline = Label(fontStyle: .BoldBodySmall) - public let body = Label(fontStyle: .RegularBodySmall) - public let button = PillButton() - public let closeButton = NotificationXButton() - public var labelStack: Stack! - public var horizontalStack: Stack! - // Legacy constant private static let viewHeight: CGFloat = 96.0 //-------------------------------------------------- // MARK: - Life Cycle //-------------------------------------------------- - - public override func setupView() { - super.setupView() - reset() - - // Buttons should have highest priority, then headline, then body - headline.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 500), for: .horizontal) - headline.setContentHuggingPriority(.required, for: .vertical) - body.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 500), for: .horizontal) - body.setContentHuggingPriority(.required, for: .vertical) - headline.setContentCompressionResistancePriority(UILayoutPriority(rawValue: body.contentCompressionResistancePriority(for: .vertical).rawValue + 40), for: .vertical) - headline.lineBreakMode = .byTruncatingTail - body.lineBreakMode = .byTruncatingTail - button.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) - - labelStack = Stack.createStack(with: [headline, body], spacing: 0) - horizontalStack = Stack.createStack(with: [(view: labelStack, model: StackItemModel()),(view: button, model: StackItemModel(horizontalAlignment: .fill)),(view: closeButton, model: StackItemModel(horizontalAlignment: .fill))], axis: .horizontal) - addAndContain(horizontalStack) - labelStack.restack() - horizontalStack.restack() - - heightAnchor.constraint(equalToConstant: Self.viewHeight).isActive = true - } - - open override func reset() { - super.reset() - backgroundColor = .mvmGreen() - headline.textColor = .white - body.textColor = .white + open override func updateAccessibility() { + super.updateAccessibility() + Self.amendAccesibilityLabel(for: titleLabel) + Self.amendAccesibilityLabel(for: subTitleLabel) + Self.amendAccesibilityLabel(for: primaryButton) + Self.amendAccesibilityLabel(for: secondaryButton) + Self.amendAccesibilityLabel(for: closeButton) } //-------------------------------------------------- // MARK: - Molecule //-------------------------------------------------- - - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - guard let model = model as? NotificationMoleculeModel else { return } - labelStack.updateContainedMolecules(with: [model.headline, model.body], delegateObject, nil) - horizontalStack.updateContainedMolecules(with: [labelStack.stackModel, model.button, model.closeButton], delegateObject, nil) - updateAccessibility() - } - - open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + public func updateView(_ size: CGFloat) { } + + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return viewHeight } - - open func updateAccessibility() { - NotificationMoleculeView.amendAccesibilityLabel(for: headline) - NotificationMoleculeView.amendAccesibilityLabel(for: body) - NotificationMoleculeView.amendAccesibilityLabel(for: button) - NotificationMoleculeView.amendAccesibilityLabel(for: closeButton) - } - + /// Formats the accessibilityLabel so voice over users know it's in the notification. - static public func amendAccesibilityLabel(for view: UIView) { - guard let amendment = MVMCoreUIUtility.hardcodedString(withKey: "top_alert_notification"), - let accessibilityLabel = view.accessibilityLabel, - !accessibilityLabel.hasPrefix(amendment) else { return } - view.accessibilityLabel = "\(amendment) - \(accessibilityLabel)" + public class func amendAccesibilityLabel(for view: UIView?) { + guard let view, + let amendment = MVMCoreUIUtility.hardcodedString(withKey: "top_alert_notification") + else { return } + view.amendAccesibilityLabel(with: amendment) } } extension NotificationMoleculeView: AccessibilityProtocol { public func getAccessibilityLayoutChangedArgument() -> Any? { - return headline + return titleLabel + } +} + +extension UIView { + /// Formats the accessibilityLabel so voice over users know it's in the notification. + public func amendAccesibilityLabel(with amendment: String) { + guard let accessibilityLabel, !accessibilityLabel.hasPrefix(amendment) else { return } + self.accessibilityLabel = "\(amendment) - \(accessibilityLabel)" } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index d0071668..c102d064 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -30,7 +30,6 @@ import MVMCore open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? NotificationXButtonModel else { return } - tintColor = model.color?.uiColor ?? .white // TODO: Temporary, consider action for dismissing top alert if model.action.actionType == ActionNoopModel.identifier { diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift index ac1c8905..0206b79d 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButtonModel.swift @@ -15,25 +15,21 @@ public class NotificationXButtonModel: ButtonModelProtocol, MoleculeModelProtoco public var id: String = UUID().uuidString public var backgroundColor: Color? - public var color: Color? public var action: ActionModelProtocol = ActionNoopModel() private enum CodingKeys: String, CodingKey { case id case moleculeName - case color case action } - public init(color: Color? = nil, action: ActionModelProtocol = ActionNoopModel()) { - self.color = color + public init(action: ActionModelProtocol = ActionNoopModel()) { self.action = action } 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 - color = try typeContainer.decodeIfPresent(Color.self, forKey: .color) if let action: ActionModelProtocol = try typeContainer.decodeModelIfPresent(codingKey: .action) { self.action = action } @@ -43,7 +39,6 @@ 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.encodeIfPresent(color, forKey: .color) try container.encodeModel(action, forKey: .action) } } diff --git a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift index c3c07b6a..3869b398 100644 --- a/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/MoleculeViewProtocol.swift @@ -66,6 +66,14 @@ extension MoleculeViewProtocol { set(with: model, delegateObject, additionalData) } } + + public func executeAction(model: T, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model.action, + additionalData: MVMCoreUIActionHandler.add(sourceModel: model, to: additionalData), + delegateObject: delegateObject) + } + } } // Convenience Functions diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift index 1bcc78c6..4bebf0c7 100644 --- a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift @@ -21,7 +21,11 @@ public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtoc } extension VDSMoleculeViewProtocol { - + public var model: MoleculeModelProtocol { + get { viewModel } + set { } + } + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { self.model = model guard let castedModel = model as? ViewModel else { return } diff --git a/MVMCoreUI/Categories/UIColor+Extension.swift b/MVMCoreUI/Categories/UIColor+Extension.swift index 78363630..f4ef0f7f 100644 --- a/MVMCoreUI/Categories/UIColor+Extension.swift +++ b/MVMCoreUI/Categories/UIColor+Extension.swift @@ -56,6 +56,18 @@ extension UIColor { "upGold2": (.vzupGold2, "#F4CA53"), "upGold3": (.vzupGold3, "#CC9B2D")] + //-------------------------------------------------- + // MARK: - Helper + //-------------------------------------------------- + public var rgbComponents: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) { + var red: CGFloat = 0 + var green: CGFloat = 0 + var blue: CGFloat = 0 + var alpha: CGFloat = 0 + getRed(&red, green: &green, blue: &blue, alpha: &alpha) + return (red, green, blue, alpha) + } + //-------------------------------------------------- // MARK: - Brand //-------------------------------------------------- diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index 57f4b5a5..d8d56244 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -34,6 +34,7 @@ import Combine public static func setupNavigationControllerAsMainController() -> Self? { guard let navigationController = setupNavigationController() else { return nil } MVMCoreUISession.sharedGlobal()?.setup(asStandardLoadViewDelegate: navigationController) + MVMCoreObject.sharedInstance()?.viewControllerManager = navigationController return navigationController } @@ -136,6 +137,31 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func displayedViewController(_ viewController: UIViewController) { manager?.displayedViewController?(viewController) } + + private func go(to index: Int) async { + guard index != viewControllers.count - 1 else { return } + await NavigationHandler.shared().set(viewControllers: Array(viewControllers[0...index]), navigationController: self) + } + + public func navigate(toViewControllerOfPageType pageType: String, controllerType: AnyClass?) async -> UIViewController? { + for (index, controller) in viewControllers.enumerated() { + if let manager = controller as? MVMCoreViewManagerProtocol, + let viewController = await manager.navigate(toViewControllerOfPageType: pageType, controllerType: controllerType) { + await go(to: index) + return viewController + } else if let controller = controller as? MVMCoreViewControllerProtocol & UIViewController, + controller.pageType == pageType { + guard let controllerType = controllerType else { + await go(to: index) + return controller + } + guard (type(of: controller) == controllerType) else { continue } + await go(to: index) + return controller + } + } + return nil + } } extension UIColor { diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index 44aa9207..5a3d9a1a 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -102,7 +102,7 @@ public extension UINavigationController { navigationBar.standardAppearance = appearance navigationBar.scrollEdgeAppearance = appearance - setNavigationBarHidden(model.hidden, animated: true) + setNavigationBarHidden(model.hidden, animated: false) } @objc @MainActor diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift index c0420055..549d53a8 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController+Extension.swift @@ -269,6 +269,10 @@ extension MVMCoreUISplitViewController: MVMCoreViewManagerProtocol { public func newDataReceived(in viewController: UIViewController) { updateState(with: viewController) } + + public func navigate(toViewControllerOfPageType pageType: String, controllerType: AnyClass?) async -> UIViewController? { + return await navigationController?.navigate(toViewControllerOfPageType: pageType, controllerType: controllerType) + } } @objc public extension MVMCoreUISplitViewController { diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 79c81b8d..453c7d56 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -95,6 +95,7 @@ CGFloat const PanelAnimationDuration = 0.2; if (topAlertView) { [splitViewController subscribeForNotifications]; } + [MVMCoreObject sharedInstance].viewControllerManager = splitViewController; return splitViewController; } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 741fb830..19a4cbc0 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -8,7 +8,7 @@ import Foundation import MVMCore -import VDSColorTokens +import VDSTokens open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, TabsDelegate, MVMCorePresentationDelegateProtocol, SubNavSwipeNavigationProtocol { /// The number of tabs count or less that will turn on the fillContainer @@ -362,6 +362,35 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, manager?.displayedViewController?(viewController) } + private func go(to index: Int) async { + // Load controller from the cache + guard index != self.index, + let controller = viewControllers[index] else { return } + needToTrackTabSelect = true + self.index = index + await NavigationHandler.shared().replace(viewController: controller, navigationController:subNavigationController, delegateObject:delegateObject(), tryToReplace: false, animated: true) + } + + public func navigate(toViewControllerOfPageType pageType: String, controllerType: AnyClass?) async -> UIViewController? { + for (index, controller) in viewControllers.enumerated() { + if let manager = controller as? MVMCoreViewManagerProtocol, + let viewController = await manager.navigate(toViewControllerOfPageType: pageType, controllerType: controllerType) { + await go(to: index) + return viewController + } else if let controller = controller as? MVMCoreViewControllerProtocol & UIViewController, + controller.pageType == pageType { + guard let controllerType = controllerType else { + await go(to: index) + return controller + } + guard (type(of: controller) == controllerType) else { continue } + await go(to: index) + return controller + } + } + return nil + } + // MARK: - MVMCoreUISwipeNavigationProtocol public func swipeLeft() { diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index 2f755491..ea91f62b 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -73,6 +73,7 @@ public extension MVMCoreUIUtility { @objc public extension MVMCoreUIUtility { + /// Returns the current visible viewcontroller. @objc @MainActor static func getVisibleViewController() -> UIViewController? { var viewController = NavigationHandler.shared().getViewControllerToPresentOn()