From 8e486f9301003734da636e255b292ff8258e4834 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Thu, 29 Sep 2022 19:52:00 +0530 Subject: [PATCH 01/51] Added RuleNotEquals form rule PREGRO-5736 --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../Rules/Rules/RuleNotEqualsModel.swift | 44 +++++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 3 files changed, 49 insertions(+) create mode 100644 MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index df9843e1..9f29106c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -602,6 +602,7 @@ EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.swift */; }; + FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -1203,6 +1204,7 @@ EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = ""; }; + FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1257,6 +1259,7 @@ 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */, 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */, 0A849EFD246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift */, + FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */, ); name = Rules; path = Rules/Rules; @@ -2956,6 +2959,7 @@ D2509ED12472ED9B001BFB9D /* NavigationItemModelProtocol.swift in Sources */, EA05EFAB278DE53600828819 /* ClearableModelProtocol.swift in Sources */, 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, + FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */, BBC0C4FD24811DBC0087C44F /* Tag.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift new file mode 100644 index 00000000..1cd8bb74 --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift @@ -0,0 +1,44 @@ +// +// RuleNotEqualsModel.swift +// MVMCoreUI +// +// Created by Marakanti, Keerthy on 26/09/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class RuleNotEqualsModel: RuleCompareModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "notEquals" + public var type: String = RuleNotEqualsModel.identifier + public var ruleId: String? + public var fields: [String] + public var errorMessage: [String: String]? + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(fields: [String]) { + self.fields = fields + } + + //-------------------------------------------------- + // MARK: - Validation + //-------------------------------------------------- + + public func isValid(_ formField: FormFieldProtocol) -> Bool { + return false + } + + ///RuleCompareModelProtocol Method + public func compare(lhs: AnyHashable?, rhs: AnyHashable?) -> Bool { + return lhs != rhs + } + +} + diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 061c67fb..3e5357ea 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -244,6 +244,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(RuleAnyValueChangedModel.self) ModelRegistry.register(RuleAllValueChangedModel.self) ModelRegistry.register(RuleEqualsModel.self) + ModelRegistry.register(RuleNotEqualsModel.self) ModelRegistry.register(RuleEqualsIgnoreCaseModel.self) ModelRegistry.register(RuleRegexModel.self) ModelRegistry.register(EnableFormFieldEffectModel.self) From 1f73a351dc88b1bfac4d4c9d2d93cea76b3dafc2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 12 Oct 2022 11:25:20 -0500 Subject: [PATCH 02/51] vds toggle import Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9f29106c..d4a5eac7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -598,6 +598,8 @@ EAA0CFAF275E7D8000D65EB0 /* FormFieldEffectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */; }; EAA0CFB1275E823A00D65EB0 /* HideFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */; }; EAA0CFB3275E831E00D65EB0 /* DisableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */; }; + EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF628F5D074003B3210 /* VDS.framework */; }; + EAA5EEFA28F5D079003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */; }; EAB14BC127D935F00012AB2C /* RuleCompareModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */; }; EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; @@ -1200,6 +1202,8 @@ EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldEffectProtocol.swift; sourceTree = ""; }; EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideFormFieldEffectModel.swift; sourceTree = ""; }; EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableFormFieldEffectModel.swift; sourceTree = ""; }; + EAA5EEF628F5D074003B3210 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = "/Users/mattbruce/Documents/Projects/iPhone/Frameworks/MVA-JSONCreator/vds_ios/../SharedFrameworks/VDSTypographyTokens.xcframework"; sourceTree = ""; }; EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleCompareModelProtocol.swift; sourceTree = ""; }; EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; @@ -1214,7 +1218,9 @@ files = ( D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, + EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */, 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, + EAA5EEFA28F5D079003B3210 /* VDSTypographyTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2058,6 +2064,8 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + EAA5EEF628F5D074003B3210 /* VDS.framework */, + EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, From bf4c28019b8f88359528f04efd32d8f9c1408b88 Mon Sep 17 00:00:00 2001 From: Sumanth Nadigadda Date: Thu, 13 Oct 2022 21:17:33 +0530 Subject: [PATCH 03/51] Fix for CXTDT-331565, appending link disabled status to the accessibility text --- .../ListRightVariableTextLinkAllTextAndLinks.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift index 059a637f..e47cae46 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableTextLinkAllTextAndLinks.swift @@ -71,10 +71,14 @@ func getAccessibilityMessage() -> String? { - guard let linkText = link.titleLabel?.text else { + guard var linkText = link.titleLabel?.text else { return eyebrowHeadlineBodyLink.getAccessibilityMessage() } + if !link.isEnabled, let accDisabled = MVMCoreUIUtility.hardcodedString(withKey:"AccDisabled") { + linkText = linkText + ", " + accDisabled + } + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { return linkText } From f9b47922db319b13be6b049339739c5424638d99 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 20 Oct 2022 16:20:16 -0400 Subject: [PATCH 04/51] always embed swift to no --- MVMCoreUI.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9f29106c..eb5327be 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3225,7 +3225,6 @@ D29DF0D221E404D4003B2FB9 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_SEARCH_USER_PATHS = NO; BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -3293,7 +3292,6 @@ D29DF0D321E404D4003B2FB9 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_SEARCH_USER_PATHS = NO; BUILD_LIBRARY_FOR_DISTRIBUTION = YES; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; From 9255e4021fbc9d93ba1ac4b60871386890e8bd2c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 13:50:50 -0500 Subject: [PATCH 05/51] this is now in VDS Signed-off-by: Matt Bruce --- .../Atomic/Atoms/Views/Label/Label.swift | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 9ce55537..9e5881a4 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -8,6 +8,7 @@ // import MVMCore +import VDS public typealias ActionBlock = () -> () @@ -737,36 +738,6 @@ public typealias ActionBlock = () -> () clauses.append(ActionableClause(range: range, actionBlock: actionBlock, accessibilityID: accessibleAction?.hash ?? -1)) } - /** - Provides a text container and layout manager of how the text would appear on screen. - They are used in tandem to derive low-level TextKit results of the label. - */ - public func abstractTextContainer() -> (NSTextContainer, NSLayoutManager, NSTextStorage)? { - - // Must configure the attributed string to translate what would appear on screen to accurately analyze. - guard let attributedText = attributedText else { return nil } - - let paragraph = NSMutableParagraphStyle() - paragraph.alignment = textAlignment - - let stagedAttributedString = NSMutableAttributedString(attributedString: attributedText) - stagedAttributedString.addAttributes([NSAttributedString.Key.paragraphStyle: paragraph], range: NSRange(location: 0, length: attributedText.string.count)) - - let textStorage = NSTextStorage(attributedString: stagedAttributedString) - let layoutManager = NSLayoutManager() - let textContainer = NSTextContainer(size: .zero) - - layoutManager.addTextContainer(textContainer) - textStorage.addLayoutManager(layoutManager) - - textContainer.lineFragmentPadding = 0.0 - textContainer.lineBreakMode = lineBreakMode - textContainer.maximumNumberOfLines = numberOfLines - textContainer.size = bounds.size - - return (textContainer, layoutManager, textStorage) - } - public static func boundingRect(forCharacterRange range: NSRange, in label: Label) -> CGRect { guard let abstractContainer = label.abstractTextContainer() else { return CGRect() } From b0d8a2668863c4a2ffe38b86f12a9c128b777aef Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 13:51:20 -0500 Subject: [PATCH 06/51] added protocol for helping in VDS, this at some point will refactor into the main Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 4 +++ .../Protocols/VDSMoleculeViewProtocol.swift | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index d4a5eac7..5540d6a8 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -600,6 +600,7 @@ EAA0CFB3275E831E00D65EB0 /* DisableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */; }; EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF628F5D074003B3210 /* VDS.framework */; }; EAA5EEFA28F5D079003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */; }; + EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */; }; EAB14BC127D935F00012AB2C /* RuleCompareModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */; }; EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; @@ -1204,6 +1205,7 @@ EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableFormFieldEffectModel.swift; sourceTree = ""; }; EAA5EEF628F5D074003B3210 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = "/Users/mattbruce/Documents/Projects/iPhone/Frameworks/MVA-JSONCreator/vds_ios/../SharedFrameworks/VDSTypographyTokens.xcframework"; sourceTree = ""; }; + EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSMoleculeViewProtocol.swift; sourceTree = ""; }; EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleCompareModelProtocol.swift; sourceTree = ""; }; EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; @@ -2460,6 +2462,7 @@ D2B9D0E3265EEE9D0084735C /* MoleculeListProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, + EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */, ); path = Protocols; sourceTree = ""; @@ -2786,6 +2789,7 @@ 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, D23A90002612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift in Sources */, + EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift new file mode 100644 index 00000000..0a6f3179 --- /dev/null +++ b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift @@ -0,0 +1,31 @@ +// +// VDSMoleculeViewProtocol.swift +// MVMCoreUI +// +// Created by Matt Bruce on 10/19/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +///----------------------------------------------------------------------------- +///MARK: -- VDSMoleculeViewProtocol (Contract between VDS -> Atomic) +///----------------------------------------------------------------------------- +public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtocol { + associatedtype ViewModel: MoleculeModelProtocol + var viewModel: ViewModel! { get set } + var delegateObject: MVMCoreUIDelegateObject? { get set } + var additionalData: [AnyHashable: Any]? { get set } + func viewModelDidUpdate() +} + +extension VDSMoleculeViewProtocol { + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + guard let castedModel = model as? ViewModel else { return } + self.delegateObject = delegateObject + viewModel = castedModel + viewModelDidUpdate() + } +} + From 1073530ee95821a5f32b397c61f5c7ee201abc5d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 16:15:54 -0500 Subject: [PATCH 07/51] refactored Toggle / ToggleModel for VDS Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 447 +++--------------- .../Atomic/Atoms/Selectors/ToggleModel.swift | 60 +-- 2 files changed, 82 insertions(+), 425 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 85ad8e9c..99635900 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -8,8 +8,7 @@ import MVMCore import UIKit - -public typealias ActionBlockConfirmation = () -> (Bool) +import VDS /** A custom implementation of Apple's UISwitch. @@ -19,402 +18,102 @@ public typealias ActionBlockConfirmation = () -> (Bool) Container: The background of the toggle control. Knob: The circular indicator that slides on the container. */ -@objcMembers open class Toggle: Control, MVMCoreUIViewConstrainingProtocol { +open class Toggle: ToggleBase, VDSMoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - - /// Holds the on and off colors for the container. - public var containerTintColor: (on: UIColor, off: UIColor) = (on: .mvmGreen, off: .mvmBlack) - - /// Holds the on and off colors for the knob. - public var knobTintColor: (on: UIColor, off: UIColor) = (on: .mvmWhite, off: .mvmWhite) - - /// Holds the on and off colors for the disabled state.. - public var disabledTintColor: (container: UIColor, knob: UIColor) = (container: .mvmCoolGray3, knob: .mvmWhite) - - /// Set this flag to false if you do not want to animate state changes. - public var isAnimated = true - - public var didToggleAction: ActionBlock? - - /// Executes logic before state change. If false, then toggle state will not change and the didToggleAction will not execute. - public var shouldToggleAction: ActionBlockConfirmation? = { - return { true } - }() - - // Sizes are from InVision design specs. - static let containerSize = CGSize(width: 51, height: 31) - static let knobSize = CGSize(width: 28, height: 28) - - private var knobView: View = { - let view = View() - view.backgroundColor = .white - view.layer.cornerRadius = Toggle.getKnobHeight() / 2.0 - return view - }() - - //-------------------------------------------------- - // MARK: - Computed Properties - //-------------------------------------------------- - - open override var isEnabled: Bool { - didSet { - isUserInteractionEnabled = isEnabled - changeStateNoAnimation(isEnabled ? isOn : false) - setToggleAppearanceFromState() - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isEnabled ? "AccToggleHint" : "AccDisabled") - } - } - - /// Simple means to prevent user interaction with the toggle. - public var isLocked: Bool = false { - didSet { isUserInteractionEnabled = !isLocked } - } - - /// The state on the toggle. Default value: false. - open var isOn: Bool = false { - didSet { - if isAnimated { - UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: { - if self.isOn { - self.knobView.backgroundColor = self.knobTintColor.on - self.backgroundColor = self.containerTintColor.on - - } else { - self.knobView.backgroundColor = self.knobTintColor.off - self.backgroundColor = self.containerTintColor.off - } - }, completion: nil) - - UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: { - self.constrainKnob() - self.knobWidthConstraint?.constant = Self.getKnobWidth() - self.layoutIfNeeded() - }, completion: nil) - - } else { - setToggleAppearanceFromState() - self.constrainKnob() - } + public var viewModel: ToggleModel! + public var delegateObject: MVMCoreUIDelegateObject? + public var additionalData: [AnyHashable: Any]? - toggleModel?.selected = isOn - _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) - accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff") - setNeedsLayout() - layoutIfNeeded() - } - } - - public var toggleModel: ToggleModel? { - model as? ToggleModel - } - - //-------------------------------------------------- - // MARK: - Delegate - //-------------------------------------------------- - - private var delegateObject: MVMCoreUIDelegateObject? - - //-------------------------------------------------- - // MARK: - Constraints - //-------------------------------------------------- - - private var knobLeadingConstraint: NSLayoutConstraint? - private var knobTrailingConstraint: NSLayoutConstraint? - private var knobHeightConstraint: NSLayoutConstraint? - private var knobWidthConstraint: NSLayoutConstraint? - private var heightConstraint: NSLayoutConstraint? - private var widthConstraint: NSLayoutConstraint? - - private func constrainKnob() { - - knobLeadingConstraint?.isActive = false - knobTrailingConstraint?.isActive = false - - _ = isOn ? constrainKnobOn() : constrainKnobOff() - - knobTrailingConstraint?.isActive = true - knobLeadingConstraint?.isActive = true - } - - private func constrainKnobOn() { - - knobTrailingConstraint = trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 2) - knobLeadingConstraint = knobView.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor) - } - - private func constrainKnobOff() { - - knobTrailingConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: knobView.trailingAnchor) - knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 2) - } - //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- - - public override init(frame: CGRect) { - super.init(frame: frame) - } - - public convenience override init() { - self.init(frame: .zero) - } - public convenience init(isOn: Bool) { self.init(frame: .zero) self.isOn = isOn } - - /// - parameter isOn: Bool to set the state of the toggle. - /// - parameter didToggleAction: A closure which is executed after the toggle changes states. - public convenience init(isOn: Bool = false, didToggleAction: ActionBlock?) { - self.init(frame: .zero) - changeStateNoAnimation(isOn) - self.didToggleAction = didToggleAction - } - - /// - parameter shouldToggleAction: Takes a closure that returns a boolean. - /// - parameter didToggleAction: A closure which is executed after the toggle changes states. - public convenience init(shouldToggleAction: ActionBlockConfirmation?, didToggleAction: ActionBlock?) { - self.init(frame: .zero) - self.didToggleAction = didToggleAction - self.shouldToggleAction = shouldToggleAction - } - - public required init?(coder: NSCoder) { - super.init(coder: coder) - fatalError("Toggle does not support xib.") - } - - //-------------------------------------------------- - // MARK: - Lifecycle - //-------------------------------------------------- - - public override func updateView(_ size: CGFloat) { - super.updateView(size) - - heightConstraint?.constant = Self.getContainerHeight() - widthConstraint?.constant = Self.getContainerWidth() - - knobHeightConstraint?.constant = Self.getKnobHeight() - knobWidthConstraint?.constant = Self.getKnobWidth() - - layer.cornerRadius = Self.getContainerHeight() / 2.0 - knobView.layer.cornerRadius = Self.getKnobHeight() / 2.0 - - changeStateNoAnimation(isOn) - } - - public override func setupView() { - super.setupView() - - isAccessibilityElement = true - accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") - accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - accessibilityTraits = .button - heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height) - heightConstraint?.isActive = true - - widthConstraint = widthAnchor.constraint(equalToConstant: Self.containerSize.width) - widthConstraint?.isActive = true - - layer.cornerRadius = Self.getContainerHeight() / 2.0 - backgroundColor = containerTintColor.off - - addSubview(knobView) - - knobHeightConstraint = knobView.heightAnchor.constraint(equalToConstant: Self.knobSize.height) - knobHeightConstraint?.isActive = true - knobWidthConstraint = knobView.widthAnchor.constraint(equalToConstant: Self.knobSize.width) - knobWidthConstraint?.isActive = true - knobView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true - knobView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true - bottomAnchor.constraint(greaterThanOrEqualTo: knobView.bottomAnchor).isActive = true - - constrainKnobOff() - } - - public override func reset() { - super.reset() - - backgroundColor = containerTintColor.off - knobView.backgroundColor = knobTintColor.off - accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - isAnimated = true - didToggleAction = nil - shouldToggleAction = { return true } - } - - class func getContainerWidth() -> CGFloat { - let containerWidth = Self.containerSize.width - return (MFSizeObject(standardSize: containerWidth, standardiPadPortraitSize: CGFloat(Self.containerSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerWidth - } - - class func getContainerHeight() -> CGFloat { - let containerHeight = Self.containerSize.height - return (MFSizeObject(standardSize: containerHeight, standardiPadPortraitSize: CGFloat(Self.containerSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerHeight - } - - class func getKnobWidth() -> CGFloat { - let knobWidth = Self.knobSize.width - return (MFSizeObject(standardSize: knobWidth, standardiPadPortraitSize: CGFloat(Self.knobSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobWidth - } - - class func getKnobHeight() -> CGFloat { - let knobHeight = Self.knobSize.width - return (MFSizeObject(standardSize: knobHeight, standardiPadPortraitSize: CGFloat(Self.knobSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobHeight - } - - //-------------------------------------------------- - // MARK: - Actions - //-------------------------------------------------- - - open override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) { - super.sendAction(action, to: target, for: event) - toggleAndAction() - } - - open override func sendActions(for controlEvents: UIControl.Event) { - super.sendActions(for: controlEvents) - toggleAndAction() - } - - /// This will toggle the state of the Toggle and execute the actionBlock if provided. - public func toggleAndAction() { - - if let result = shouldToggleAction?(), result { - isOn.toggle() - didToggleAction?() - } - } - - private func changeStateNoAnimation(_ state: Bool) { - - // Hold state in case User wanted isAnimated to remain off. - let isAnimatedState = isAnimated - - isAnimated = false - isOn = state - isAnimated = isAnimatedState - } - - override open func accessibilityActivate() -> Bool { - // Hold state in case User wanted isAnimated to remain off. - guard isUserInteractionEnabled else { return false } - let isAnimatedState = isAnimated - isAnimated = false - sendActions(for: .touchUpInside) - isAnimated = isAnimatedState - return true - } - - //-------------------------------------------------- - // MARK: - UIResponder - //-------------------------------------------------- - - open override func touchesBegan(_ touches: Set, with event: UIEvent?) { - - UIView.animate(withDuration: 0.1, animations: { - self.knobWidthConstraint?.constant += PaddingOne - self.layoutIfNeeded() - }) - } - - public override func touchesEnded(_ touches: Set, with event: UIEvent?) { - - knobReformAnimation() - - // Action only occurs of the user lifts up from withing acceptable region of the toggle. - guard let coordinates = touches.first?.location(in: self), - coordinates.x > -20, - coordinates.x < bounds.width + 20, - coordinates.y > -20, - coordinates.y < bounds.height + 20 - else { return } - - sendActions(for: .touchUpInside) - } - - public func touchesCancelled(_ touches: Set, with event: UIEvent) { - - knobReformAnimation() - sendActions(for: .touchCancel) - } - - //-------------------------------------------------- - // MARK: - Animations - //-------------------------------------------------- - - public func setToggleAppearanceFromState() { - - backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container - knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob - } - - public func knobReformAnimation() { - - if isAnimated { - UIView.animate(withDuration: 0.1, animations: { - self.knobWidthConstraint?.constant = Self.getKnobWidth() - self.layoutIfNeeded() - }, completion: nil) - - } else { - knobWidthConstraint?.constant = Self.getKnobWidth() - layoutIfNeeded() - } - } + open override func initialSetup() { + super.initialSetup() - // MARK:- MoleculeViewProtocol - public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - super.set(with: model, delegateObject, additionalData) - self.delegateObject = delegateObject - - guard let model = model as? ToggleModel else { return } - - FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - - containerTintColor.on = model.onTintColor.uiColor - containerTintColor.off = model.offTintColor.uiColor - knobTintColor.on = model.onKnobTintColor.uiColor - knobTintColor.off = model.offKnobTintColor.uiColor - isOn = model.selected - changeStateNoAnimation(isOn) - isAnimated = model.animated - isEnabled = model.enabled && !model.readOnly - - if let accessibileString = model.accessibilityText { - accessibilityLabel = accessibileString - } - - if model.action != nil || model.alternateAction != nil { - didToggleAction = { [weak self] in + publisher(for: .touchUpInside) + .sink {[weak self] toggle in guard let self = self else { return } - if self.isOn { - if let action = model.action { - MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) - } - } else { - if let action = model.alternateAction ?? model.action { - MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) - } - } + self.toggle() + }.store(in: &subscribers) + + publisher(for: .valueChanged) + .sink {[weak self] toggle in + guard let self = self else { return } + self.valueChanged(isOn: toggle.isOn) + }.store(in: &subscribers) + + accessibilityLabelEnabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + accessibilityLabelDisabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + accessibilityHintEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") + accessibilityHintDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccDisabled") + accessibilityValueEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOn") + accessibilityValueDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOff") + } + + open func updateView(_ size: CGFloat) {} + + open override func updateView() { + super.updateView() + backgroundColor = .clear + } + + open func viewModelDidUpdate() { + guard let viewModel else { return } + FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) + additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: viewModel) + } + + private func valueChanged(isOn: Bool){ + guard let viewModel else { return } + //sync the value on the viewModel + viewModel.selected = isOn + + //tell the form you changed + _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) + + if viewModel.action != nil || viewModel.alternateAction != nil { + var action: ActionModelProtocol? + if isOn { + action = viewModel.action + } else { + action = viewModel.alternateAction ?? viewModel.action + } + if let action { + MVMCoreUIActionHandler.performActionUnstructured(with: action, + sourceModel: viewModel, + additionalData: additionalData, + delegateObject: delegateObject) } } } - public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - Self.getContainerHeight() + public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 44 + } + + private typealias ActionDefinition = (model: ActionModelProtocol, + sourceModel: MoleculeModelProtocol?) + + private func performActionUnstructured(definition: ActionDefinition) { + MVMCoreUIActionHandler.performActionUnstructured(with: definition.model, + sourceModel: definition.sourceModel, + additionalData: additionalData, + delegateObject: delegateObject) } } // MARK: - MVMCoreUIViewConstrainingProtocol -extension Toggle { +extension Toggle: MVMCoreUIViewConstrainingProtocol { public func needsToBeConstrained() -> Bool { true } public func horizontalAlignment() -> UIStackView.Alignment { .trailing } } + diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index e8d50851..3fd6c3d5 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -13,20 +13,14 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- public static var identifier: String = "toggle" - public var accessibilityIdentifier: String? - public var backgroundColor: Color? + public var backgroundColor: Color? //not used + public var selected: Bool = false - public var animated: Bool = true public var enabled: Bool = true public var readOnly: Bool = false public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? - public var onTintColor: Color = Color(uiColor: .mvmGreen) - public var offTintColor: Color = Color(uiColor: .mvmBlack) - public var onKnobTintColor: Color = Color(uiColor: .mvmWhite) - public var offKnobTintColor: Color = Color(uiColor: .mvmWhite) - public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? @@ -34,22 +28,16 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- - + private enum CodingKeys: String, CodingKey { case moleculeName case state - case animated case enabled case readOnly case action - case backgroundColor case accessibilityIdentifier case alternateAction case accessibilityText - case onTintColor - case offTintColor - case onKnobTintColor - case offKnobTintColor case fieldKey case groupName } @@ -75,7 +63,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- public init(_ state: Bool) { - self.selected = state + selected = state baseValue = state } @@ -87,60 +75,30 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { - self.selected = state + selected = state } - - if let animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) { - self.animated = animated - } - action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) - backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) - accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) - - if let onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) { - self.onTintColor = onTintColor - } - - if let offTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offTintColor) { - self.offTintColor = offTintColor - } - - if let onKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onKnobTintColor) { - self.onKnobTintColor = onKnobTintColor - } - - if let offKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offKnobTintColor) { - self.offKnobTintColor = offKnobTintColor - } - accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - baseValue = selected fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - self.groupName = groupName + if let gName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + groupName = gName } enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false + + } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(selected, forKey: .state) - try container.encode(animated, forKey: .animated) try container.encode(enabled, forKey: .enabled) - try container.encode(onTintColor, forKey: .onTintColor) - try container.encode(onKnobTintColor, forKey: .onKnobTintColor) - try container.encode(onKnobTintColor, forKey: .onKnobTintColor) - try container.encode(offKnobTintColor, forKey: .offKnobTintColor) - try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encode(readOnly, forKey: .readOnly) From 433b45a5457feecbe58df21718342221fa6ec4c3 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 17:06:51 -0500 Subject: [PATCH 08/51] removed framework not needed Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 60da155c..929d1131 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -599,7 +599,6 @@ EAA0CFB1275E823A00D65EB0 /* HideFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */; }; EAA0CFB3275E831E00D65EB0 /* DisableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */; }; EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF628F5D074003B3210 /* VDS.framework */; }; - EAA5EEFA28F5D079003B3210 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */; }; EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */; }; EAB14BC127D935F00012AB2C /* RuleCompareModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */; }; EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; @@ -1222,7 +1221,6 @@ AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */, 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, - EAA5EEFA28F5D079003B3210 /* VDSTypographyTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; From 3a3bbe05ead3014b91afdc9fe2cc2912b5141d1a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 21 Oct 2022 17:07:01 -0500 Subject: [PATCH 09/51] added in didToggleAction Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 99635900..3bf8f878 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -25,6 +25,7 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { public var viewModel: ToggleModel! public var delegateObject: MVMCoreUIDelegateObject? public var additionalData: [AnyHashable: Any]? + public var didToggleAction: ActionBlock? //-------------------------------------------------- // MARK: - Initializers @@ -74,10 +75,12 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { guard let viewModel else { return } //sync the value on the viewModel viewModel.selected = isOn - + //tell the form you changed _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) + didToggleAction?() + if viewModel.action != nil || viewModel.alternateAction != nil { var action: ActionModelProtocol? if isOn { From 30530bc4e13cd8f5af4c1832bed138b8b210d7fb Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 22 Oct 2022 09:11:03 -0500 Subject: [PATCH 10/51] removed isOn being passed Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 3bf8f878..9a977b40 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -45,9 +45,9 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { }.store(in: &subscribers) publisher(for: .valueChanged) - .sink {[weak self] toggle in + .sink {[weak self] _ in guard let self = self else { return } - self.valueChanged(isOn: toggle.isOn) + self.valueChanged() }.store(in: &subscribers) accessibilityLabelEnabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") @@ -71,7 +71,7 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: viewModel) } - private func valueChanged(isOn: Bool){ + private func valueChanged(){ guard let viewModel else { return } //sync the value on the viewModel viewModel.selected = isOn From c075323ce7520417945ec8cd15d0af5460679bf1 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 10:49:26 -0500 Subject: [PATCH 11/51] update for changes discussed today Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 58 ++++++++++--------- .../Protocols/VDSMoleculeViewProtocol.swift | 1 + 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 9a977b40..16072b89 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -9,6 +9,7 @@ import MVMCore import UIKit import VDS +import Combine /** A custom implementation of Apple's UISwitch. @@ -25,8 +26,8 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { public var viewModel: ToggleModel! public var delegateObject: MVMCoreUIDelegateObject? public var additionalData: [AnyHashable: Any]? - public var didToggleAction: ActionBlock? - + public var valueChangedCancellable: AnyCancellable? + //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- @@ -34,22 +35,37 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { self.init(frame: .zero) self.isOn = isOn } - + open override func initialSetup() { super.initialSetup() - + publisher(for: .touchUpInside) .sink {[weak self] toggle in guard let self = self else { return } self.toggle() }.store(in: &subscribers) + //this is logic that will always need to be run + //and is added into the array of Set publisher(for: .valueChanged) .sink {[weak self] _ in - guard let self = self else { return } - self.valueChanged() + guard let self = self, let viewModel = self.viewModel else { return } + //sync the value on the viewModel + viewModel.selected = self.isOn + + //tell the form you changed + _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) + }.store(in: &subscribers) - + + //register the defaultActionExecuter + //this can then be overwritten by a subclass + valueChangedCancellable = publisher(for: .valueChanged) + .sink {[weak self] _ in + guard let self = self else { return } + self.executeDefaultAction() + } + accessibilityLabelEnabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") accessibilityLabelDisabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") accessibilityHintEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") @@ -57,9 +73,9 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { accessibilityValueEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOn") accessibilityValueDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOff") } - + open func updateView(_ size: CGFloat) {} - + open override func updateView() { super.updateView() backgroundColor = .clear @@ -67,20 +83,13 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { open func viewModelDidUpdate() { guard let viewModel else { return } + + //send toggle.model to the Form FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) - additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: viewModel) } - private func valueChanged(){ + public func executeDefaultAction() { guard let viewModel else { return } - //sync the value on the viewModel - viewModel.selected = isOn - - //tell the form you changed - _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) - - didToggleAction?() - if viewModel.action != nil || viewModel.alternateAction != nil { var action: ActionModelProtocol? if isOn { @@ -97,19 +106,12 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { } } + //Return the same height as the internal ToggleBase.toggleContainerSize.height + //since this is a class func, we can't reference it directly public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { return 44 } - private typealias ActionDefinition = (model: ActionModelProtocol, - sourceModel: MoleculeModelProtocol?) - - private func performActionUnstructured(definition: ActionDefinition) { - MVMCoreUIActionHandler.performActionUnstructured(with: definition.model, - sourceModel: definition.sourceModel, - additionalData: additionalData, - delegateObject: delegateObject) - } } // MARK: - MVMCoreUIViewConstrainingProtocol diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift index 0a6f3179..41349f2c 100644 --- a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift @@ -24,6 +24,7 @@ extension VDSMoleculeViewProtocol { public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { guard let castedModel = model as? ViewModel else { return } self.delegateObject = delegateObject + self.additionalData = additionalData viewModel = castedModel viewModelDidUpdate() } From e27fa862d5cae99dc38c89f4d9580da53900ecc0 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 11:51:08 -0500 Subject: [PATCH 12/51] forgot to add back in animated to the model accessibilityIdentifier isn't even used in the current Toggle today Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 3fd6c3d5..fec5a78d 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -18,6 +18,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { public var selected: Bool = false public var enabled: Bool = true public var readOnly: Bool = false + public var animated: Bool = false public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? @@ -34,8 +35,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { case state case enabled case readOnly + case animated case action - case accessibilityIdentifier case alternateAction case accessibilityText case fieldKey @@ -87,13 +88,12 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { } enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false - + animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) ?? false } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) @@ -102,5 +102,6 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encode(readOnly, forKey: .readOnly) + try container.encode(animated, forKey: .animated) } } From 20fcbb57c2f51020d5083313a6e2653faf17c3df Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 11:51:42 -0500 Subject: [PATCH 13/51] added notes for backgroundColor added in ToggleBase property setters for ToggleModel properties Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 16072b89..c84e566f 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -78,12 +78,23 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { open override func updateView() { super.updateView() + //we want to overwrite the VDS color that is set in the ToggleBase + //for surface since the Atomic controls doesn't look at + //surface today for its views. We just want to show whatever + //the current parent's background color. backgroundColor = .clear } open func viewModelDidUpdate() { guard let viewModel else { return } + //set properties from the viewModel change that came in + if let accessibileString = viewModel.accessibilityText { + accessibilityLabelEnabled = accessibileString + accessibilityLabelDisabled = accessibileString + } + isAnimated = viewModel.animated + //send toggle.model to the Form FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) } From 92fefd0ac14bc842a6d78351f46b7a7956a2f942 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 11:56:36 -0500 Subject: [PATCH 14/51] removed framework not needed Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 929d1131..eb0b1ac3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1203,7 +1203,6 @@ EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideFormFieldEffectModel.swift; sourceTree = ""; }; EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableFormFieldEffectModel.swift; sourceTree = ""; }; EAA5EEF628F5D074003B3210 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = "/Users/mattbruce/Documents/Projects/iPhone/Frameworks/MVA-JSONCreator/vds_ios/../SharedFrameworks/VDSTypographyTokens.xcframework"; sourceTree = ""; }; EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSMoleculeViewProtocol.swift; sourceTree = ""; }; EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleCompareModelProtocol.swift; sourceTree = ""; }; EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; @@ -2065,7 +2064,6 @@ isa = PBXGroup; children = ( EAA5EEF628F5D074003B3210 /* VDS.framework */, - EAA5EEF728F5D074003B3210 /* VDSTypographyTokens.xcframework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, From c93a270b1a05f5c726914b81497c4d70d8e231d9 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 13:25:14 -0500 Subject: [PATCH 15/51] updated name to valueChangedSubscription Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index c84e566f..0152771e 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -26,7 +26,7 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { public var viewModel: ToggleModel! public var delegateObject: MVMCoreUIDelegateObject? public var additionalData: [AnyHashable: Any]? - public var valueChangedCancellable: AnyCancellable? + public var valueChangedSubscription: AnyCancellable? //-------------------------------------------------- // MARK: - Initializers @@ -60,7 +60,7 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { //register the defaultActionExecuter //this can then be overwritten by a subclass - valueChangedCancellable = publisher(for: .valueChanged) + valueChangedSubscription = publisher(for: .valueChanged) .sink {[weak self] _ in guard let self = self else { return } self.executeDefaultAction() From ae431b8b2b30cbc4e1dda449f5a368731669fbb4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 13:46:21 -0500 Subject: [PATCH 16/51] cancelled the previous subscription Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 0152771e..89acf4c2 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -26,7 +26,13 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { public var viewModel: ToggleModel! public var delegateObject: MVMCoreUIDelegateObject? public var additionalData: [AnyHashable: Any]? - public var valueChangedSubscription: AnyCancellable? + public var valueChangedSubscription: AnyCancellable? { + willSet{ + if let current = valueChangedSubscription { + current.cancel() + } + } + } //-------------------------------------------------- // MARK: - Initializers From c043fff7bd854a906f1873c1979fdb8ef7c283be Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Oct 2022 14:07:30 -0500 Subject: [PATCH 17/51] default is animated, not sure what i was thinking earlier today Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index fec5a78d..1389b11e 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -18,7 +18,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { public var selected: Bool = false public var enabled: Bool = true public var readOnly: Bool = false - public var animated: Bool = false + public var animated: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? @@ -88,7 +88,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { } enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false - animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) ?? false + animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) ?? true } From 47b28f297fb64344230d119ebba634d9c3b37285 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 24 Oct 2022 17:33:23 -0400 Subject: [PATCH 18/51] Create an alertObject generator from a direct alertModel. Cleanup model initialization interface. --- .../Alerts/MVMCoreAlertObject+Swift.swift | 35 +++++++++++++++++++ .../Atomic/Actions/ActionAlertHandler.swift | 11 ++++-- MVMCoreUI/Atomic/Actions/AlertModel.swift | 5 +-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift index c2c5d50f..ea9dfd98 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift @@ -9,6 +9,41 @@ public extension MVMCoreAlertObject { + static func alertObject(from alertModel: AlertModel, actions: [UIAlertAction]? = nil, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> MVMCoreAlertObject? { + + let actionsForAlert = actions ?? generateActions(from: alertModel.alertActions, additionalData: additionalData, delegateObject: delegateObject) + + let alertObject = MVMCoreAlertObject(popupAlertWithTitle: alertModel.title, + message: alertModel.message, + actions: actionsForAlert, + isGreedy: false) + + alertObject?.alertStyle = alertModel.style + alertObject?.pageJson = alertModel.analyticsData + + return alertObject + } + + static func generateActions(from buttonModels: [AlertButtonModel], additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalHandling: ((AlertButtonModel, UIAlertAction)->())? = nil) -> [UIAlertAction] { + return buttonModels.map { alertButtonModel in + let alertAction = UIAlertAction(title: alertButtonModel.title, style: alertButtonModel.style) { action in + Task(priority: .userInitiated) { + do { + try await MVMCoreUIActionHandler.shared()?.handleAction( + with: alertButtonModel.action, + additionalData: additionalData, + delegateObject: delegateObject + ) + } catch { + + } + additionalHandling?(alertButtonModel, action) + } + } + return alertAction + } + } + @objc static func alertObjectWith(action actionJson: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> MVMCoreAlertObject? { guard let alertJson = actionJson?.optionalDictionaryForKey("alert"), diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift index 0f4a11fa..67ed6156 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -25,7 +25,14 @@ open class ActionAlertHandler: MVMCoreJSONActionHandlerProtocol { } open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { - let json = try MVMCoreActionHandler.convertActionToJSON(model) - try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData) + guard let model = model as? ActionAlertModel else { return } + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject.alertObject(from: model.alert, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + throw MVMCoreError.errorObject(error!) + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: (try? MVMCoreActionHandler.convertActionToJSON(model)) ?? [:]) + _ = await MainActor.run { + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } } } diff --git a/MVMCoreUI/Atomic/Actions/AlertModel.swift b/MVMCoreUI/Atomic/Actions/AlertModel.swift index 76bfb273..6825898c 100644 --- a/MVMCoreUI/Atomic/Actions/AlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/AlertModel.swift @@ -23,7 +23,7 @@ public class AlertButtonModel: Codable { // MARK: - Initializer //-------------------------------------------------- - public init(_ title: String,_ action: ActionModelProtocol,_ style: UIAlertAction.Style = .default) { + public init(_ title: String, _ action: ActionModelProtocol, style: UIAlertAction.Style = .default) { self.title = title self.action = action self.style = style @@ -76,10 +76,11 @@ public class AlertModel: Codable { // MARK: - Properties //-------------------------------------------------- - public init(_ title: String,_ message: String,_ alertActions: [AlertButtonModel]) { + public init(title: String, message: String, alertActions: [AlertButtonModel], style: UIAlertController.Style = .alert) { self.title = title self.message = message self.alertActions = alertActions + self.style = style } //-------------------------------------------------- From 847d7ed372dbd52d3735de715277c5585d69199a Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Oct 2022 11:16:27 -0500 Subject: [PATCH 19/51] renamed var Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 89acf4c2..b220a330 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -95,9 +95,9 @@ open class Toggle: ToggleBase, VDSMoleculeViewProtocol { guard let viewModel else { return } //set properties from the viewModel change that came in - if let accessibileString = viewModel.accessibilityText { - accessibilityLabelEnabled = accessibileString - accessibilityLabelDisabled = accessibileString + if let accessibilityText = viewModel.accessibilityText { + accessibilityLabelEnabled = accessibilityText + accessibilityLabelDisabled = accessibilityText } isAnimated = viewModel.animated From d0a0ea9e4ec0067b81b1d9ef4b03cfee6105b95f Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Oct 2022 11:24:02 -0500 Subject: [PATCH 20/51] update logic Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 1389b11e..84bc25aa 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -83,9 +83,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) baseValue = selected fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - if let gName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { - groupName = gName - } + groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) ?? true From ad0bbbab8e6fa67237b890b8353468dd2d2e59df Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 25 Oct 2022 11:25:44 -0500 Subject: [PATCH 21/51] added to encoding Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index 84bc25aa..bcc11d8b 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -94,6 +94,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(selected, forKey: .state) try container.encode(enabled, forKey: .enabled) From e813cf8fac450231190491eeea509bbf25a52a7b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 11:06:19 -0500 Subject: [PATCH 22/51] added VDS framework --- Scripts/build_aggregate.sh | 4 ++++ Scripts/download_dependencies.sh | 4 +++- Scripts/download_framework.sh | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 84c7f4fb..911a4002 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -15,6 +15,10 @@ UNIVERSAL_OUTPUTFOLDER="${BUILD_DIR}/universal" # Update to use .xcframework sed -i '' 's|MVMCore.framework \*\/ = {isa.*};|MVMCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MVMCore.xcframework; path = ../SharedFrameworks/MVMCore.xcframework; sourceTree = ""; };|g' ./MVMCoreUI.xcodeproj/project.pbxproj sed -i '' 's/MVMCore.framework/MVMCore.xcframework/g' ./MVMCoreUI.xcodeproj/project.pbxproj + +sed -i '' 's|VDS.framework \*\/ = {isa.*};|VDS.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDS.xcframework; path = ../SharedFrameworks/VDS.xcframework; sourceTree = ""; };|g' ./MVMCoreUI.xcodeproj/project.pbxproj +sed -i '' 's/VDS.framework/VDS.xcframework/g' ./MVMCoreUI.xcodeproj/project.pbxproj + sed -i '' "s|path = \.\.\/SharedFrameworks|path = ${FRAMEWORKS_DIR}|g" ./MVMCoreUI.xcodeproj/project.pbxproj # Build device archive diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index cc6bc209..bd0368da 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -20,6 +20,8 @@ fi ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/3.0/MVMCore-3.0-Debug-SNAPSHOT.zip -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/%40vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDS.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/VDS/1.0/VDS-1.0-Debug-SNAPSHOT.zip + +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSFormControlsTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSFormControlsTokens.1.0.7.xcframework.zip diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 5d602e0a..791e9ead 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,7 +48,7 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") -CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') +CHECKSUM=$(echo "$JSON" | python3 -c 'import sys, json; print (json.load(sys.stdin)["checksums"]["sha1"])') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi From 7225866ba1bc755e5ac606fc108c0206849804c2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 11:11:10 -0500 Subject: [PATCH 23/51] added VDSTypography Signed-off-by: Matt Bruce --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++++ Scripts/download_dependencies.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index eb0b1ac3..ad8b8a73 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -593,6 +593,7 @@ EA41F4AC2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */; }; EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */; }; EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */; }; + EA797B402909936000DBAFE6 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */; }; EA7E67742758310500ABF773 /* EnableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67732758310500ABF773 /* EnableFormFieldEffectModel.swift */; }; EA7E67762758365300ABF773 /* UIUpdatableModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67752758365300ABF773 /* UIUpdatableModelProtocol.swift */; }; EAA0CFAF275E7D8000D65EB0 /* FormFieldEffectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */; }; @@ -1197,6 +1198,7 @@ EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicRuleFormFieldEffectModel.swift; sourceTree = ""; }; EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButton.swift; sourceTree = ""; }; EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButtonModel.swift; sourceTree = ""; }; + EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; EA7E67732758310500ABF773 /* EnableFormFieldEffectModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnableFormFieldEffectModel.swift; sourceTree = ""; }; EA7E67752758365300ABF773 /* UIUpdatableModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIUpdatableModelProtocol.swift; sourceTree = ""; }; EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldEffectProtocol.swift; sourceTree = ""; }; @@ -1220,6 +1222,7 @@ AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */, 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, + EA797B402909936000DBAFE6 /* VDSTypographyTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2063,6 +2066,7 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( + EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */, EAA5EEF628F5D074003B3210 /* VDS.framework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index bd0368da..7d15f39d 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -25,3 +25,6 @@ fi ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSFormControlsTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSFormControlsTokens.1.0.7.xcframework.zip + +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSTypographyTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSTypographyTokens.2.0.0.xcframework.zip + From 4f8c33228a77a609a0078fc1ee81e5e8c972bbe6 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 26 Oct 2022 11:20:54 -0500 Subject: [PATCH 24/51] updated to 3.1 for MVMCore Signed-off-by: Matt Bruce --- Scripts/download_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 7d15f39d..87b29d03 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -18,7 +18,7 @@ if [ ! -d $FRAMEWORKS_DIR ]; then mkdir -p $FRAMEWORKS_DIR fi -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/3.0/MVMCore-3.0-Debug-SNAPSHOT.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/3.1/MVMCore-3.1-Debug-SNAPSHOT.zip ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDS.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/VDS/1.0/VDS-1.0-Debug-SNAPSHOT.zip From 4eca0db76ca3eca6affe57ade725677b99b66559 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 26 Oct 2022 15:45:09 -0400 Subject: [PATCH 25/51] MFCheckbox adding --- MVMCoreUI/BaseClasses/Control.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 865e3a8e..91cee30f 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -9,7 +9,7 @@ import UIKit -@objcMembers open class Control: UIControl, MoleculeViewProtocol { +open class Control: UIControl, MoleculeViewProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- From 0da94465b369adc4a0ba632d1b19651f9adaf2f0 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Thu, 27 Oct 2022 17:49:49 -0400 Subject: [PATCH 26/51] allow action delegate to perform the actiopn --- MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift index ea9dfd98..0adae2e2 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject+Swift.swift @@ -29,7 +29,7 @@ public extension MVMCoreAlertObject { let alertAction = UIAlertAction(title: alertButtonModel.title, style: alertButtonModel.style) { action in Task(priority: .userInitiated) { do { - try await MVMCoreUIActionHandler.shared()?.handleAction( + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction( with: alertButtonModel.action, additionalData: additionalData, delegateObject: delegateObject From 9ce2023eec8097a6f70cfcfbbb8fabec5573e1e3 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 28 Oct 2022 10:48:58 -0400 Subject: [PATCH 27/51] code review: allow try to throw on model decode --- MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift index 67ed6156..f3004f71 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -30,7 +30,7 @@ open class ActionAlertHandler: MVMCoreJSONActionHandlerProtocol { guard let alertObject = MVMCoreAlertObject.alertObject(from: model.alert, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { throw MVMCoreError.errorObject(error!) } - (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: (try? MVMCoreActionHandler.convertActionToJSON(model)) ?? [:]) + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: try MVMCoreActionHandler.convertActionToJSON(model)) _ = await MainActor.run { MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) } From c6a8b0c2889d3b27581994b3a6d824b2395d0ee3 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 1 Nov 2022 17:27:58 -0400 Subject: [PATCH 28/51] Revert "Merge branch 'develop' into 'release/10_4_0'" This reverts commit a65f52ca07a352f8849d13677bccbc15998230ce, reversing changes made to edfb2c1f366dc4335727396cb3fb0b35dced681f. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ---- Scripts/build_aggregate.sh | 4 ---- Scripts/download_dependencies.sh | 9 ++------- Scripts/download_framework.sh | 2 +- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index ad8b8a73..eb0b1ac3 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -593,7 +593,6 @@ EA41F4AC2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */; }; EA5124FD243601600051A3A4 /* BGImageHeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */; }; EA5124FF2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */; }; - EA797B402909936000DBAFE6 /* VDSTypographyTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */; }; EA7E67742758310500ABF773 /* EnableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67732758310500ABF773 /* EnableFormFieldEffectModel.swift */; }; EA7E67762758365300ABF773 /* UIUpdatableModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7E67752758365300ABF773 /* UIUpdatableModelProtocol.swift */; }; EAA0CFAF275E7D8000D65EB0 /* FormFieldEffectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */; }; @@ -1198,7 +1197,6 @@ EA41F4AB2787927100F5B377 /* DynamicRuleFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicRuleFormFieldEffectModel.swift; sourceTree = ""; }; EA5124FC243601600051A3A4 /* BGImageHeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButton.swift; sourceTree = ""; }; EA5124FE2436018E0051A3A4 /* BGImageHeadlineBodyButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BGImageHeadlineBodyButtonModel.swift; sourceTree = ""; }; - EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSTypographyTokens.xcframework; path = ../SharedFrameworks/VDSTypographyTokens.xcframework; sourceTree = ""; }; EA7E67732758310500ABF773 /* EnableFormFieldEffectModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EnableFormFieldEffectModel.swift; sourceTree = ""; }; EA7E67752758365300ABF773 /* UIUpdatableModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIUpdatableModelProtocol.swift; sourceTree = ""; }; EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldEffectProtocol.swift; sourceTree = ""; }; @@ -1222,7 +1220,6 @@ AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */, 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, - EA797B402909936000DBAFE6 /* VDSTypographyTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2066,7 +2063,6 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( - EA797B3F2909936000DBAFE6 /* VDSTypographyTokens.xcframework */, EAA5EEF628F5D074003B3210 /* VDS.framework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, diff --git a/Scripts/build_aggregate.sh b/Scripts/build_aggregate.sh index 911a4002..84c7f4fb 100755 --- a/Scripts/build_aggregate.sh +++ b/Scripts/build_aggregate.sh @@ -15,10 +15,6 @@ UNIVERSAL_OUTPUTFOLDER="${BUILD_DIR}/universal" # Update to use .xcframework sed -i '' 's|MVMCore.framework \*\/ = {isa.*};|MVMCore.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = MVMCore.xcframework; path = ../SharedFrameworks/MVMCore.xcframework; sourceTree = ""; };|g' ./MVMCoreUI.xcodeproj/project.pbxproj sed -i '' 's/MVMCore.framework/MVMCore.xcframework/g' ./MVMCoreUI.xcodeproj/project.pbxproj - -sed -i '' 's|VDS.framework \*\/ = {isa.*};|VDS.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDS.xcframework; path = ../SharedFrameworks/VDS.xcframework; sourceTree = ""; };|g' ./MVMCoreUI.xcodeproj/project.pbxproj -sed -i '' 's/VDS.framework/VDS.xcframework/g' ./MVMCoreUI.xcodeproj/project.pbxproj - sed -i '' "s|path = \.\.\/SharedFrameworks|path = ${FRAMEWORKS_DIR}|g" ./MVMCoreUI.xcodeproj/project.pbxproj # Build device archive diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index 87b29d03..cc6bc209 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -18,13 +18,8 @@ if [ ! -d $FRAMEWORKS_DIR ]; then mkdir -p $FRAMEWORKS_DIR fi -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/3.1/MVMCore-3.1-Debug-SNAPSHOT.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/MVMCore.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/MVMCore/3.0/MVMCore-3.0-Debug-SNAPSHOT.zip -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDS.xcframework" BPHV_MobileFirst_IOS/com/vzw/hss/myverizon/VDS/1.0/VDS-1.0-Debug-SNAPSHOT.zip - -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip +./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSColorTokens.xcframework" GVJV_VDS_Maven/%40vds-tokens/ios/VDSColorTokens.1.0.6.xcframework.zip ./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSFormControlsTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSFormControlsTokens.1.0.7.xcframework.zip - -./Scripts/download_framework.sh $ARTIFACTORY_URL "$FRAMEWORKS_DIR/VDSTypographyTokens.xcframework" GVJV_VDS_Maven/@vds-tokens/ios/VDSTypographyTokens.2.0.0.xcframework.zip - diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 791e9ead..5d602e0a 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,7 +48,7 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") -CHECKSUM=$(echo "$JSON" | python3 -c 'import sys, json; print (json.load(sys.stdin)["checksums"]["sha1"])') +CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi From 06672f0268a73a6f10b7e70157d1c6c9d4ce44fd Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Tue, 1 Nov 2022 17:29:20 -0400 Subject: [PATCH 29/51] Revert "Merge branch 'feature/vds-toggle' into 'develop'" This reverts commit edfb2c1f366dc4335727396cb3fb0b35dced681f, reversing changes made to 1dc367c4636dfb9db12dd29330d8966619ccfc5f. --- MVMCoreUI.xcodeproj/project.pbxproj | 8 - MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 453 ++++++++++++++---- .../Atomic/Atoms/Selectors/ToggleModel.swift | 66 ++- .../Atomic/Atoms/Views/Label/Label.swift | 31 +- .../Protocols/VDSMoleculeViewProtocol.swift | 32 -- 5 files changed, 450 insertions(+), 140 deletions(-) delete mode 100644 MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index eb0b1ac3..eb5327be 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -598,8 +598,6 @@ EAA0CFAF275E7D8000D65EB0 /* FormFieldEffectProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */; }; EAA0CFB1275E823A00D65EB0 /* HideFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */; }; EAA0CFB3275E831E00D65EB0 /* DisableFormFieldEffectModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */; }; - EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EAA5EEF628F5D074003B3210 /* VDS.framework */; }; - EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */; }; EAB14BC127D935F00012AB2C /* RuleCompareModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */; }; EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; @@ -1202,8 +1200,6 @@ EAA0CFAE275E7D8000D65EB0 /* FormFieldEffectProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormFieldEffectProtocol.swift; sourceTree = ""; }; EAA0CFB0275E823A00D65EB0 /* HideFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideFormFieldEffectModel.swift; sourceTree = ""; }; EAA0CFB2275E831E00D65EB0 /* DisableFormFieldEffectModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisableFormFieldEffectModel.swift; sourceTree = ""; }; - EAA5EEF628F5D074003B3210 /* VDS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = VDS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VDSMoleculeViewProtocol.swift; sourceTree = ""; }; EAB14BC027D935F00012AB2C /* RuleCompareModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleCompareModelProtocol.swift; sourceTree = ""; }; EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; @@ -1218,7 +1214,6 @@ files = ( D29DF0E621E4F3C7003B2FB9 /* MVMCore.framework in Frameworks */, AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */, - EAA5EEF828F5D079003B3210 /* VDS.framework in Frameworks */, 187FEB2A2844D2A600BF29C2 /* VDSFormControlsTokens.xcframework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2063,7 +2058,6 @@ D29DF0E421E4F3C7003B2FB9 /* Frameworks */ = { isa = PBXGroup; children = ( - EAA5EEF628F5D074003B3210 /* VDS.framework */, 187FEB292844D2A600BF29C2 /* VDSFormControlsTokens.xcframework */, AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */, D29DF0E521E4F3C7003B2FB9 /* MVMCore.framework */, @@ -2458,7 +2452,6 @@ D2B9D0E3265EEE9D0084735C /* MoleculeListProtocol.swift */, 011B58EE23A2AA850085F53C /* ModelProtocols */, 27559EFB27D691D3000836C1 /* ViewMaskingProtocol.swift */, - EAA7801F290081320057DFDF /* VDSMoleculeViewProtocol.swift */, ); path = Protocols; sourceTree = ""; @@ -2785,7 +2778,6 @@ 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, D23A90002612347A007E14CE /* PageBehaviorHandlerModelProtocol.swift in Sources */, - EAA78020290081320057DFDF /* VDSMoleculeViewProtocol.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index b220a330..85ad8e9c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -8,8 +8,8 @@ import MVMCore import UIKit -import VDS -import Combine + +public typealias ActionBlockConfirmation = () -> (Bool) /** A custom implementation of Apple's UISwitch. @@ -19,123 +19,402 @@ import Combine Container: The background of the toggle control. Knob: The circular indicator that slides on the container. */ -open class Toggle: ToggleBase, VDSMoleculeViewProtocol { +@objcMembers open class Toggle: Control, MVMCoreUIViewConstrainingProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public var viewModel: ToggleModel! - public var delegateObject: MVMCoreUIDelegateObject? - public var additionalData: [AnyHashable: Any]? - public var valueChangedSubscription: AnyCancellable? { - willSet{ - if let current = valueChangedSubscription { - current.cancel() - } + + /// Holds the on and off colors for the container. + public var containerTintColor: (on: UIColor, off: UIColor) = (on: .mvmGreen, off: .mvmBlack) + + /// Holds the on and off colors for the knob. + public var knobTintColor: (on: UIColor, off: UIColor) = (on: .mvmWhite, off: .mvmWhite) + + /// Holds the on and off colors for the disabled state.. + public var disabledTintColor: (container: UIColor, knob: UIColor) = (container: .mvmCoolGray3, knob: .mvmWhite) + + /// Set this flag to false if you do not want to animate state changes. + public var isAnimated = true + + public var didToggleAction: ActionBlock? + + /// Executes logic before state change. If false, then toggle state will not change and the didToggleAction will not execute. + public var shouldToggleAction: ActionBlockConfirmation? = { + return { true } + }() + + // Sizes are from InVision design specs. + static let containerSize = CGSize(width: 51, height: 31) + static let knobSize = CGSize(width: 28, height: 28) + + private var knobView: View = { + let view = View() + view.backgroundColor = .white + view.layer.cornerRadius = Toggle.getKnobHeight() / 2.0 + return view + }() + + //-------------------------------------------------- + // MARK: - Computed Properties + //-------------------------------------------------- + + open override var isEnabled: Bool { + didSet { + isUserInteractionEnabled = isEnabled + changeStateNoAnimation(isEnabled ? isOn : false) + setToggleAppearanceFromState() + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isEnabled ? "AccToggleHint" : "AccDisabled") } } + + /// Simple means to prevent user interaction with the toggle. + public var isLocked: Bool = false { + didSet { isUserInteractionEnabled = !isLocked } + } + + /// The state on the toggle. Default value: false. + open var isOn: Bool = false { + didSet { + if isAnimated { + UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: { + if self.isOn { + self.knobView.backgroundColor = self.knobTintColor.on + self.backgroundColor = self.containerTintColor.on + + } else { + self.knobView.backgroundColor = self.knobTintColor.off + self.backgroundColor = self.containerTintColor.off + } + }, completion: nil) + + UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: { + self.constrainKnob() + self.knobWidthConstraint?.constant = Self.getKnobWidth() + self.layoutIfNeeded() + }, completion: nil) + + } else { + setToggleAppearanceFromState() + self.constrainKnob() + } + + toggleModel?.selected = isOn + _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) + accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff") + setNeedsLayout() + layoutIfNeeded() + } + } + + public var toggleModel: ToggleModel? { + model as? ToggleModel + } + + //-------------------------------------------------- + // MARK: - Delegate + //-------------------------------------------------- + + private var delegateObject: MVMCoreUIDelegateObject? + + //-------------------------------------------------- + // MARK: - Constraints + //-------------------------------------------------- + + private var knobLeadingConstraint: NSLayoutConstraint? + private var knobTrailingConstraint: NSLayoutConstraint? + private var knobHeightConstraint: NSLayoutConstraint? + private var knobWidthConstraint: NSLayoutConstraint? + private var heightConstraint: NSLayoutConstraint? + private var widthConstraint: NSLayoutConstraint? + + private func constrainKnob() { + + knobLeadingConstraint?.isActive = false + knobTrailingConstraint?.isActive = false + + _ = isOn ? constrainKnobOn() : constrainKnobOff() + + knobTrailingConstraint?.isActive = true + knobLeadingConstraint?.isActive = true + } + + private func constrainKnobOn() { + + knobTrailingConstraint = trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 2) + knobLeadingConstraint = knobView.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor) + } + + private func constrainKnobOff() { + + knobTrailingConstraint = trailingAnchor.constraint(greaterThanOrEqualTo: knobView.trailingAnchor) + knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 2) + } //-------------------------------------------------- // MARK: - Initializers //-------------------------------------------------- + + public override init(frame: CGRect) { + super.init(frame: frame) + } + + public convenience override init() { + self.init(frame: .zero) + } + public convenience init(isOn: Bool) { self.init(frame: .zero) self.isOn = isOn } - open override func initialSetup() { - super.initialSetup() - - publisher(for: .touchUpInside) - .sink {[weak self] toggle in - guard let self = self else { return } - self.toggle() - }.store(in: &subscribers) - - //this is logic that will always need to be run - //and is added into the array of Set - publisher(for: .valueChanged) - .sink {[weak self] _ in - guard let self = self, let viewModel = self.viewModel else { return } - //sync the value on the viewModel - viewModel.selected = self.isOn - - //tell the form you changed - _ = FormValidator.validate(delegate: self.delegateObject?.formHolderDelegate) - - }.store(in: &subscribers) - - //register the defaultActionExecuter - //this can then be overwritten by a subclass - valueChangedSubscription = publisher(for: .valueChanged) - .sink {[weak self] _ in - guard let self = self else { return } - self.executeDefaultAction() - } - - accessibilityLabelEnabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - accessibilityLabelDisabled = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - accessibilityHintEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") - accessibilityHintDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccDisabled") - accessibilityValueEnabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOn") - accessibilityValueDisabled = MVMCoreUIUtility.hardcodedString(withKey: "AccOff") + /// - parameter isOn: Bool to set the state of the toggle. + /// - parameter didToggleAction: A closure which is executed after the toggle changes states. + public convenience init(isOn: Bool = false, didToggleAction: ActionBlock?) { + self.init(frame: .zero) + changeStateNoAnimation(isOn) + self.didToggleAction = didToggleAction } - open func updateView(_ size: CGFloat) {} - - open override func updateView() { - super.updateView() - //we want to overwrite the VDS color that is set in the ToggleBase - //for surface since the Atomic controls doesn't look at - //surface today for its views. We just want to show whatever - //the current parent's background color. - backgroundColor = .clear + /// - parameter shouldToggleAction: Takes a closure that returns a boolean. + /// - parameter didToggleAction: A closure which is executed after the toggle changes states. + public convenience init(shouldToggleAction: ActionBlockConfirmation?, didToggleAction: ActionBlock?) { + self.init(frame: .zero) + self.didToggleAction = didToggleAction + self.shouldToggleAction = shouldToggleAction } - open func viewModelDidUpdate() { - guard let viewModel else { return } + public required init?(coder: NSCoder) { + super.init(coder: coder) + fatalError("Toggle does not support xib.") + } + + //-------------------------------------------------- + // MARK: - Lifecycle + //-------------------------------------------------- + + public override func updateView(_ size: CGFloat) { + super.updateView(size) - //set properties from the viewModel change that came in - if let accessibilityText = viewModel.accessibilityText { - accessibilityLabelEnabled = accessibilityText - accessibilityLabelDisabled = accessibilityText - } - isAnimated = viewModel.animated + heightConstraint?.constant = Self.getContainerHeight() + widthConstraint?.constant = Self.getContainerWidth() + + knobHeightConstraint?.constant = Self.getKnobHeight() + knobWidthConstraint?.constant = Self.getKnobWidth() + + layer.cornerRadius = Self.getContainerHeight() / 2.0 + knobView.layer.cornerRadius = Self.getKnobHeight() / 2.0 + + changeStateNoAnimation(isOn) + } + + public override func setupView() { + super.setupView() + + isAccessibilityElement = true + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") + accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + accessibilityTraits = .button - //send toggle.model to the Form - FormValidator.setupValidation(for: viewModel, delegate: delegateObject?.formHolderDelegate) + heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height) + heightConstraint?.isActive = true + + widthConstraint = widthAnchor.constraint(equalToConstant: Self.containerSize.width) + widthConstraint?.isActive = true + + layer.cornerRadius = Self.getContainerHeight() / 2.0 + backgroundColor = containerTintColor.off + + addSubview(knobView) + + knobHeightConstraint = knobView.heightAnchor.constraint(equalToConstant: Self.knobSize.height) + knobHeightConstraint?.isActive = true + knobWidthConstraint = knobView.widthAnchor.constraint(equalToConstant: Self.knobSize.width) + knobWidthConstraint?.isActive = true + knobView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true + knobView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true + bottomAnchor.constraint(greaterThanOrEqualTo: knobView.bottomAnchor).isActive = true + + constrainKnobOff() } - public func executeDefaultAction() { - guard let viewModel else { return } - if viewModel.action != nil || viewModel.alternateAction != nil { - var action: ActionModelProtocol? - if isOn { - action = viewModel.action - } else { - action = viewModel.alternateAction ?? viewModel.action - } - if let action { - MVMCoreUIActionHandler.performActionUnstructured(with: action, - sourceModel: viewModel, - additionalData: additionalData, - delegateObject: delegateObject) + public override func reset() { + super.reset() + + backgroundColor = containerTintColor.off + knobView.backgroundColor = knobTintColor.off + accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + isAnimated = true + didToggleAction = nil + shouldToggleAction = { return true } + } + + class func getContainerWidth() -> CGFloat { + let containerWidth = Self.containerSize.width + return (MFSizeObject(standardSize: containerWidth, standardiPadPortraitSize: CGFloat(Self.containerSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerWidth + } + + class func getContainerHeight() -> CGFloat { + let containerHeight = Self.containerSize.height + return (MFSizeObject(standardSize: containerHeight, standardiPadPortraitSize: CGFloat(Self.containerSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? containerHeight + } + + class func getKnobWidth() -> CGFloat { + let knobWidth = Self.knobSize.width + return (MFSizeObject(standardSize: knobWidth, standardiPadPortraitSize: CGFloat(Self.knobSize.width * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobWidth + } + + class func getKnobHeight() -> CGFloat { + let knobHeight = Self.knobSize.width + return (MFSizeObject(standardSize: knobHeight, standardiPadPortraitSize: CGFloat(Self.knobSize.height * 1.5)))?.getValueBasedOnApplicationWidth() ?? knobHeight + } + + //-------------------------------------------------- + // MARK: - Actions + //-------------------------------------------------- + + open override func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?) { + super.sendAction(action, to: target, for: event) + toggleAndAction() + } + + open override func sendActions(for controlEvents: UIControl.Event) { + super.sendActions(for: controlEvents) + toggleAndAction() + } + + /// This will toggle the state of the Toggle and execute the actionBlock if provided. + public func toggleAndAction() { + + if let result = shouldToggleAction?(), result { + isOn.toggle() + didToggleAction?() + } + } + + private func changeStateNoAnimation(_ state: Bool) { + + // Hold state in case User wanted isAnimated to remain off. + let isAnimatedState = isAnimated + + isAnimated = false + isOn = state + isAnimated = isAnimatedState + } + + override open func accessibilityActivate() -> Bool { + // Hold state in case User wanted isAnimated to remain off. + guard isUserInteractionEnabled else { return false } + let isAnimatedState = isAnimated + isAnimated = false + sendActions(for: .touchUpInside) + isAnimated = isAnimatedState + return true + } + + //-------------------------------------------------- + // MARK: - UIResponder + //-------------------------------------------------- + + open override func touchesBegan(_ touches: Set, with event: UIEvent?) { + + UIView.animate(withDuration: 0.1, animations: { + self.knobWidthConstraint?.constant += PaddingOne + self.layoutIfNeeded() + }) + } + + public override func touchesEnded(_ touches: Set, with event: UIEvent?) { + + knobReformAnimation() + + // Action only occurs of the user lifts up from withing acceptable region of the toggle. + guard let coordinates = touches.first?.location(in: self), + coordinates.x > -20, + coordinates.x < bounds.width + 20, + coordinates.y > -20, + coordinates.y < bounds.height + 20 + else { return } + + sendActions(for: .touchUpInside) + } + + public func touchesCancelled(_ touches: Set, with event: UIEvent) { + + knobReformAnimation() + sendActions(for: .touchCancel) + } + + //-------------------------------------------------- + // MARK: - Animations + //-------------------------------------------------- + + public func setToggleAppearanceFromState() { + + backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container + knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob + } + + public func knobReformAnimation() { + + if isAnimated { + UIView.animate(withDuration: 0.1, animations: { + self.knobWidthConstraint?.constant = Self.getKnobWidth() + self.layoutIfNeeded() + }, completion: nil) + + } else { + knobWidthConstraint?.constant = Self.getKnobWidth() + layoutIfNeeded() + } + } + + // MARK:- MoleculeViewProtocol + public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + self.delegateObject = delegateObject + + guard let model = model as? ToggleModel else { return } + + FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) + + containerTintColor.on = model.onTintColor.uiColor + containerTintColor.off = model.offTintColor.uiColor + knobTintColor.on = model.onKnobTintColor.uiColor + knobTintColor.off = model.offKnobTintColor.uiColor + isOn = model.selected + changeStateNoAnimation(isOn) + isAnimated = model.animated + isEnabled = model.enabled && !model.readOnly + + if let accessibileString = model.accessibilityText { + accessibilityLabel = accessibileString + } + + if model.action != nil || model.alternateAction != nil { + didToggleAction = { [weak self] in + guard let self = self else { return } + if self.isOn { + if let action = model.action { + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) + } + } else { + if let action = model.alternateAction ?? model.action { + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) + } + } } } } - //Return the same height as the internal ToggleBase.toggleContainerSize.height - //since this is a class func, we can't reference it directly - public static func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return 44 + public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + Self.getContainerHeight() } - } // MARK: - MVMCoreUIViewConstrainingProtocol -extension Toggle: MVMCoreUIViewConstrainingProtocol { +extension Toggle { public func needsToBeConstrained() -> Bool { true } public func horizontalAlignment() -> UIStackView.Alignment { .trailing } } - diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index bcc11d8b..e8d50851 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -13,15 +13,20 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- public static var identifier: String = "toggle" - public var backgroundColor: Color? //not used - + public var accessibilityIdentifier: String? + public var backgroundColor: Color? public var selected: Bool = false + public var animated: Bool = true public var enabled: Bool = true public var readOnly: Bool = false - public var animated: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? + public var onTintColor: Color = Color(uiColor: .mvmGreen) + public var offTintColor: Color = Color(uiColor: .mvmBlack) + public var onKnobTintColor: Color = Color(uiColor: .mvmWhite) + public var offKnobTintColor: Color = Color(uiColor: .mvmWhite) + public var fieldKey: String? public var groupName: String = FormValidator.defaultGroupName public var baseValue: AnyHashable? @@ -29,16 +34,22 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- - + private enum CodingKeys: String, CodingKey { case moleculeName case state + case animated case enabled case readOnly - case animated case action + case backgroundColor + case accessibilityIdentifier case alternateAction case accessibilityText + case onTintColor + case offTintColor + case onKnobTintColor + case offKnobTintColor case fieldKey case groupName } @@ -64,7 +75,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { //-------------------------------------------------- public init(_ state: Bool) { - selected = state + self.selected = state baseValue = state } @@ -76,31 +87,62 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { - selected = state + self.selected = state } + + if let animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) { + self.animated = animated + } + action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) + + if let onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) { + self.onTintColor = onTintColor + } + + if let offTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offTintColor) { + self.offTintColor = offTintColor + } + + if let onKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onKnobTintColor) { + self.onKnobTintColor = onKnobTintColor + } + + if let offKnobTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .offKnobTintColor) { + self.offKnobTintColor = offKnobTintColor + } + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) + baseValue = selected fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey) - groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) ?? FormValidator.defaultGroupName + if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { + self.groupName = groupName + } enabled = try typeContainer.decodeIfPresent(Bool.self, forKey: .enabled) ?? true readOnly = try typeContainer.decodeIfPresent(Bool.self, forKey: .readOnly) ?? false - animated = try typeContainer.decodeIfPresent(Bool.self, forKey: .animated) ?? true - } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) - try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encode(moleculeName, forKey: .moleculeName) try container.encode(selected, forKey: .state) + try container.encode(animated, forKey: .animated) try container.encode(enabled, forKey: .enabled) + try container.encode(onTintColor, forKey: .onTintColor) + try container.encode(onKnobTintColor, forKey: .onKnobTintColor) + try container.encode(onKnobTintColor, forKey: .onKnobTintColor) + try container.encode(offKnobTintColor, forKey: .offKnobTintColor) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) try container.encode(readOnly, forKey: .readOnly) - try container.encode(animated, forKey: .animated) } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 9e5881a4..9ce55537 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -8,7 +8,6 @@ // import MVMCore -import VDS public typealias ActionBlock = () -> () @@ -738,6 +737,36 @@ public typealias ActionBlock = () -> () clauses.append(ActionableClause(range: range, actionBlock: actionBlock, accessibilityID: accessibleAction?.hash ?? -1)) } + /** + Provides a text container and layout manager of how the text would appear on screen. + They are used in tandem to derive low-level TextKit results of the label. + */ + public func abstractTextContainer() -> (NSTextContainer, NSLayoutManager, NSTextStorage)? { + + // Must configure the attributed string to translate what would appear on screen to accurately analyze. + guard let attributedText = attributedText else { return nil } + + let paragraph = NSMutableParagraphStyle() + paragraph.alignment = textAlignment + + let stagedAttributedString = NSMutableAttributedString(attributedString: attributedText) + stagedAttributedString.addAttributes([NSAttributedString.Key.paragraphStyle: paragraph], range: NSRange(location: 0, length: attributedText.string.count)) + + let textStorage = NSTextStorage(attributedString: stagedAttributedString) + let layoutManager = NSLayoutManager() + let textContainer = NSTextContainer(size: .zero) + + layoutManager.addTextContainer(textContainer) + textStorage.addLayoutManager(layoutManager) + + textContainer.lineFragmentPadding = 0.0 + textContainer.lineBreakMode = lineBreakMode + textContainer.maximumNumberOfLines = numberOfLines + textContainer.size = bounds.size + + return (textContainer, layoutManager, textStorage) + } + public static func boundingRect(forCharacterRange range: NSRange, in label: Label) -> CGRect { guard let abstractContainer = label.abstractTextContainer() else { return CGRect() } diff --git a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift b/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift deleted file mode 100644 index 41349f2c..00000000 --- a/MVMCoreUI/Atomic/Protocols/VDSMoleculeViewProtocol.swift +++ /dev/null @@ -1,32 +0,0 @@ -// -// VDSMoleculeViewProtocol.swift -// MVMCoreUI -// -// Created by Matt Bruce on 10/19/22. -// Copyright © 2022 Verizon Wireless. All rights reserved. -// - -import Foundation -import MVMCore - -///----------------------------------------------------------------------------- -///MARK: -- VDSMoleculeViewProtocol (Contract between VDS -> Atomic) -///----------------------------------------------------------------------------- -public protocol VDSMoleculeViewProtocol: MoleculeViewProtocol, MVMCoreViewProtocol { - associatedtype ViewModel: MoleculeModelProtocol - var viewModel: ViewModel! { get set } - var delegateObject: MVMCoreUIDelegateObject? { get set } - var additionalData: [AnyHashable: Any]? { get set } - func viewModelDidUpdate() -} - -extension VDSMoleculeViewProtocol { - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let castedModel = model as? ViewModel else { return } - self.delegateObject = delegateObject - self.additionalData = additionalData - viewModel = castedModel - viewModelDidUpdate() - } -} - From b250e141defbcfdadecd5b5376de9d6d820d4171 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 1 Nov 2022 17:09:01 -0500 Subject: [PATCH 30/51] script update for python 3 Signed-off-by: Matt Bruce --- Scripts/download_framework.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/download_framework.sh b/Scripts/download_framework.sh index 5d602e0a..791e9ead 100755 --- a/Scripts/download_framework.sh +++ b/Scripts/download_framework.sh @@ -48,7 +48,7 @@ fi echo -e "Getting checksums..." echo -e "URL: ${URL}/api/storage/${REMOTEPATH}" JSON=$(curl --header "X-JFrog-Art-Api: ${ARTIFACTORY_APIKEY}" -X GET "${URL}/api/storage/${REMOTEPATH}") -CHECKSUM=$(echo "$JSON" | python -c 'import sys, json; print json.load(sys.stdin)["checksums"]["sha1"]') +CHECKSUM=$(echo "$JSON" | python3 -c 'import sys, json; print (json.load(sys.stdin)["checksums"]["sha1"])') if [[ -z "$CHECKSUM" ]]; then exit_with_error "No Checksum found in json: ${JSON}" fi From af2360c13a1b12f071adcd3d9d76cfed91e494ae Mon Sep 17 00:00:00 2001 From: "Murugan, Vimal" Date: Tue, 8 Nov 2022 18:41:27 +0530 Subject: [PATCH 31/51] fix for CXTDT_344190 --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 9e5881a4..ec94149b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -757,8 +757,10 @@ public typealias ActionBlock = () -> () extension Label { public func reset() { - text = nil + //Weird issue. when cell reuse. text style is not getting reset.Fix for:CXTDT-344190 + //We need to reset the attribute text first and then text. Its working fine attributedText = nil + text = nil hero = nil textAlignment = .left originalAttributedString = nil From 13fd2015e5b857e735c462c96e8e358ad9750304 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Wed, 9 Nov 2022 21:12:58 -0500 Subject: [PATCH 32/51] prevent crashes when ipads attempt to show an actionsheet without a source rect --- MVMCoreUI/Alerts/MVMCoreAlertHandler.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m index 75dab8f1..16fb1f4a 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m @@ -83,6 +83,11 @@ [self removeAllAlertViews]; } + if (alertStyle == UIAlertControllerStyleActionSheet && UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) { + // ActionSheets are not supported on iPad interfaces without a source rect (i.e. a source element) which isn't currently supported for our generic handling. + alertStyle = UIAlertControllerStyleAlert; + } + // Create the alert. Adds the actions one by one. MVMCoreAlertController *alertController = [MVMCoreAlertController alertControllerWithTitle:(title ?: @"") message:message preferredStyle:alertStyle]; for (NSUInteger i = 0; i < [actions count]; i++) { From 34ef2e5c8196746d19b1039c1d9a40c34fd4af64 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Mon, 21 Nov 2022 19:22:40 +0530 Subject: [PATCH 33/51] Added accessibilityText for ListOneColumnTextWithWhitespaceDividerTall DOPMO-153745 --- ...eColumnTextWithWhitespaceDividerTall.swift | 34 +++++++++++-------- ...mnTextWithWhitespaceDividerTallModel.swift | 7 +++- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index 62ee43f5..4a6e7c96 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -17,6 +17,7 @@ import Foundation public var stack: Stack public let headline = Label(fontStyle: .BoldTitleMedium) public let body = Label(fontStyle: .RegularBodySmall) + public var accessibilityText: String? = nil //-------------------------------------------------- // MARK: - Initializers @@ -41,7 +42,6 @@ import Foundation addMolecule(stack) stack.restack() isAccessibilityElement = true - updateAccessibilityLabel() } //-------------------------------------------------- @@ -53,7 +53,8 @@ import Foundation guard let model = model as? ListOneColumnTextWithWhitespaceDividerTallModel else { return } stack.updateContainedMolecules(with: [model.headline, model.body], delegateObject, additionalData) - updateAccessibilityLabel() + + updateAccessibilityLabel(model: model) } open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { @@ -70,18 +71,23 @@ import Foundation // MARK: - Accessibility //---------------------------------------------------- - func updateAccessibilityLabel() { - - var message = "" - - if let headlineLabel = headline.text, !headlineLabel.isEmpty { - message += headlineLabel + ", " + func updateAccessibilityLabel(model: ListOneColumnTextWithWhitespaceDividerTallModel) { + if let accessibilityText = model.accessibilityText { + accessibilityLabel = accessibilityText + }else { + var message = "" + + if let headlineLabel = headline.text, !headlineLabel.isEmpty { + message += headlineLabel + ", " + } + + if let bodyLabel = body.text, !bodyLabel.isEmpty { + message += bodyLabel + } + + accessibilityLabel = message } - - if let bodyLabel = body.text, !bodyLabel.isEmpty { - message += bodyLabel - } - - accessibilityLabel = message + } + } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift index c713b0d2..ed233607 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -17,14 +17,16 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol public static var identifier: String = "list1CTxtDiv2" public var headline: LabelModel public var body: LabelModel? + public var accessibilityText: String? //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(headline: LabelModel, body: LabelModel?) { + public init(headline: LabelModel, body: LabelModel?, accessibilityText: String?) { self.headline = headline self.body = body + self.accessibilityText = accessibilityText super.init() } @@ -45,6 +47,7 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol case moleculeName case headline case body + case accessibilityText } //-------------------------------------------------- @@ -55,6 +58,7 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol let typeContainer = try decoder.container(keyedBy: CodingKeys.self) headline = try typeContainer.decode(LabelModel.self, forKey: .headline) body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) try super.init(from: decoder) } @@ -64,5 +68,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol try container.encode(moleculeName, forKey: .moleculeName) try container.encode(headline, forKey: .headline) try container.encodeIfPresent(body, forKey: .body) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } } From dce172bb640b51a65236cb1f29012e831e1701d7 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Mon, 28 Nov 2022 14:57:53 +0530 Subject: [PATCH 34/51] CXTDT-352289 - disabled clipboard actions --- .../Atoms/FormFields/TextFields/TextEntryField.swift | 1 + .../FormFields/TextFields/TextEntryFieldModel.swift | 7 +++++++ MVMCoreUI/BaseClasses/TextField.swift | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift index 07260ac1..18749c8a 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryField.swift @@ -338,6 +338,7 @@ import UIKit placeholder = model.placeholder textField.shouldMaskWhileRecording = model.shouldMaskRecordedView ?? true + textField.enableClipboardActions = model.enableClipboardActions switch model.type { case .password, .secure: diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift index 7d2eb987..053a5ac5 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextEntryFieldModel.swift @@ -37,6 +37,7 @@ public var clearTextOnTap: Bool = false public var displayFormat: String? public var displayMask: String? + public var enableClipboardActions: Bool = true //-------------------------------------------------- // MARK: - Initializers @@ -112,6 +113,7 @@ case clearTextOnTap case displayFormat case displayMask + case enableClipboardActions } //-------------------------------------------------- @@ -143,6 +145,10 @@ if let textAlignment = try typeContainer.decodeIfPresent(NSTextAlignment.self, forKey: .textAlignment) { self.textAlignment = textAlignment } + + if let enableClipboardActions = try typeContainer.decodeIfPresent(Bool.self, forKey: .enableClipboardActions) { + self.enableClipboardActions = enableClipboardActions + } } open override func encode(to encoder: Encoder) throws { @@ -157,5 +163,6 @@ try container.encode(enabledTextColor, forKey: .enabledTextColor) try container.encode(disabledTextColor, forKey: .disabledTextColor) try container.encode(clearTextOnTap, forKey: .clearTextOnTap) + try container.encode(enableClipboardActions, forKey: .enableClipboardActions) } } diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index 306b363f..1f5d1b09 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -23,7 +23,7 @@ public protocol TextInputDidDeleteProtocol: AnyObject { /// Set to true to hide the blinking textField cursor. public var hideBlinkingCaret = false - + public var enableClipboardActions: Bool = true public var shouldMaskWhileRecording: Bool = true //-------------------------------------------------- @@ -74,6 +74,14 @@ public protocol TextInputDidDeleteProtocol: AnyObject { super.deleteBackward() didDeleteDelegate?.textInputDidDelete() } + + open override func buildMenu(with builder: UIMenuBuilder) { + defer { super.buildMenu(with: builder) } + guard !enableClipboardActions else { return } + builder.remove(menu: .lookup) + } + + open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { enableClipboardActions } } /// MARK:- MVMCoreViewProtocol From 8858018620b2437f3490355dcc5d44e809c3fe29 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Fri, 2 Dec 2022 13:31:30 +0530 Subject: [PATCH 35/51] removed unused code --- MVMCoreUI/BaseClasses/TextField.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index 1f5d1b09..00a81464 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -75,12 +75,6 @@ public protocol TextInputDidDeleteProtocol: AnyObject { didDeleteDelegate?.textInputDidDelete() } - open override func buildMenu(with builder: UIMenuBuilder) { - defer { super.buildMenu(with: builder) } - guard !enableClipboardActions else { return } - builder.remove(menu: .lookup) - } - open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { enableClipboardActions } } From 4963c311d44a4407678a06637f9308ffbc583d46 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Fri, 2 Dec 2022 13:52:59 +0530 Subject: [PATCH 36/51] access specifier changed --- MVMCoreUI/BaseClasses/TextField.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseClasses/TextField.swift b/MVMCoreUI/BaseClasses/TextField.swift index 00a81464..34e301a3 100644 --- a/MVMCoreUI/BaseClasses/TextField.swift +++ b/MVMCoreUI/BaseClasses/TextField.swift @@ -93,7 +93,7 @@ extension TextField: MVMCoreViewProtocol { /// MARK:- MoleculeViewProtocol extension TextField: MoleculeViewProtocol { - open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { if let color = model.backgroundColor?.uiColor { backgroundColor = color From 0f8c21025d04290834ec794487a092010b2459c5 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Fri, 2 Dec 2022 18:44:59 -0500 Subject: [PATCH 37/51] Add navigation bar model tracking to PageMoleculeTransformationBehavior. Update ScreenRecordingMaskingBehavior to consume. Enhance MDN regex. --- .../Protocols/PageBehaviorProtocol.swift | 4 ++ .../NavigationController.swift | 38 ++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 3420299d..10dc3020 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -30,6 +30,8 @@ public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) + func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) + func didSetupNavigationBar(view: UINavigationBar, withModel: NavigationItemModelProtocol) } public extension PageMoleculeTransformationBehavior { @@ -37,6 +39,8 @@ public extension PageMoleculeTransformationBehavior { func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) {} func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) {} func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {} + func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {} + func didSetupNavigationBar(view: UINavigationBar, withModel: NavigationItemModelProtocol) {} } public protocol PageVisibilityBehavior: PageBehaviorProtocol { diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index 9b4b332a..329ff423 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -70,30 +70,42 @@ extension NavigationController: MVMCoreViewManagerProtocol { public func newDataReceived(in viewController: UIViewController) { if isDisplayed(viewController: viewController), - let topViewController = topViewController, let model = getNavigationModel(from: viewController) { - setNavigationItem(with: model, for: topViewController) - setNavigationBarUI(with: model) - - navigationBar.setNeedsLayout() - navigationBar.layoutIfNeeded() + updateNavigationView(with: model, for: viewController) } manager?.newDataReceived?(in: viewController) } public func willDisplay(_ viewController: UIViewController) { - if let topViewController = topViewController, - isDisplayed(viewController: viewController), + if isDisplayed(viewController: viewController), let model = getNavigationModel(from: viewController) { - setNavigationItem(with: model, for: topViewController) - setNavigationBarUI(with: model) - - navigationBar.setNeedsLayout() - navigationBar.layoutIfNeeded() + updateNavigationView(with: model, for: viewController) } manager?.willDisplay?(viewController) } + private func updateNavigationView(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + guard let topViewController = topViewController else { return } + + if let pageBehaviorController = viewController as? PageBehaviorHandlerProtocol { + pageBehaviorController.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.willSetupNavigationBar(with: model, updating: navigationBar) + } + } + + setNavigationItem(with: model, for: topViewController) + setNavigationBarUI(with: model) + + navigationBar.setNeedsLayout() + navigationBar.layoutIfNeeded() + + if let pageBehaviorController = viewController as? PageBehaviorHandlerProtocol { + pageBehaviorController.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.didSetupNavigationBar(view: navigationBar, withModel: model) + } + } + } + public func displayedViewController(_ viewController: UIViewController) { manager?.displayedViewController?(viewController) } From b7413d536bda45ab3be72f65aec5b32ae13c68bb Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 5 Dec 2022 19:58:38 -0500 Subject: [PATCH 38/51] shifted behavior calls to extension for better support. added molecular setup callback for navigation titleView. --- .../Protocols/PageBehaviorProtocol.swift | 4 +-- .../NavigationController.swift | 14 +------- .../UINavigationController+Extension.swift | 34 +++++++++++++++---- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 10dc3020..d5f65323 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -31,7 +31,7 @@ public protocol PageMoleculeTransformationBehavior: PageBehaviorProtocol { func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) - func didSetupNavigationBar(view: UINavigationBar, withModel: NavigationItemModelProtocol) + func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol) } public extension PageMoleculeTransformationBehavior { @@ -40,7 +40,7 @@ public extension PageMoleculeTransformationBehavior { func willSetupMolecule(with model: MoleculeModelProtocol, updating view: MoleculeViewProtocol?) {} func didSetupMolecule(view: MoleculeViewProtocol, withModel: MoleculeModelProtocol) {} func willSetupNavigationBar(with model: NavigationItemModelProtocol, updating view: UINavigationBar) {} - func didSetupNavigationBar(view: UINavigationBar, withModel: NavigationItemModelProtocol) {} + func didSetupNavigationBar(view: UINavigationBar, with model: NavigationItemModelProtocol) {} } public protocol PageVisibilityBehavior: PageBehaviorProtocol { diff --git a/MVMCoreUI/Containers/NavigationController/NavigationController.swift b/MVMCoreUI/Containers/NavigationController/NavigationController.swift index 329ff423..eb43201a 100644 --- a/MVMCoreUI/Containers/NavigationController/NavigationController.swift +++ b/MVMCoreUI/Containers/NavigationController/NavigationController.swift @@ -87,23 +87,11 @@ extension NavigationController: MVMCoreViewManagerProtocol { private func updateNavigationView(with model: NavigationItemModelProtocol, for viewController: UIViewController) { guard let topViewController = topViewController else { return } - if let pageBehaviorController = viewController as? PageBehaviorHandlerProtocol { - pageBehaviorController.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in - behavior.willSetupNavigationBar(with: model, updating: navigationBar) - } - } - - setNavigationItem(with: model, for: topViewController) + setNavigationItem(with: model, for: topViewController, coordinatingWith: viewController as? PageBehaviorHandlerProtocol) setNavigationBarUI(with: model) navigationBar.setNeedsLayout() navigationBar.layoutIfNeeded() - - if let pageBehaviorController = viewController as? PageBehaviorHandlerProtocol { - pageBehaviorController.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in - behavior.didSetupNavigationBar(view: navigationBar, withModel: model) - } - } } public func displayedViewController(_ viewController: UIViewController) { diff --git a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift index e63028d4..9a0665b9 100644 --- a/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift +++ b/MVMCoreUI/Containers/NavigationController/UINavigationController+Extension.swift @@ -11,13 +11,24 @@ import Foundation public extension UINavigationController { /// Convenience function for setting the navigation item. - func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + func setNavigationItem(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) { + + let behaviorHandler = pageBehaviorController ?? viewController as? PageBehaviorHandlerProtocol; + + behaviorHandler?.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.willSetupNavigationBar(with: model, updating: navigationBar) + } + viewController.navigationItem.title = model.title viewController.navigationItem.accessibilityLabel = model.title viewController.navigationItem.hidesBackButton = model.hidesSystemBackButton viewController.navigationItem.leftItemsSupplementBackButton = !model.hidesSystemBackButton setNavigationButtons(with: model, for: viewController) - setNavigationTitleView(with: model, for: viewController) + setNavigationTitleView(with: model, for: viewController, coordinatingWith: pageBehaviorController) + + behaviorHandler?.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.didSetupNavigationBar(view: navigationBar, with: model) + } } /// Convenience function for setting the navigation buttons. @@ -48,11 +59,22 @@ public extension UINavigationController { } /// Convenience function for setting the navigation titleView. - func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController) { + func setNavigationTitleView(with model: NavigationItemModelProtocol, for viewController: UIViewController, coordinatingWith pageBehaviorController: PageBehaviorHandlerProtocol? = nil) { + guard let titleViewModel = model.titleView else { return } + let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject - if let titleViewModel = model.titleView, - let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) { - viewController.navigationItem.titleView = molecule + + let behaviorHandler = pageBehaviorController ?? viewController as? PageBehaviorHandlerProtocol; + behaviorHandler?.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.willSetupMolecule(with: titleViewModel, updating: nil) + } + + guard let molecule = ModelRegistry.createMolecule(titleViewModel, delegateObject: delegate, additionalData: nil) else { return } + + viewController.navigationItem.titleView = molecule + + behaviorHandler?.executeBehaviors { (behavior: PageMoleculeTransformationBehavior) in + behavior.didSetupMolecule(view: molecule, withModel: titleViewModel) } } From a72f3cc3c1542a2d0fb2d2994b0f32d50d1309f9 Mon Sep 17 00:00:00 2001 From: Nandhini Rajendran Date: Fri, 9 Dec 2022 12:34:06 +0530 Subject: [PATCH 39/51] refactor to add resetAttributeStyle --- .../Atomic/Atoms/Views/Label/Label.swift | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 225d39c1..059c5637 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -241,18 +241,7 @@ public typealias ActionBlock = () -> () case left } - public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) { - - clauses = [] - text = nil - attributedText = nil - originalAttributedString = nil - shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false - - guard let labelModel = model as? LabelModel else { return } - - text = labelModel.text - + @objc public func resetAttributeStyle() { /* * This is to address a reuse issue with iOS 13 and up. * Even if you set text & attributedText to nil, the moment you set text with a value, @@ -274,6 +263,21 @@ public typealias ActionBlock = () -> () self.attributedText = attributedString } + } + + public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject? = nil, _ additionalData: [AnyHashable: Any]? = nil) { + + clauses = [] + text = nil + attributedText = nil + originalAttributedString = nil + shouldMaskWhileRecording = model.shouldMaskRecordedView ?? false + + guard let labelModel = model as? LabelModel else { return } + + text = labelModel.text + + resetAttributeStyle() hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) @@ -786,10 +790,8 @@ public typealias ActionBlock = () -> () extension Label { public func reset() { - //Weird issue. when cell reuse. text style is not getting reset.Fix for:CXTDT-344190 - //We need to reset the attribute text first and then text. Its working fine - attributedText = nil text = nil + attributedText = nil hero = nil textAlignment = .left originalAttributedString = nil From e66924dc1f9ce001402c60ea5f57c257d431ccd7 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Mon, 12 Dec 2022 13:33:10 +0530 Subject: [PATCH 40/51] added setDefaults func --- .../TextFields/Dropdown Fields/BaseDropdownFieldModel.swift | 5 +++++ .../Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownFieldModel.swift index 39701016..6c2131ac 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownFieldModel.swift @@ -26,6 +26,11 @@ case action } + open override func setDefaults() { + super.setDefaults() + enableClipboardActions = false + } + //-------------------------------------------------- // MARK: - Codec //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift index 4e35ce30..7b3eee03 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/EntryFieldModel.swift @@ -83,6 +83,9 @@ import Foundation case shouldMaskRecordedView } + /// Sets the default values. Should be called on init. + open func setDefaults() { } + //-------------------------------------------------- // MARK: - Validation Methods //-------------------------------------------------- @@ -119,6 +122,7 @@ import Foundation baseValue = text self.titleStateLabel = FormLabelModel(text: "") self.feedbackStateLabel = FormLabelModel(text: "") + setDefaults() } //-------------------------------------------------- @@ -157,6 +161,7 @@ import Foundation self.feedbackStateLabel = FormLabelModel(model: LabelModel(text: feedback ?? "", fontStyle: FormLabelModel.defaultFontStyle, textColor: Color(uiColor: .mvmCoolGray6))) + setDefaults() } public func encode(to encoder: Encoder) throws { From 7494d8664a171380f5ae2b9316f24738e43e1770 Mon Sep 17 00:00:00 2001 From: Kyle Matthew Hedden Date: Mon, 12 Dec 2022 13:18:17 -0500 Subject: [PATCH 41/51] add the provided color name to the error string --- MVMCoreUI/CustomPrimitives/Color.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/CustomPrimitives/Color.swift b/MVMCoreUI/CustomPrimitives/Color.swift index 42c7a600..b251f778 100644 --- a/MVMCoreUI/CustomPrimitives/Color.swift +++ b/MVMCoreUI/CustomPrimitives/Color.swift @@ -106,7 +106,7 @@ public final class Color: Codable { if colorString.hasPrefix("#") { hex = colorString.replacingOccurrences(of: "#", with: "") } else { - guard let hexString = UIColor.names[colorString]?.hex else { throw ColorError.badName(reason: "Check the spelling of your color.") } + guard let hexString = UIColor.names[colorString]?.hex else { throw ColorError.badName(reason: "Check the spelling of your color: \(colorString)") } hex = hexString.replacingOccurrences(of: "#", with: "") name = colorString } From 7ae5cbfc8a028251bebe7de0727ee571cedba2ac Mon Sep 17 00:00:00 2001 From: teegsh2 Date: Tue, 13 Dec 2022 09:52:47 +0530 Subject: [PATCH 42/51] unmask NavBar SR --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index c6c64f3a..d9c606e4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -363,7 +363,7 @@ import MVMCore super.viewWillDisappear(animated) executeBehaviors { [weak self] (behavior: PageVisibilityBehavior) in - behavior.willHidePage(self?.delegateObjectIVar) + behavior.willShowPage(self?.delegateObjectIVar) } } From 9dd400f894b5742003341591a9e049e42a3aa302 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Tue, 20 Dec 2022 19:58:30 +0530 Subject: [PATCH 43/51] Accessibility fix for PRODDEF-1201 Accessibility fix to provide custom accessibilityText for list1CTxtDiv3 --- ...eColumnTextWithWhitespaceDividerTall.swift | 26 +++++++------------ ...mnTextWithWhitespaceDividerTallModel.swift | 5 ---- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index 4a6e7c96..d93cd0f2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -17,7 +17,6 @@ import Foundation public var stack: Stack public let headline = Label(fontStyle: .BoldTitleMedium) public let body = Label(fontStyle: .RegularBodySmall) - public var accessibilityText: String? = nil //-------------------------------------------------- // MARK: - Initializers @@ -72,22 +71,17 @@ import Foundation //---------------------------------------------------- func updateAccessibilityLabel(model: ListOneColumnTextWithWhitespaceDividerTallModel) { - if let accessibilityText = model.accessibilityText { - accessibilityLabel = accessibilityText - }else { - var message = "" - - if let headlineLabel = headline.text, !headlineLabel.isEmpty { - message += headlineLabel + ", " - } - - if let bodyLabel = body.text, !bodyLabel.isEmpty { - message += bodyLabel - } - - accessibilityLabel = message + + var message = "" + + if let headlineLabel = model.headline.accessibilityText ?? headline.text, !headlineLabel.isEmpty { + message += headlineLabel + ", " } - } + if let bodyLabel = model.body?.accessibilityText ?? body.text, !bodyLabel.isEmpty { + message += bodyLabel + } + accessibilityLabel = message + } } diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift index ed233607..4527dba0 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -17,7 +17,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol public static var identifier: String = "list1CTxtDiv2" public var headline: LabelModel public var body: LabelModel? - public var accessibilityText: String? //-------------------------------------------------- // MARK: - Initializer @@ -26,7 +25,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol public init(headline: LabelModel, body: LabelModel?, accessibilityText: String?) { self.headline = headline self.body = body - self.accessibilityText = accessibilityText super.init() } @@ -47,7 +45,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol case moleculeName case headline case body - case accessibilityText } //-------------------------------------------------- @@ -58,7 +55,6 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol let typeContainer = try decoder.container(keyedBy: CodingKeys.self) headline = try typeContainer.decode(LabelModel.self, forKey: .headline) body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) - accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) try super.init(from: decoder) } @@ -68,6 +64,5 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol try container.encode(moleculeName, forKey: .moleculeName) try container.encode(headline, forKey: .headline) try container.encodeIfPresent(body, forKey: .body) - try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } } From 04acb80fd58b542b93a1a2bbbb568f2215183eae Mon Sep 17 00:00:00 2001 From: teegsh2 Date: Wed, 21 Dec 2022 20:25:03 +0530 Subject: [PATCH 44/51] Revert "unmask NavBar SR" This reverts commit 7ae5cbfc8a028251bebe7de0727ee571cedba2ac. --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d9c606e4..c6c64f3a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -363,7 +363,7 @@ import MVMCore super.viewWillDisappear(animated) executeBehaviors { [weak self] (behavior: PageVisibilityBehavior) in - behavior.willShowPage(self?.delegateObjectIVar) + behavior.willHidePage(self?.delegateObjectIVar) } } From af97c5d38793287854df8183fef6fb7c56cbfb79 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Fri, 23 Dec 2022 23:33:18 +0530 Subject: [PATCH 45/51] addressed review comments --- .../OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift | 1 + .../ListOneColumnTextWithWhitespaceDividerTallModel.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift index d93cd0f2..772ec5ac 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTall.swift @@ -64,6 +64,7 @@ import Foundation super.reset() headline.setFontStyle(.BoldTitleMedium) 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 4527dba0..c713b0d2 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/SectionDividers/OneColumn/ListOneColumnTextWithWhitespaceDividerTallModel.swift @@ -22,7 +22,7 @@ public class ListOneColumnTextWithWhitespaceDividerTallModel: ListItemModel, Mol // MARK: - Initializer //-------------------------------------------------- - public init(headline: LabelModel, body: LabelModel?, accessibilityText: String?) { + public init(headline: LabelModel, body: LabelModel?) { self.headline = headline self.body = body super.init() From 3a57a11a57e214fabb3ecf5252d094e9738dbee2 Mon Sep 17 00:00:00 2001 From: vimal Date: Tue, 24 Jan 2023 20:52:26 +0530 Subject: [PATCH 46/51] fix for CXTDT-367273 --- .../Molecules/VerticalCombinationViews/HeadlineBody.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift index ae0d22c4..96e94640 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -150,6 +150,9 @@ open class HeadlineBody: View { open override func reset() { super.reset() + //Reset the text values + headlineLabel.reset() + messageLabel.reset() stylePageHeader() } } From be6629ab7b5480787db18957785c8672d56cf40a Mon Sep 17 00:00:00 2001 From: Rajesh Pullagalla Date: Thu, 9 Feb 2023 17:41:55 -0500 Subject: [PATCH 47/51] Changed above methods permission to open to subclass in 5G Module --- .../Atomic/Templates/ThreeLayerPageTemplateModel.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift index e3ada79d..ab4f29d5 100644 --- a/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Atomic/Templates/ThreeLayerPageTemplateModel.swift @@ -7,12 +7,12 @@ // -@objcMembers public class ThreeLayerPageTemplateModel: ThreeLayerModelBase { +@objcMembers open class ThreeLayerPageTemplateModel: ThreeLayerModelBase { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- - public override class var identifier: String { "threeLayer" } + open override class var identifier: String { "threeLayer" } public var middle: MoleculeModelProtocol? public override var rootMolecules: [MoleculeModelProtocol] { @@ -51,7 +51,7 @@ try super.init(from: decoder) } - public override func encode(to encoder: Encoder) throws { + open override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeModelIfPresent(header, forKey: .middle) From 7043a75bf144526394504b214e7adca0ca6f8c50 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 16 Feb 2023 17:15:48 -0500 Subject: [PATCH 48/51] update artifactory url from prod to ci --- .gitlab-ci.yml | 12 ++++++------ Scripts/download_dependencies.sh | 2 +- Scripts/upload_core_ui_frameworks.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d475e062..8dc2e960 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,9 +22,9 @@ download_artifacts: - bash_shell environment: name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory + url: https://oneartifactoryci.verizon.com/artifactory variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + ARTIFACTORY_URL: https://oneartifactoryci.verizon.com/artifactory build_project: stage: build @@ -47,9 +47,9 @@ deploy_snapshot: - bash_shell environment: name: oneartifactory - url: https://oneartifactoryprod.verizon.com/artifactory + url: https://oneartifactoryci.verizon.com/artifactory variables: - ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory + ARTIFACTORY_URL: https://oneartifactoryci.verizon.com/artifactory #promote_snapshot: # stage: go live @@ -65,9 +65,9 @@ deploy_snapshot: # - bash_shell # environment: # name: oneartifactory -# url: https://oneartifactoryprod.verizon.com/artifactory +# url: https://oneartifactoryci.verizon.com/artifactory # variables: -# ARTIFACTORY_URL: https://oneartifactoryprod.verizon.com/artifactory +# ARTIFACTORY_URL: https://oneartifactoryci.verizon.com/artifactory # #create_version_tag: # stage: tag diff --git a/Scripts/download_dependencies.sh b/Scripts/download_dependencies.sh index cc6bc209..08ec31c0 100755 --- a/Scripts/download_dependencies.sh +++ b/Scripts/download_dependencies.sh @@ -8,7 +8,7 @@ # Create new aggregate builds if [ -z $ARTIFACTORY_URL ]; then - ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" + ARTIFACTORY_URL="https://oneartifactoryci.verizon.com/artifactory" fi BUILD_DIR=$(xcodebuild -showBuildSettings -project ./MVMCoreUI.xcodeproj | grep -w -o 'BUILD_DIR = .*' | cut -d\ -f3-) diff --git a/Scripts/upload_core_ui_frameworks.sh b/Scripts/upload_core_ui_frameworks.sh index a8cf475b..b6092993 100755 --- a/Scripts/upload_core_ui_frameworks.sh +++ b/Scripts/upload_core_ui_frameworks.sh @@ -17,7 +17,7 @@ fi # Create new aggregate builds if [ -z $ARTIFACTORY_URL ]; then - ARTIFACTORY_URL="https://oneartifactoryprod.verizon.com/artifactory" + ARTIFACTORY_URL="https://oneartifactoryci.verizon.com/artifactory" fi # Upload From 81a6cd8447fa2b8d59189bf913c2d8f9290a702f Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Wed, 1 Mar 2023 17:05:56 +0530 Subject: [PATCH 49/51] made model class as open & properties --- MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift index 858984b0..58f398b6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/CheckboxLabelModel.swift @@ -15,8 +15,8 @@ public enum CheckboxPosition: String, Codable { case bottom } -@objcMembers public class CheckboxLabelModel: MoleculeModelProtocol { - public static var identifier: String = "checkboxLabel" +@objcMembers open class CheckboxLabelModel: MoleculeModelProtocol { + open class var identifier: String { "checkboxLabel" } public var moleculeName: String = CheckboxLabelModel.identifier public var backgroundColor: Color? public var checkboxAlignment: CheckboxPosition? From f7f9731209439a88783ca00bea798a10888d43b0 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 2 Mar 2023 21:29:14 -0500 Subject: [PATCH 50/51] add missing ParentMoleculeModelProtocol --- .../OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift | 6 +++++- .../ListRightVariableButtonAllTextAndLinksModel.swift | 6 +++++- .../VerticalCombinationViews/HeadlineBodyModel.swift | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift index 288b0591..94be5a53 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/OneColumn/ListOneColumnFullWidthTextBodyTextModel.swift @@ -9,7 +9,7 @@ import Foundation -public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol { +public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeModelProtocol, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -35,6 +35,10 @@ public class ListOneColumnFullWidthTextBodyTextModel: ListItemModel, MoleculeMod headlineBody.style = .item } + public var children: [MoleculeModelProtocol] { + return [headlineBody] + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift index db093a9a..21a4b08c 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableButtonAllTextAndLinksModel.swift @@ -7,7 +7,7 @@ // -public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { +public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol, ParentMoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -36,6 +36,10 @@ public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, Molecul self.button.style = .secondary } + public var children: [MoleculeModelProtocol] { + return [button, eyebrowHeadlineBodyLink] + } + //-------------------------------------------------- // MARK: - Keys //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift index a3452e7b..20df223a 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/HeadlineBodyModel.swift @@ -47,6 +47,11 @@ self.body = body } + public init(headline: LabelModel, body: LabelModel) { + self.headline = headline + self.body = body + } + //----------------------------------------------------- // MARK: - Codec //----------------------------------------------------- From f8c6a11199346ebba66e14feff37674ecbc81d91 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 3 Mar 2023 17:13:50 -0500 Subject: [PATCH 51/51] identifiable streamlining iCloud fix --- MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift index 10e6a4e5..d1995d19 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelModel.swift @@ -7,12 +7,13 @@ // -@objcMembers open class LabelModel: MoleculeModelProtocol { +@objcMembers open class LabelModel: MoleculeModelProtocol, Identifiable { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- open class var identifier: String { "label" } + public var id: String public var backgroundColor: Color? public var text: String public var accessibilityText: String? @@ -34,6 +35,7 @@ private enum CodingKeys: String, CodingKey { case moleculeName + case id case text case accessibilityText case textColor @@ -58,7 +60,8 @@ // MARK: - Initializer //-------------------------------------------------- - public init(text: String) { + public init(id: String = UUID().uuidString, text: String) { + self.id = id self.text = text } @@ -78,6 +81,7 @@ 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 text = try typeContainer.decode(String.self, forKey: .text) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor) @@ -102,6 +106,7 @@ open func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(id, forKey: .id) try container.encode(text, forKey: .text) try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) try container.encodeIfPresent(textColor, forKey: .textColor)