diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index da20838e..cdc028d4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -91,6 +91,7 @@ 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; 0A41BA7F23453A6400D4C0BC /* TextEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */; }; 0A5D59C223AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */; }; + 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */; }; 0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */; }; 0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */; }; 0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */; }; @@ -120,6 +121,10 @@ 525019DE2406430800EED91C /* ListProgressBarData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019DC2406430800EED91C /* ListProgressBarData.swift */; }; 525019E52406852100EED91C /* ListFourColumnDataUsageDividerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */; }; 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */; }; + 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525239BF2407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift */; }; + 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525239C12407BD1000454969 /* ListTwoColumnPriceDetails.swift */; }; + 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 526A265B240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift */; }; + 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */ = {isa = PBXBuildFile; fileRef = 526A265D240D200500B0D828 /* ListTwoColumnCompareChanges.swift */; }; 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B201D024081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift */; }; 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B201D124081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift */; }; 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */; }; @@ -196,6 +201,9 @@ D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */; }; D22D1F562204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */; }; + D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */; }; + D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; }; + D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; }; @@ -458,6 +466,7 @@ 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextEntryField.swift; sourceTree = ""; }; 0A5D59C123AD2F5700EFD9E9 /* AppleGuidelinesProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleGuidelinesProtocol.swift; sourceTree = ""; }; + 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyRequiredModel.swift; sourceTree = ""; }; 0A6BF4712360C56C0028F841 /* BaseDropdownEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseDropdownEntryField.swift; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; 0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = ""; }; @@ -490,6 +499,10 @@ 525019DC2406430800EED91C /* ListProgressBarData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListProgressBarData.swift; sourceTree = ""; }; 525019E42406852100EED91C /* ListFourColumnDataUsageDividerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageDividerModel.swift; sourceTree = ""; }; 525019E62406853600EED91C /* ListFourColumnDataUsageDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListFourColumnDataUsageDivider.swift; sourceTree = ""; }; + 525239BF2407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDetailsModel.swift; sourceTree = ""; }; + 525239C12407BD1000454969 /* ListTwoColumnPriceDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDetails.swift; sourceTree = ""; }; + 526A265B240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnCompareChangesModel.swift; sourceTree = ""; }; + 526A265D240D200500B0D828 /* ListTwoColumnCompareChanges.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTwoColumnCompareChanges.swift; sourceTree = ""; }; 52B201D024081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAndPaymentMethod.swift; sourceTree = ""; }; 52B201D124081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListLeftVariableRadioButtonAndPaymentMethodModel.swift; sourceTree = ""; }; 8D084ACF2410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListOneColumnFullWidthTextBodyTextModel.swift; sourceTree = ""; }; @@ -565,6 +578,9 @@ D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISwitch.m; sourceTree = ""; }; D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = ""; }; D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = ""; }; + D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Extension.swift"; sourceTree = ""; }; + D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = ""; }; + D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = ""; }; @@ -795,20 +811,6 @@ path = ModelProtocols; sourceTree = ""; }; - 011D9583240422BF000E3791 /* New */ = { - isa = PBXGroup; - children = ( - 011D958A24042794000E3791 /* Rules */, - 011D95882404249B000E3791 /* FormHolderModelProtocol.swift */, - 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, - 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, - 011D958624042492000E3791 /* FormFieldProtocol.swift */, - 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */, - 011D9601240DA20A000E3791 /* ValidProtocol.swift */, - ); - path = New; - sourceTree = ""; - }; 011D958A24042794000E3791 /* Rules */ = { isa = PBXGroup; children = ( @@ -819,8 +821,10 @@ 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */, 011D95A2240453F8000E3791 /* RuleRegexModel.swift */, 011D95A4240455DC000E3791 /* FormGroupRule.swift */, + 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */, ); - path = Rules; + name = Rules; + path = Rules/Rules; sourceTree = ""; }; 012A88EF23985E0100FE3DA1 /* CustomPrimitives */ = { @@ -842,8 +846,14 @@ 01C74D87224298E2009C25A3 /* FormUIHelpers */ = { isa = PBXGroup; children = ( - 011D9583240422BF000E3791 /* New */, + 011D95882404249B000E3791 /* FormProtocol.swift */, + 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */, + 011D95AA2405C553000E3791 /* FormItemProtocol.swift */, + 011D958624042492000E3791 /* FormFieldProtocol.swift */, + 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */, + 011D9601240DA20A000E3791 /* ValidProtocol.swift */, 0105618A224BBE7700E1557D /* FormValidator.swift */, + 011D958A24042794000E3791 /* Rules */, ); path = FormUIHelpers; sourceTree = ""; @@ -908,6 +918,13 @@ path = LockUps; sourceTree = ""; }; + 526A265A240D1FCE00B0D828 /* TwoColumn */ = { + isa = PBXGroup; + children = ( + ); + path = TwoColumn; + sourceTree = ""; + }; 94C2D9822386F3E30006CF46 /* Label */ = { isa = PBXGroup; children = ( @@ -1136,6 +1153,7 @@ D22B38EA23F4E08B00490EF6 /* List */ = { isa = PBXGroup; children = ( + D22D8396241FDE4700D3DF69 /* TwoColumn */, 52267A0523FFE0A900906CBA /* OneColumn */, AA4FC2A323F4F69600E251DB /* RightVariable */, D22B38EB23F4E0AE00490EF6 /* LeftVariable */, @@ -1159,6 +1177,7 @@ D22B38EC23F4E10700490EF6 /* SectionDividers */ = { isa = PBXGroup; children = ( + 526A265A240D1FCE00B0D828 /* TwoColumn */, 525019E3240684E500EED91C /* FourColumn */, D22B38ED23F4E11100490EF6 /* ThreeColumn */, ); @@ -1183,6 +1202,19 @@ path = Legacy; sourceTree = ""; }; + D22D8396241FDE4700D3DF69 /* TwoColumn */ = { + isa = PBXGroup; + children = ( + D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */, + D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */, + 526A265B240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift */, + 526A265D240D200500B0D828 /* ListTwoColumnCompareChanges.swift */, + 525239BF2407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift */, + 525239C12407BD1000454969 /* ListTwoColumnPriceDetails.swift */, + ); + path = TwoColumn; + sourceTree = ""; + }; D260105723CF9CC500764D80 /* Doughnut */ = { isa = PBXGroup; children = ( @@ -1331,6 +1363,7 @@ D29DF11421E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m */, D22479932316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift */, 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */, + D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */, ); path = Categories; sourceTree = ""; @@ -1799,6 +1832,7 @@ D28A838123CCB0D800DFE4FC /* AccordionListItemModel.swift in Sources */, DBC4391822442197001AB423 /* CaretView.swift in Sources */, C07065C42395677300FBF997 /* Link.swift in Sources */, + 0A69F611241BDEA700F7231B /* RuleAnyRequiredModel.swift in Sources */, D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */, D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */, D28A838923CCCFCB00DFE4FC /* LinkModel.swift in Sources */, @@ -1823,6 +1857,7 @@ D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, 011D95A924057AC7000E3791 /* FormActionFieldProtocol.swift in Sources */, + D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */, 0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, 942C378C2412F4FA0066E45E /* ModalMoleculeListTemplate.swift in Sources */, @@ -1868,7 +1903,9 @@ 012A88C4238D86E600FE3DA1 /* CarouselItemModelProtocol.swift in Sources */, D2E2A9A123E095AB000B42E6 /* ButtonModelProtocol.swift in Sources */, 94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */, + D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */, 52B201D324081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethodModel.swift in Sources */, + 525239C02407BCFF00454969 /* ListTwoColumnPriceDetailsModel.swift in Sources */, D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */, 8D084AD22410BF7600951227 /* ListOneColumnFullWidthTextBodyText.swift in Sources */, 014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */, @@ -1901,6 +1938,7 @@ D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, + 526A265C240D1FF700B0D828 /* ListTwoColumnCompareChangesModel.swift in Sources */, D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, @@ -1963,6 +2001,7 @@ 94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */, D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */, D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */, + 526A265E240D200500B0D828 /* ListTwoColumnCompareChanges.swift in Sources */, 8D24041523E7FC0B009E23BE /* ListLeftVariableIconWithRightCaretModel.swift in Sources */, D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */, D2D90B42240463E100DD6EC9 /* MoleculeHeaderModel.swift in Sources */, @@ -2032,6 +2071,7 @@ 011D95892404249B000E3791 /* FormHolderModelProtocol.swift in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, 013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */, + 525239C22407BD1000454969 /* ListTwoColumnPriceDetails.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D2E2A9A323E096B1000B42E6 /* DisableableModelProtocol.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, @@ -2054,6 +2094,7 @@ D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */, 0A7EF86323D8AFA000B2AAD1 /* BaseDropdownEntryFieldModel.swift in Sources */, 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */, + D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */, D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */, D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */, 014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index c3aa19c6..4c56036e 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -44,7 +44,7 @@ import UIKit private var observingForChange: Bool = false - /// Validate on each entry in the textField. Default: false + /// Validate on each entry in the textField. Default: true public var validateEachCharacter: Bool = true /// Validate when user resigns editing. Default: true diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift index ddc468b7..77f7fde6 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeModel.swift @@ -32,7 +32,7 @@ import Foundation var location: Int var length: Int - init(_ location: Int, _ length: Int) { + public init(_ location: Int, _ length: Int) { self.location = location self.length = length } diff --git a/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift b/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift index f69e966d..59552e18 100644 --- a/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift +++ b/MVMCoreUI/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift @@ -19,4 +19,8 @@ import UIKit public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) } + + public override init(_ location: Int, _ length: Int) { + super.init(location, length) + } } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index 0a7f4e55..c0f267fc 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -17,7 +17,7 @@ open class ThreeLayerTableViewController: ProgrammaticTableViewController { private var footerView: UIView? private var safeAreaView: UIView? var useMargins: Bool = true - var bottomViewOutsideOfScrollArea: Bool = false + public var bottomViewOutsideOfScrollArea: Bool = false private var topViewBottomConstraint: NSLayoutConstraint? private var bottomViewTopConstraint: NSLayoutConstraint? diff --git a/MVMCoreUI/Categories/UIStackView+Extension.swift b/MVMCoreUI/Categories/UIStackView+Extension.swift new file mode 100644 index 00000000..e968fd7c --- /dev/null +++ b/MVMCoreUI/Categories/UIStackView+Extension.swift @@ -0,0 +1,23 @@ +// +// UIStackView+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/16/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +extension UIStackView: MVMCoreUIMoleculeViewProtocol { + public func updateView(_ size: CGFloat) { + for view in arrangedSubviews { + (view as? MVMCoreViewProtocol)?.updateView(size) + } + } + + public func reset() { + for view in arrangedSubviews { + (view as? MVMCoreUIMoleculeViewProtocol)?.reset?() + } + } +} diff --git a/MVMCoreUI/FormUIHelpers/New/FormActionFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/FormActionFieldProtocol.swift rename to MVMCoreUI/FormUIHelpers/FormActionFieldProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/New/FormFieldProtocol.swift b/MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/FormFieldProtocol.swift rename to MVMCoreUI/FormUIHelpers/FormFieldProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift b/MVMCoreUI/FormUIHelpers/FormHolderProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift rename to MVMCoreUI/FormUIHelpers/FormHolderProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/New/FormItemProtocol.swift b/MVMCoreUI/FormUIHelpers/FormItemProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/FormItemProtocol.swift rename to MVMCoreUI/FormUIHelpers/FormItemProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index f2cdb8ea..8977fad5 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -66,7 +66,7 @@ import MVMCore public func validate(_ groupName: String, _ actionModel: FormActionFieldProtocol, _ rules: [RulesProtocol]) { var valid = true for rule in rules { - valid = valid && rule.isValid(self) + valid = valid && rule.isValid(fieldMolecules) if !valid { break } diff --git a/MVMCoreUI/FormUIHelpers/New/FormHolderModelProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/FormHolderModelProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/FormHolderModelProtocol.swift rename to MVMCoreUI/FormUIHelpers/Rules/FormHolderModelProtocol.swift diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/FormGroupRule.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/Rules/FormGroupRule.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/FormGroupRule.swift diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleAllValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/Rules/RuleAllValueChangedModel.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAllValueChangedModel.swift diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift new file mode 100644 index 00000000..d41c0b0c --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyRequiredModel.swift @@ -0,0 +1,49 @@ +// +// RuleAnyRequiredModel.swift +// MVMCoreUI +// +// Created by Kevin Christiano on 3/13/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + + +public class RuleAnyRequiredModel: RulesProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "anyRequired" + public var type: String = RuleRequiredModel.identifier + public var fields: [String] + + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + + public func isValid(_ formField: FormFieldProtocol) -> Bool { + guard let value = formField.formFieldValue() else { return false } + + if let valueString = value as? String { + return valueString.count > 0 + + } else if let valueBool = value as? Bool { + return valueBool + } + + return false + } + + public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { + + for formKey in fields { + guard let formField = fieldMolecules[formKey] else { continue } + + if isValid(formField) { + return true + } + } + return false + } +} diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyValueChangedModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift similarity index 82% rename from MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyValueChangedModel.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift index f52dd92d..042243db 100644 --- a/MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyValueChangedModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleAnyValueChangedModel.swift @@ -18,9 +18,9 @@ public class RuleAnyValueChangedModel: RulesProtocol { return formField.baseValue != formField.formFieldValue() } - public func isValid(_ formValidator: FormValidator) -> Bool { + public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { for formKey in fields { - guard let formField = formValidator.formField(for: formKey) else { + guard let formField = fieldMolecules[formKey] else { continue } if isValid(formField) { diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift similarity index 85% rename from MVMCoreUI/FormUIHelpers/New/Rules/RuleEqualsModel.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift index ac148a29..e6b338a4 100644 --- a/MVMCoreUI/FormUIHelpers/New/Rules/RuleEqualsModel.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleEqualsModel.swift @@ -18,11 +18,11 @@ public class RuleEqualsModel: RulesProtocol { return false } - public func isValid(_ formValidator: FormValidator) -> Bool { + public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { var valid = true var compareValue: AnyHashable? for formKey in fields { - guard let formField = formValidator.formField(for: formKey) else { + guard let formField = fieldMolecules[formKey] else { continue } diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleRegexModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/Rules/RuleRegexModel.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRegexModel.swift diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RuleRequiredModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/Rules/RuleRequiredModel.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RuleRequiredModel.swift diff --git a/MVMCoreUI/FormUIHelpers/New/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift similarity index 81% rename from MVMCoreUI/FormUIHelpers/New/Rules/RulesProtocol.swift rename to MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index 16fe77b3..25119e03 100644 --- a/MVMCoreUI/FormUIHelpers/New/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -16,7 +16,7 @@ public enum RulesCodingKey: String, CodingKey { public protocol RulesProtocol: ModelProtocol { var type: String { get set } var fields: [String] { get set } - func isValid(_ formValidator: FormValidator) -> Bool + func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool func isValid(_ formField: FormFieldProtocol) -> Bool func setValid(_ formField: FormFieldProtocol, _ isValid: Bool) } @@ -35,23 +35,22 @@ public extension RulesProtocol { return "\(RulesProtocol.self)" } - func isValid(_ formValidator: FormValidator) -> Bool { + func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool { var valid = true + for formKey in fields { - guard let formField = formValidator.formField(for: formKey) else { - continue - } + guard let formField = fieldMolecules[formKey] else { continue } let fieldValidity = isValid(formField) setValid(formField, fieldValidity) valid = valid && fieldValidity } + return valid } func setValid(_ formField: FormFieldProtocol, _ isValid: Bool) { - guard let formFieldValid = formField as? ValidProtocol else { - return - } + guard let formFieldValid = formField as? ValidProtocol else { return } + formFieldValid.setValidity(isValid) } } diff --git a/MVMCoreUI/FormUIHelpers/New/ValidProtocol.swift b/MVMCoreUI/FormUIHelpers/ValidProtocol.swift similarity index 100% rename from MVMCoreUI/FormUIHelpers/New/ValidProtocol.swift rename to MVMCoreUI/FormUIHelpers/ValidProtocol.swift diff --git a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m index 9a8f880f..f2b9976e 100644 --- a/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m +++ b/MVMCoreUI/Legacy/Views/MVMCoreUIPageControl.m @@ -311,7 +311,7 @@ static CGFloat const IndicatorRectangleHeight = 4; self.currentPage = page; } -#pragma mark - MoleculeViewProtocol +#pragma mark - MVMCoreUIMoleculeViewProtocol - (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { NSString *colorString = [json string:KeyBackgroundColor]; diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift new file mode 100644 index 00000000..c007b8c7 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChanges.swift @@ -0,0 +1,113 @@ +// +// ListTwoColumnCompareChanges.swift +// MVMCoreUI +// +// Created by Lekshmi S on 24/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListTwoColumnCompareChanges: TableViewCell { + + //------------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + let leftHeadline1 = Label.commonLabelB1(true) + let leftHeadline2 = Label.commonLabelB1(true) + let leftHeadline3 = Label.commonLabelB1(true) + let leftBody = Label.commonLabelB2(true) + let leftLink = Link() + let rightHeadline1 = Label.commonLabelB1(true) + let rightHeadline2 = Label.commonLabelB1(true) + let rightHeadline3 = Label.commonLabelB1(true) + let rightBody = Label.commonLabelB2(true) + let rightLink = Link() + let containingStack: Stack + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + let stackHeadline1 = Stack.createStack(with: [(view: leftHeadline1, model: StackItemModel(percent: 50, verticalAlignment: .leading)), + (view: rightHeadline1, model: StackItemModel(percent: 50, verticalAlignment: .leading))], + axis: .horizontal) + let stackHeadline2 = Stack.createStack(with: [(view: leftHeadline2, model: StackItemModel(percent: 50, verticalAlignment: .leading)), + (view: rightHeadline2, model: StackItemModel(percent: 50, verticalAlignment: .leading))], + axis: .horizontal) + let stackHeadline3 = Stack.createStack(with: [(view: leftHeadline3, model: StackItemModel(percent: 50, verticalAlignment: .leading)), + (view: rightHeadline3, model: StackItemModel(percent: 50, verticalAlignment: .leading))], + axis: .horizontal) + let stackBody = Stack.createStack(with: [(view: leftBody, model: StackItemModel(percent: 50, verticalAlignment: .leading)), + (view: rightBody, model: StackItemModel(percent: 50, verticalAlignment: .leading))], + axis: .horizontal) + let stackLink = Stack.createStack(with: [(view: leftLink, model: StackItemModel(percent: 50, verticalAlignment: .leading)), + (view: rightLink, model: StackItemModel(percent: 50, verticalAlignment: .leading))], + axis: .horizontal) + containingStack = Stack.createStack(with: [stackHeadline1, + stackHeadline2, + stackHeadline3, + stackBody, + stackLink], + spacing: 0) + containingStack.stackModel?.molecules[1].spacing = 5 + containingStack.stackModel?.molecules[2].spacing = 5 + containingStack.stackModel?.molecules[4].spacing = 5 + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //------------------------------------------------------ + // MARK: - Properties + //------------------------------------------------------ + let stackSpacing: CGFloat = 5.0 + + //------------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func setupView() { + super.setupView() + addMolecule(containingStack) + for molecule in containingStack.stackItems { + ((molecule as? StackItem)?.view as? Stack)?.restack() + } + containingStack.restack() + } + + //------------------------------------------------------ + // MARK: - Molecule + //------------------------------------------------------ + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListTwoColumnCompareChangesModel else { return } + leftHeadline1.set(with: model.leftHeadline1, delegateObject, additionalData) + leftHeadline2.set(with: model.leftHeadline2, delegateObject, additionalData) + leftHeadline3.set(with: model.leftHeadline3, delegateObject, additionalData) + leftBody.set(with: model.leftBody, delegateObject, additionalData) + leftLink.set(with: model.leftLink, delegateObject, additionalData) + rightHeadline1.set(with: model.rightHeadline1, delegateObject, additionalData) + rightHeadline2.set(with: model.rightHeadline2, delegateObject, additionalData) + rightHeadline3.set(with: model.rightHeadline3, delegateObject, additionalData) + rightBody.set(with: model.rightBody, delegateObject, additionalData) + rightLink.set(with: model.rightLink, delegateObject, additionalData) + } + + open override func reset() { + super.reset() + leftHeadline1.styleB1(true) + leftHeadline2.styleB1(true) + leftHeadline3.styleB1(true) + leftBody.styleB2(true) + rightHeadline1.styleB1(true) + rightHeadline2.styleB1(true) + rightHeadline3.styleB1(true) + rightBody.styleB2(true) + } + + public override class func estimatedHeight(with molecule: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 121 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift new file mode 100644 index 00000000..5e4e876c --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnCompareChangesModel.swift @@ -0,0 +1,83 @@ +// +// ListTwoColumnCompareChangesModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 24/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListTwoColumnCompareChangesModel: ListItemModel, MoleculeModelProtocol { + + public static var identifier: String = "list2CCmpr1" + public var leftHeadline1: LabelModel + public var leftHeadline2: LabelModel + public var leftHeadline3: LabelModel + public var leftBody: LabelModel + public var leftLink: LinkModel + public var rightHeadline1: LabelModel + public var rightHeadline2: LabelModel + public var rightHeadline3: LabelModel + public var rightBody: LabelModel + public var rightLink: LinkModel + + public init(leftHeadline1: LabelModel, leftHeadline2: LabelModel, leftHeadline3: LabelModel, leftBody: LabelModel, leftLink: LinkModel, rightHeadline1: LabelModel, rightHeadline2: LabelModel, rightHeadline3: LabelModel, rightBody: LabelModel, rightLink: LinkModel) { + self.leftHeadline1 = leftHeadline1 + self.leftHeadline2 = leftHeadline2 + self.leftHeadline3 = leftHeadline3 + self.leftBody = leftBody + self.leftLink = leftLink + self.rightHeadline1 = rightHeadline1 + self.rightHeadline2 = rightHeadline2 + self.rightHeadline3 = rightHeadline3 + self.rightBody = rightBody + self.rightLink = rightLink + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftHeadline1 + case leftHeadline2 + case leftHeadline3 + case leftBody + case leftLink + case rightHeadline1 + case rightHeadline2 + case rightHeadline3 + case rightBody + case rightLink + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftHeadline1 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline1) + leftHeadline2 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline2) + leftHeadline3 = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline3) + leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody) + leftLink = try typeContainer.decode(LinkModel.self, forKey: .leftLink) + rightHeadline1 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline1) + rightHeadline2 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline2) + rightHeadline3 = try typeContainer.decode(LabelModel.self, forKey: .rightHeadline3) + rightBody = try typeContainer.decode(LabelModel.self, forKey: .rightBody) + rightLink = try typeContainer.decode(LinkModel.self, forKey: .rightLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftHeadline1, forKey: .leftHeadline1) + try container.encode(leftHeadline2, forKey: .leftHeadline2) + try container.encode(leftHeadline3, forKey: .leftHeadline3) + try container.encode(leftBody, forKey: .leftBody) + try container.encode(leftLink, forKey: .leftLink) + try container.encode(rightHeadline1, forKey: .rightHeadline1) + try container.encode(rightHeadline2, forKey: .rightHeadline2) + try container.encode(rightHeadline3, forKey: .rightHeadline3) + try container.encode(rightBody, forKey: .rightBody) + try container.encode(rightLink, forKey: .rightLink) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift new file mode 100644 index 00000000..9f4f60b2 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescription.swift @@ -0,0 +1,94 @@ +// +// ListTwoColumnPriceDescription.swift +// MVMCoreUI +// +// Created by Kruthika KP on 24/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListTwoColumnPriceDescription: TableViewCell { + + //----------------------------------------------------- + // MARK: - Outlets + //------------------------------------------------------- + public let leftHeadline = Label.commonLabelB1(true) + public let leftBody = Label.commonLabelB2(true) + public let rightLabel = Label.commonLabelB2(true) + public let rightSubLabel = Label.commonLabelB2(true) + + public let view = MVMCoreUICommonViewsUtility.commonView() + public let leftVerticalStack: UIStackView + public let rightVerticalStack: UIStackView + + //------------------------------------------------------ + // MARK: - Initializers + //------------------------------------------------------ + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + leftVerticalStack = UIStackView(arrangedSubviews: [leftHeadline, leftBody]) + leftVerticalStack.axis = .vertical + leftVerticalStack.alignment = .leading + rightVerticalStack = UIStackView(arrangedSubviews: [rightLabel, rightSubLabel]) + rightVerticalStack.axis = .vertical + rightVerticalStack.alignment = .trailing + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + //----------------------------------------------------- + // MARK: - View Lifecycle + //------------------------------------------------------- + open override func updateView(_ size: CGFloat) { + super.updateView(size) + leftVerticalStack.updateView(size) + rightVerticalStack.updateView(size) + } + + override open func setupView() { + super.setupView() + contentView.addSubview(view) + containerHelper.constrainView(view) + + leftVerticalStack.translatesAutoresizingMaskIntoConstraints = false + rightVerticalStack.translatesAutoresizingMaskIntoConstraints = false + rightLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) + rightSubLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) + view.addSubview(leftVerticalStack) + view.addSubview(rightVerticalStack) + NSLayoutConstraint.pinViews(leftView: leftVerticalStack, rightView: rightVerticalStack, alignTop: true) + + leftHeadline.numberOfLines = 1 + rightLabel.numberOfLines = 1 + rightSubLabel.numberOfLines = 1 + } + //---------------------------------------------------- + // MARK: - Molecule + //------------------------------------------------------ + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListTwoColumnPriceDescriptionModel else { return } + leftHeadline.set(with: model.leftHeadline, delegateObject, additionalData) + leftBody.set(with: model.leftBody, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + rightSubLabel.set(with: model.rightSubLabel, delegateObject, additionalData) + } + + open override class func estimatedHeight(with molecule: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 80 + } + + override open func reset() { + super.reset() + leftVerticalStack.reset() + rightVerticalStack.reset() + leftHeadline.styleB1(true) + leftBody.styleB2(true) + rightLabel.styleB2(true) + rightSubLabel.styleB2(true) + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift new file mode 100644 index 00000000..996b1b47 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDescriptionModel.swift @@ -0,0 +1,66 @@ +// +// ListTwoColumnPriceDescriptionModel.swift +// MVMCoreUI +// +// Created by Kruthika KP on 26/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListTwoColumnPriceDescriptionModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list2CTxtPrc1" + public var leftHeadline: LabelModel + public var leftBody: LabelModel + public var rightLabel: LabelModel + public var rightSubLabel: LabelModel + + override public func setDefaults() { + super.setDefaults() + rightLabel.hero = 0 + if rightSubLabel.textColor == nil { + rightSubLabel.textColor = Color(uiColor: .mvmCoolGray6) + } + if rightSubLabel.attributes == nil { + rightSubLabel.attributes = [LabelAttributeStrikeThroughModel(0, rightSubLabel.text.count)] + } + } + + public init(leftHeadline: LabelModel,leftBody: LabelModel, rightLabel: LabelModel, rightSubLabel: LabelModel) { + self.leftHeadline = leftHeadline + self.leftBody = leftBody + self.rightLabel = rightLabel + self.rightSubLabel = rightSubLabel + super.init() + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftHeadline + case leftBody + case rightLabel + case rightSubLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftHeadline = try typeContainer.decode(LabelModel.self, forKey: .leftHeadline) + leftBody = try typeContainer.decode(LabelModel.self, forKey: .leftBody) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + rightSubLabel = try typeContainer.decode(LabelModel.self, forKey: .rightSubLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftHeadline, forKey: .leftHeadline) + try container.encode(leftBody, forKey: .leftBody) + try container.encode(rightLabel, forKey: .rightLabel) + try container.encode(rightSubLabel, forKey: .rightSubLabel) + } +} + + + diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift new file mode 100644 index 00000000..610821b3 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetails.swift @@ -0,0 +1,54 @@ +// +// ListTwoColumnPriceDetails.swift +// MVMCoreUI +// +// Created by Lekshmi S on 19/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import UIKit + +@objcMembers open class ListTwoColumnPriceDetails: TableViewCell { + + let leftLabel = Label.commonLabelB2(true) + let rightLabel = Label.commonLabelB2(true) + let view = MVMCoreUICommonViewsUtility.commonView() + + // MARK: - MFViewProtocol + open override func setupView() { + super.setupView() + view.addSubview(leftLabel) + view.addSubview(rightLabel) + NSLayoutConstraint.pinViews(leftView: leftLabel, rightView: rightLabel, alignTop: true) + contentView.addSubview(view) + containerHelper.constrainView(view) + rightLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal) + rightLabel.setContentHuggingPriority(.defaultHigh, for: .vertical) + } + + open override func updateView(_ size: CGFloat) { + super.updateView(size) + leftLabel.updateView(size) + rightLabel.updateView(size) + } + + // MARK: - MVMCoreUIMoleculeViewProtocol + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListTwoColumnPriceDetailsModel else { return } + leftLabel.set(with: model.leftLabel, delegateObject, additionalData) + rightLabel.set(with: model.rightLabel, delegateObject, additionalData) + } + + open override func reset() { + super.reset() + leftLabel.reset() + rightLabel.reset() + leftLabel.styleB2(true) + rightLabel.styleB2(true) + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat { + return 15 + } +} diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift new file mode 100644 index 00000000..2de46552 --- /dev/null +++ b/MVMCoreUI/Molecules/DesignedComponents/List/TwoColumn/ListTwoColumnPriceDetailsModel.swift @@ -0,0 +1,54 @@ +// +// ListTwoColumnPriceDetailsModel.swift +// MVMCoreUI +// +// Created by Lekshmi S on 19/02/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListTwoColumnPriceDetailsModel: ListItemModel, MoleculeModelProtocol { + public static var identifier: String = "list2CTxtPrc2" + public var leftLabel: LabelModel + public var rightLabel: LabelModel + + public init(leftLabel: LabelModel, rightLabel:LabelModel) { + self.leftLabel = leftLabel + self.rightLabel = rightLabel + super.init() + } + + /// Defaults to set + override public func setDefaults() { + super.setDefaults() + style = "none" + if leftLabel.textColor == nil { + leftLabel.textColor = Color(uiColor: .mvmCoolGray6) + } + if rightLabel.textColor == nil { + rightLabel.textColor = Color(uiColor: .mvmCoolGray6) + } + } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case leftLabel + case rightLabel + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + leftLabel = try typeContainer.decode(LabelModel.self, forKey: .leftLabel) + rightLabel = try typeContainer.decode(LabelModel.self, forKey: .rightLabel) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(leftLabel, forKey: .leftLabel) + try container.encode(rightLabel, forKey: .rightLabel) + } +} diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index aa581ba1..41801046 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,7 +29,9 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let model = self.listItemModel as? DropDownListItemModel + let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), + let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], + !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) else { return } if self.previousIndex != NSNotFound { diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 99d493b8..0cd2f5ef 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -51,7 +51,7 @@ import Foundation required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) - molecules = try typeContainer.decodeModels2D(codingKey: .molecules) + molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) try super.init(from: decoder) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift index f7ae36de..bbdda6af 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/CornerLabels.swift @@ -152,7 +152,7 @@ import UIKit styleDefault() spaceAboveMolecule = 6.0 spaceBelowMolecule = 6.0 - (middleView as? MoleculeViewProtocol)?.reset?() + (middleView as? MVMCoreUIMoleculeViewProtocol)?.reset?() } func styleDefault() { diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift index 95392b8d..09ed8a7b 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/Lists/StringAndMoleculeStack/StringAndMoleculeView.swift @@ -73,7 +73,7 @@ open class StringAndMoleculeView: View { override open func reset() { super.reset() label.reset() - (molecule as? MoleculeViewProtocol)?.reset?() + (molecule as? MVMCoreUIMoleculeViewProtocol)?.reset?() } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 696964f1..8fa220ec 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -135,7 +135,7 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto super.reset() backgroundColor = .clear for item in stackItems { - (item as? MoleculeViewProtocol)?.reset?() + (item as? MVMCoreUIMoleculeViewProtocol)?.reset?() } } diff --git a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift index 17a9972c..cc3950cd 100644 --- a/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift +++ b/MVMCoreUI/OtherHandlers/MoleculeObjectMapping.swift @@ -111,7 +111,10 @@ import Foundation // Designed Section Dividers MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListFourColumnDataUsageDivider.self, viewModelClass: ListFourColumnDataUsageDividerModel.self) MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListThreeColumnPlanDataDivider.self, viewModelClass: ListThreeColumnPlanDataDividerModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDetails.self, viewModelClass: ListTwoColumnPriceDetailsModel.self) + MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: ListTwoColumnPriceDescription.self, viewModelClass: ListTwoColumnPriceDescriptionModel.self) // TODO: Need model MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DigitEntryField.self, forKey: "digitTextField" as NSString) MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DateDropdownEntryField.self, forKey: "dateDropdownEntryField" as NSString) @@ -124,6 +127,7 @@ import Foundation // Helper models try? ModelRegistry.register(RuleRequiredModel.self) + try? ModelRegistry.register(RuleAnyRequiredModel.self) try? ModelRegistry.register(RuleAnyValueChangedModel.self) try? ModelRegistry.register(RuleAllValueChangedModel.self) try? ModelRegistry.register(RuleEqualsModel.self) diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 84b88fd4..a539240e 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -126,7 +126,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, selfDelegateObject, nil) moleculeCell?.updateView(tableView.bounds.width) - + // Neded to fix an apple defect where the cell is not the correct size on certain devices for certain cells + cell.layoutIfNeeded() return cell }