This commit is contained in:
Pfeil, Scott Robert 2020-01-17 09:32:58 -05:00
commit d26d3b1e40
65 changed files with 4055 additions and 460 deletions

View File

@ -50,6 +50,7 @@
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D223CF9E740021F976 /* LabelToggleModel.swift */; };
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; };
01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; };
@ -81,6 +82,7 @@
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 */; };
0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B392398524F0067DD0F /* Toggle.swift */; };
0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136A237B193A0081388D /* EntryFieldContainer.swift */; };
0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD136C237CAD1E0081388D /* DateDropdownEntryField.swift */; };
0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ABD1370237DB0450081388D /* ItemDropdownEntryField.swift */; };
@ -105,6 +107,9 @@
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; };
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; };
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69323C9909000BFB94E /* DoughnutChartModel.swift */; };
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69523C990BC00BFB94E /* DoughnutChart.swift */; };
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A69723C990C200BFB94E /* DoughnutChartView.swift */; };
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
@ -128,10 +133,19 @@
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 */; };
D243859923A16B1800332775 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = D243859823A16B1800332775 /* Container.swift */; };
D260105323CEA61600764D80 /* ToggleModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105223CEA61600764D80 /* ToggleModel.swift */; };
D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */; };
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105823D0A92900764D80 /* ContainerProtocol.swift */; };
D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105A23D0BB7100764D80 /* StackModelProtocol.swift */; };
D260105D23D0BCD400764D80 /* Stack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105C23D0BCD400764D80 /* Stack.swift */; };
D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260105E23D0BFFC00764D80 /* StackItem.swift */; };
D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */; };
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106223D0C05000764D80 /* StackItemModel.swift */; };
D260106523D0CEA700764D80 /* StackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D260106423D0CEA700764D80 /* StackModel.swift */; };
D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; };
D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* StackItemModel.swift */; };
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
D268C70E238C22D7007F2C1C /* DropDownFilterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */; };
D268C712238D6699007F2C1C /* DropDown.swift in Sources */ = {isa = PBXBuildFile; fileRef = D268C711238D6699007F2C1C /* DropDown.swift */; };
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
@ -155,6 +169,7 @@
D28A838D23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */; };
D28A838F23CCDEDE00DFE4FC /* TwoButtonViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */; };
D28A839123CD4FD400DFE4FC /* CornerLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */; };
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */; };
D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -281,7 +296,7 @@
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */; };
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */; };
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; };
D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* StackItem.swift */; };
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; };
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; };
DBC4391822442197001AB423 /* CaretView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391622442196001AB423 /* CaretView.swift */; };
DBC4391922442197001AB423 /* DashLine.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBC4391722442197001AB423 /* DashLine.swift */; };
@ -334,10 +349,11 @@
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
01C851D223CF9E740021F976 /* LabelToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggleModel.swift; sourceTree = "<group>"; };
01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = "<group>"; };
01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = "<group>"; };
01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = "<group>"; };
01EB368A23609801006832FA /* StackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StackItemModel.swift; sourceTree = "<group>"; };
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = "<group>"; };
01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = "<group>"; };
01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = "<group>"; };
01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = "<group>"; };
@ -354,6 +370,7 @@
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
0A7BAFA0232BE61800FB8E22 /* Checkbox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkbox.swift; sourceTree = "<group>"; };
0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxWithLabelView.swift; sourceTree = "<group>"; };
0AA33B392398524F0067DD0F /* Toggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toggle.swift; sourceTree = "<group>"; };
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitBox.swift; sourceTree = "<group>"; };
0AA33B33239813C50067DD0F /* UIColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Extension.swift"; sourceTree = "<group>"; };
0ABD136A237B193A0081388D /* EntryFieldContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryFieldContainer.swift; sourceTree = "<group>"; };
@ -379,6 +396,9 @@
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartModel.swift; sourceTree = "<group>"; };
C695A69523C990BC00BFB94E /* DoughnutChart.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChart.swift; sourceTree = "<group>"; };
C695A69723C990C200BFB94E /* DoughnutChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DoughnutChartView.swift; sourceTree = "<group>"; };
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = "<group>"; };
C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = "<group>"; };
@ -402,6 +422,15 @@
D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIStackableViewController.h; sourceTree = "<group>"; };
D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIStackableViewController.m; sourceTree = "<group>"; };
D243859823A16B1800332775 /* Container.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Container.swift; sourceTree = "<group>"; };
D260105223CEA61600764D80 /* ToggleModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleModel.swift; sourceTree = "<group>"; };
D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISwitch+Model.swift"; sourceTree = "<group>"; };
D260105823D0A92900764D80 /* ContainerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerProtocol.swift; sourceTree = "<group>"; };
D260105A23D0BB7100764D80 /* StackModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModelProtocol.swift; sourceTree = "<group>"; };
D260105C23D0BCD400764D80 /* Stack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stack.swift; sourceTree = "<group>"; };
D260105E23D0BFFC00764D80 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = "<group>"; };
D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModelProtocol.swift; sourceTree = "<group>"; };
D260106223D0C05000764D80 /* StackItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItemModel.swift; sourceTree = "<group>"; };
D260106423D0CEA700764D80 /* StackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackModel.swift; sourceTree = "<group>"; };
D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPageControl.h; sourceTree = "<group>"; };
D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIPageControl.m; sourceTree = "<group>"; };
D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPagingProtocol.h; sourceTree = "<group>"; };
@ -428,6 +457,7 @@
D28A838C23CCDCC200DFE4FC /* PrimaryButton+MoleculeProtocolExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimaryButton+MoleculeProtocolExtension.swift"; sourceTree = "<group>"; };
D28A838E23CCDEDE00DFE4FC /* TwoButtonViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonViewModel.swift; sourceTree = "<group>"; };
D28A839023CD4FD400DFE4FC /* CornerLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerLabelsModel.swift; sourceTree = "<group>"; };
D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyCaretLinkImageModel.swift; sourceTree = "<group>"; };
D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewConstrainingProtocol.h; sourceTree = "<group>"; };
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
@ -570,7 +600,7 @@
D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; };
D2F4DDE52371A4CB00CD28BB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeContainer.swift; sourceTree = "<group>"; };
D2FB151C23A40F1500C20E10 /* StackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackItem.swift; sourceTree = "<group>"; };
D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeStackItem.swift; sourceTree = "<group>"; };
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LeftRightLabelView.swift; sourceTree = "<group>"; };
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
@ -768,6 +798,7 @@
children = (
01509D942327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift */,
D22479892314445E003FCCF9 /* LabelSwitch.swift */,
01C851D223CF9E740021F976 /* LabelToggleModel.swift */,
D224798B231450C8003FCCF9 /* HeadlineBodySwitch.swift */,
);
path = SwitchMolecules;
@ -780,6 +811,7 @@
01EB368D23609801006832FA /* HeadlineBodyModel.swift */,
D22479952316AF6D003FCCF9 /* HeadlineBodyTextButton.swift */,
D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */,
D28A839223CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift */,
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */,
);
path = VerticalCombinationViews;
@ -809,6 +841,9 @@
D22479902316A9CB003FCCF9 /* Organisms */ = {
isa = PBXGroup;
children = (
D260105A23D0BB7100764D80 /* StackModelProtocol.swift */,
D260106423D0CEA700764D80 /* StackModel.swift */,
D260105C23D0BCD400764D80 /* Stack.swift */,
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
D2A5145E2211DDC100345BFB /* MoleculeStackView.swift */,
D2A6390022CBB1820052ED1F /* Carousel.swift */,
@ -829,8 +864,11 @@
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */,
011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */,
D268C70D238C22D7007F2C1C /* DropDownFilterTableViewCell.swift */,
01EB368A23609801006832FA /* StackItemModel.swift */,
D2FB151C23A40F1500C20E10 /* StackItem.swift */,
D260106023D0C02A00764D80 /* StackItemModelProtocol.swift */,
D260106223D0C05000764D80 /* StackItemModel.swift */,
D260105E23D0BFFC00764D80 /* StackItem.swift */,
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */,
D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */,
);
path = Items;
sourceTree = "<group>";
@ -844,6 +882,16 @@
path = Legacy;
sourceTree = "<group>";
};
D260105723CF9CC500764D80 /* Doughnut */ = {
isa = PBXGroup;
children = (
C695A69323C9909000BFB94E /* DoughnutChartModel.swift */,
C695A69523C990BC00BFB94E /* DoughnutChart.swift */,
C695A69723C990C200BFB94E /* DoughnutChartView.swift */,
);
path = Doughnut;
sourceTree = "<group>";
};
D29DF0C221E404D4003B2FB9 = {
isa = PBXGroup;
children = (
@ -943,6 +991,7 @@
C6FA7D5023C77A4800A3614A /* LabelRightMoleculesStack.swift */,
C6FA7D5123C77A4900A3614A /* NumberedList.swift */,
C6FA7D4F23C77A4700A3614A /* UnOrderedList.swift */,
D260105723CF9CC500764D80 /* Doughnut */,
);
path = Molecules;
sourceTree = "<group>";
@ -990,6 +1039,7 @@
D29DF2B721E7BE79003B2FB9 /* TabBarController */,
D29DF2B621E7BE66003B2FB9 /* SplitViewController */,
D2B18B93236214AD00A9AEDC /* NavigationController.swift */,
D260105823D0A92900764D80 /* ContainerProtocol.swift */,
D243859823A16B1800332775 /* Container.swift */,
);
path = Containers;
@ -1107,6 +1157,8 @@
D29DF32221ED0DA2003B2FB9 /* TextButtonView.m */,
D29770FB21F7C77400B2F0D0 /* MVMCoreUITextFieldView.h */,
D29770FA21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m */,
D260105223CEA61600764D80 /* ToggleModel.swift */,
D260105423CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift */,
D22D1F44220496A30077CEC0 /* MVMCoreUISwitch.h */,
D22D1F45220496A30077CEC0 /* MVMCoreUISwitch.m */,
DBC4391C2245232D001AB423 /* LabelWithInternalButton.swift */,
@ -1118,6 +1170,7 @@
D28A838223CCBD3F00DFE4FC /* CircleProgressModel.swift */,
943784F3236B77BB006A1E82 /* GraphView.swift */,
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */,
0AA33B392398524F0067DD0F /* Toggle.swift */,
);
path = Views;
sourceTree = "<group>";
@ -1426,7 +1479,7 @@
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
D2FB151D23A40F1500C20E10 /* StackItem.swift in Sources */,
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */,
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */,
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */,
@ -1440,6 +1493,7 @@
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
D2B18B7F2360913400A9AEDC /* Control.swift in Sources */,
0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */,
D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */,
012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */,
DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */,
@ -1448,9 +1502,11 @@
9445890C2385BCE300DE9FD4 /* ProgressBarModel.swift in Sources */,
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */,
01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */,
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */,
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */,
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
@ -1465,7 +1521,9 @@
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
D28A838723CCCF6500DFE4FC /* MFTextButton+ModelExtension.swift in Sources */,
C695A69623C990BC00BFB94E /* DoughnutChart.swift in Sources */,
014AA72D23C5059B006F3E93 /* StackPageTemplateModel.swift in Sources */,
D260106123D0C02A00764D80 /* StackItemModelProtocol.swift in Sources */,
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
014AA73123C5059B006F3E93 /* ListPageTemplateModel.swift in Sources */,
@ -1487,10 +1545,11 @@
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
D28A838323CCBD3F00DFE4FC /* CircleProgressModel.swift in Sources */,
D268C70C2386DFFD007F2C1C /* StackItemModel.swift in Sources */,
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
DBEFFA04225A829700230692 /* Label.swift in Sources */,
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */,
D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */,
D29DF13021E6851E003B2FB9 /* MVMCoreUITopAlertShortView.m in Sources */,
0ABD136D237CAD1E0081388D /* DateDropdownEntryField.swift in Sources */,
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */,
@ -1499,11 +1558,13 @@
D2B18B812360945C00A9AEDC /* View.swift in Sources */,
C6FA7D5423C77A4A00A3614A /* NumberedList.swift in Sources */,
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
D260105323CEA61600764D80 /* ToggleModel.swift in Sources */,
014AA72523C501E2006F3E93 /* ContainerModel.swift in Sources */,
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */,
D2B18B94236214AD00A9AEDC /* NavigationController.swift in Sources */,
D282AACB2243C61700C46919 /* ButtonView.swift in Sources */,
D260105D23D0BCD400764D80 /* Stack.swift in Sources */,
D2D6CD4222E78FAB00D701B8 /* ThreeLayerTemplate.swift in Sources */,
01EB368F23609801006832FA /* LabelModel.swift in Sources */,
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
@ -1562,8 +1623,11 @@
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */,
D243859923A16B1800332775 /* Container.swift in Sources */,
D260105B23D0BB7100764D80 /* StackModelProtocol.swift in Sources */,
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
D28A839323CE828900DFE4FC /* HeadlineBodyCaretLinkImageModel.swift in Sources */,
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */,
01EB369323609801006832FA /* HeaderModel.swift in Sources */,
D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */,
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */,
@ -1603,6 +1667,8 @@
014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */,
0ABD136B237B193A0081388D /* EntryFieldContainer.swift in Sources */,
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */,
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */,
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
012A88C2238D7BCA00FE3DA1 /* CarouselItemModel.swift in Sources */,
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
@ -1614,9 +1680,11 @@
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */,
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;

File diff suppressed because it is too large Load Diff

View File

@ -13,12 +13,20 @@ public enum ButtonStyle: String, Codable {
case secondary
}
public enum ButtonSize: String, Codable {
case standard
case tiny
}
public class ButtonModel: MoleculeProtocol {
public static var identifier: String = "button"
public var backgroundColor: Color?
public var title: String
public var action: ActionProtocol
public var style: ButtonStyle?
public var style: ButtonStyle? = .primary
public var size: ButtonSize? = .standard
public var required: Bool?
public var requiredGroups: [String]?
init(with title: String, action: ActionProtocol) {
self.title = title
@ -30,6 +38,9 @@ public class ButtonModel: MoleculeProtocol {
case title
case action
case style
case size
case required
case requiredGroups
}
required public init(from decoder: Decoder) throws {
@ -37,7 +48,14 @@ public class ButtonModel: MoleculeProtocol {
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
title = try typeContainer.decode(String.self, forKey: .title)
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style)
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups)
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
self.style = style
}
if let size = try typeContainer.decodeIfPresent(ButtonSize.self, forKey: .size) {
self.size = size
}
}
public func encode(to encoder: Encoder) throws {
@ -46,5 +64,7 @@ public class ButtonModel: MoleculeProtocol {
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeModel(action, forKey: .action)
try container.encodeIfPresent(style, forKey: .style)
try container.encodeIfPresent(size, forKey: .size)
try container.encodeIfPresent(required, forKey: .required)
}
}

View File

@ -14,6 +14,16 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
guard let model = model as? ButtonModel else { return }
setTitle(model.title, for: .normal)
backgroundColor = model.backgroundColor?.uiColor
self.validationRequired = model.required ?? false
self.requiredGroupsList = model.requiredGroups
if self.validationRequired,
let selfForm = self as? FormValidationEnableDisableProtocol {
FormValidator.setupValidation(molecule: selfForm, delegate: delegateObject?.formValidationProtocol)
}
if let style = model.style {
switch style {
case .primary:
@ -22,6 +32,14 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
setAsSecondaryCustom()
}
}
if let size = model.size {
switch size {
case .standard:
setAsTiny(false)
case .tiny:
setAsTiny(true)
}
}
set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)
}
}

View File

@ -46,6 +46,9 @@ static CGFloat const PrimaryButtonSmallHeight = 30.0;
// set YES to skip highlight method, for customer color button
@property (nonatomic) BOOL skipHighlighted;
@property (nonatomic) BOOL validationRequired;
@property (nullable, nonatomic, strong) NSArray *requiredGroupsList;
// The main creation functions, changed to black button for 2.0 for default
+ (nullable instancetype)primaryButton:(BOOL)enabled;
+ (nullable instancetype)primarySmallButton:(BOOL)enabled;

View File

@ -20,8 +20,6 @@
@interface PrimaryButton() <FormValidationEnableDisableProtocol>
@property (nonatomic) BOOL validationRequired;
@property (nonatomic, strong) NSArray *requiredGroupsList;
@property (nonatomic) BOOL smallButton;
@property (assign, nonatomic) BOOL tinyButton;
@property (nonatomic) CGFloat sizeForSizing;

View File

@ -112,7 +112,9 @@ import UIKit
//if number of colors is even, need to display gradient layer, otherwise make top layer as solid color layer
if graphObject.colors.count % 2 == 0 {
leftColors.removeLast()
topLayer.colors = [leftColors.last!, rightColors.first!]
let firstColor = leftColors.last!.uiColor.cgColor
let secondColor = rightColors.first!.uiColor.cgColor
topLayer.colors = [firstColor, secondColor]
} else {
topLayer.backgroundColor = leftColors.last?.uiColor.cgColor
}
@ -125,7 +127,9 @@ import UIKit
//count of graidentLayer.colors must be bigger than 1, otherwise set backgroundColor
if leftColors.count > 1 {
leftLayer.colors = Array(leftColors)
leftLayer.colors = leftColors.map({ (color) -> CGColor in
return color.uiColor.cgColor
})
} else {
leftLayer.backgroundColor = leftColors.first?.uiColor.cgColor
}
@ -136,7 +140,9 @@ import UIKit
rightLayer.startPoint = CGPoint(x: 0, y: 0)
rightLayer.endPoint = CGPoint(x: 0, y: 1)
if rightColors.count > 1 {
rightLayer.colors = Array(rightColors)
rightLayer.colors = rightColors.map({ (color) -> CGColor in
return color.uiColor.cgColor
})
} else {
rightLayer.backgroundColor = rightColors.first?.uiColor.cgColor
}

View File

@ -244,10 +244,15 @@ public typealias ActionBlock = () -> ()
}
if let fontStyle = labelModel.fontStyle {
MFStyler.styleLabel(self, withStyle: fontStyle)
MFStyler.styleLabel(self, withStyle: fontStyle, genericScaling: false)
standardFontSize = font.pointSize
} else {
let fontSize = labelModel.fontSize
if let fontSize = fontSize {
standardFontSize = fontSize
}
if let fontName = labelModel.fontName {
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? font.pointSize)
font = MFFonts.mfFont(withName: fontName, size: fontSize ?? standardFontSize)
} else if let fontSize = fontSize {
font = font.withSize(fontSize)
}
@ -262,9 +267,9 @@ public typealias ActionBlock = () -> ()
for attribute in attributes {
let range = NSRange(location: attribute.location, length: attribute.length)
switch attribute {
case let underLineAtt as LabelAttributeUnderlineModel:
case let _ as LabelAttributeUnderlineModel:
attributedString.addAttribute(.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
case let strikeAtt as LabelAttributeStrikeThroughModel:
case let _ as LabelAttributeStrikeThroughModel:
attributedString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.thick.rawValue, range: range)
attributedString.addAttribute(.baselineOffset, value: 0, range: range)
case let colorAtt as LabelAttributeColorModel:
@ -309,11 +314,17 @@ public typealias ActionBlock = () -> ()
}
}
case let actionAtt as LabelAttributeActionModel:
addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) {
if let data = try? actionAtt.encode(using: JSONEncoder()), let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
}
addActionAttributes(range: range, string: attributedString)
default:
continue
}
}
attributedText = attributedString
originalAttributedString = attributedText
hero = labelModel.hero
}

View File

@ -12,12 +12,21 @@ class LabelAttributeActionModel: LabelAttributeModel {
override public class var identifier: String {
return "action"
}
var action: ActionProtocol
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
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.encodeModel(action, forKey: .action)
}
private enum CodingKeys: String, CodingKey {
case action
}
}

View File

@ -9,8 +9,8 @@
import UIKit
@objcMembers public class LeftRightLabelModel: MoleculeProtocol {
public static var identifier: String = "leftRightLabel"
public static var identifier: String = "leftRightLabelView"
public var backgroundColor: Color?
public var leftText: LabelModel
public var rightText: LabelModel
public var rightText: LabelModel?
}

View File

@ -0,0 +1,31 @@
//
// MVMCoreUISwitch+Model.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/14/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
// temporary until link is finished
extension MVMCoreUISwitch: ModelMoleculeViewProtocol {
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
guard let model = model as? ToggleModel else { return }
if let castSelf = self as? FormValidationProtocol {
FormValidator.setupValidation(molecule: castSelf, delegate: delegateObject?.formValidationProtocol)
}
setState(model.state, animated: false)
guard let action = model.action else { return }
actionBlock = {
if let data = try? action.encode(using: JSONEncoder()),
let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
}
}
}

View File

@ -423,16 +423,16 @@ const CGFloat SwitchShakeIntensity = 2;
return UIAccessibilityTraitButton;
}
- (NSString * _Nullable)formFieldGroupName {
return [self.json string:@"groupName"];
}
- (NSString *)accessibilityHint {
return [MVMCoreUIUtility hardcodedStringWithKey:@"AccToggleHint"];
}
#pragma mark FormValidationProtocol
- (NSString * _Nullable)formFieldGroupName {
return [self.json string:@"groupName"];
}
- (BOOL)isValidField {
return self.isOn && [self.json boolForKey:@"required"];
}

View File

@ -0,0 +1,425 @@
//
// Toggle.swift
// MVMCoreUI
//
// Created by Kevin Christiano on 12/4/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import MVMCore
import UIKit
public typealias ActionBlockConfirmation = () -> (Bool)
/**
A custom implementation of Apple's UISwitch.
By default this class begins in the off state.
Container: The background of the toggle control.
Knob: The circular indicator that slides on the container.
*/
@objcMembers open class Toggle: Control, MVMCoreUIViewConstrainingProtocol, FormValidationFormFieldProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
/// Holds the on and off colors for the container.
public var containerTintColor: (on: UIColor?, off: UIColor?)? = (on: .mfShamrock(), off: .black)
/// Holds the on and off colors for the knob.
public var knobTintColor: (on: UIColor?, off: UIColor?)? = (on: .white, off: .white)
/// Holds the on and off colors for the disabled state..
public var disabledTintColor: (container: UIColor?, knob: UIColor?)? = (container: .mfSilver(), knob: .white)
/// 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 { return true }
}()
// Sizes are from InVision design specs.
static let containerSize = CGSize(width: 46, height: 24)
static let knobSize = CGSize(width: 22, height: 22)
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)
backgroundColor = isEnabled ? containerTintColor?.off : disabledTintColor?.container
knobView.backgroundColor = isEnabled ? knobTintColor?.off : disabledTintColor?.knob
}
}
/// 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 {
backgroundColor = isOn ? containerTintColor?.on : containerTintColor?.off
knobView.backgroundColor = isOn ? knobTintColor?.on : knobTintColor?.off
self.constrainKnob()
}
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff")
setNeedsLayout()
layoutIfNeeded()
}
}
//--------------------------------------------------
// 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 = !isOn
knobTrailingConstraint?.isActive = isOn
}
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
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
}
public override func setupView() {
super.setupView()
guard subviews.isEmpty else { return }
heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height)
heightConstraint?.isActive = true
widthConstraint = widthAnchor.constraint(equalToConstant: Self.containerSize.width)
widthConstraint?.isActive = true
layer.cornerRadius = Self.containerSize.height / 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
knobTrailingConstraint = trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 1)
knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 1)
knobLeadingConstraint?.isActive = true
accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel")
}
public override func reset() {
super.reset()
backgroundColor = containerTintColor?.off
knobView.backgroundColor = knobTintColor?.off
isAnimated = false
isOn = false
constrainKnob()
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
}
//--------------------------------------------------
// MARK: - UIResponder
//--------------------------------------------------
open override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
UIView.animate(withDuration: 0.1, animations: {
self.knobWidthConstraint?.constant += PaddingOne
self.layoutIfNeeded()
})
}
public override func touchesEnded(_ touches: Set<UITouch>, 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<UITouch>, with event: UIEvent) {
knobReformAnimation()
sendActions(for: .touchCancel)
}
//--------------------------------------------------
// MARK: - Animations
//--------------------------------------------------
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()
}
}
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let toggleModel = model as? ToggleModel else {
return
}
let toggleModelJSON = toggleModel.toJSON()
setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData)
}
}
// MARK: - Accessibility
extension Toggle {
public func formFieldGroupName() -> String? {
return json?["groupName"] as? String
}
}
// MARK: - FormValidationProtocol
extension Toggle {
public func isValidField() -> Bool {
return isOn && json?["required"] as? Bool ?? false
}
public func formFieldName() -> String? {
return json?[KeyFieldKey] as? String ?? ""
}
public func formFieldValue() -> Any? {
return NSNumber(value: isOn)
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Toggle {
public override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
self.delegateObject = delegateObject
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
guard let dictionary = json else { return }
if let color = dictionary["onTintColor"] as? String {
containerTintColor?.on = UIColor.mfGet(forHex: color)
}
if let color = dictionary["offTintColor"] as? String {
containerTintColor?.off = UIColor.mfGet(forHex: color)
}
if let color = dictionary["onKnobTintColor"] as? String {
knobTintColor?.on = UIColor.mfGet(forHex: color)
}
if let color = dictionary["offKnobTintColor"] as? String {
knobTintColor?.off = UIColor.mfGet(forHex: color)
}
if let state = dictionary["state"] as? Bool {
changeStateNoAnimation(state)
}
if let actionMap = dictionary.optionalDictionaryForKey("actionMap") {
didToggleAction = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) }
}
if let isAnimated = dictionary["isAnimated"] as? Bool {
self.isAnimated = isAnimated
}
if let isEnabled = dictionary["isEnabled"] as? Bool{
self.isEnabled = isEnabled
}
}
public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return Self.getContainerHeight()
}
public func needsToBeConstrained() -> Bool {
return true
}
public func alignment() -> UIStackView.Alignment {
return .trailing
}
}

View File

@ -0,0 +1,53 @@
//
// ToggleModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/14/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
public class ToggleModel: MoleculeProtocol {
public static var identifier: String = "toggle"
public var moleculeName: String?
public var backgroundColor: Color?
public var state: Bool = true
public var action: ActionProtocol?
public var required: Bool?
public var fieldKey: String?
enum CodingKeys: String, CodingKey {
case moleculeName
case state
case action
case backgroundColor
case required
case fieldKey
}
public init(_ state: Bool) {
self.state = state
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) {
self.state = state
}
action = try typeContainer.decodeModelIfPresent(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeModelIfPresent(action, forKey: .action)
try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(state, forKey: .state)
try container.encodeIfPresent(required, forKey: .required)
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
}
}

View File

@ -352,6 +352,45 @@
}
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
// Only treated as a container if we are constraining a molecule.
if (!self.constrainedView) {
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
}
if (self.shouldSetupMoleculeFromJSON) {
NSDictionary *moleculeJSON = [json dict:KeyMolecule];
if (self.molecule) {
[self.molecule setWithJSON:moleculeJSON delegateObject:delegateObject additionalData:additionalData];
} else if (moleculeJSON) {
UIView <MVMCoreUIMoleculeViewProtocol>*molecule = [[MVMCoreUIMoleculeMappingObject sharedMappingObject] createMoleculeForJSON:moleculeJSON delegateObject:delegateObject constrainIfNeeded:true];
if (molecule) {
[self addMolecule:molecule];
}
self.molecule = molecule;
[self setMoleculeAccessibility];
}
} else {
[self.molecule setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
}
NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"];
if (useHorizontalMargins) {
self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue];
}
NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"];
if (useVerticalMargins) {
self.updateViewVerticalDefaults = [useVerticalMargins boolValue];
}
// Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment.
NSString *alignment = [json string:@"horizontalAlignment"];
if (alignment) {
[self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]];
}
alignment = [json string:@"verticalAlignment"];
if (alignment) {
[self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]];
}
if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) {
self.backgroundColor = self.molecule.backgroundColor;
}

View File

@ -81,6 +81,7 @@ extension Control: MVMCoreViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Control: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.json = json

View File

@ -40,16 +40,24 @@ import UIKit
}
}
public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model
if let backgroundColor = model?.backgroundColor {
self.backgroundColor = backgroundColor.uiColor
}
}
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
public class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
}
// MARK:- MVMCoreViewProtocol
@ -61,6 +69,7 @@ extension View: MVMCoreViewProtocol {
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0)
}
}

View File

@ -101,7 +101,9 @@
[self parsePageJSONAndReturnError:&parseError];
if (parseError) {
if (error) {
*error = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
MVMCoreErrorObject *errorObject = [MVMCoreErrorObject createErrorObjectForNSError:parseError location:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject]];
errorObject.messageToDisplay = [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess];
*error = errorObject;
}
return false;
}

View File

@ -196,7 +196,7 @@ public class ContainerHelper: NSObject {
}
}
open class Container: View {
open class Container: View, ContainerProtocol {
var view: UIView?
let containerHelper = ContainerHelper()
var containerModel: ContainerModelProtocol? {
@ -208,6 +208,19 @@ open class Container: View {
guard let containerModel = model as? ContainerModelProtocol else { return }
containerHelper.set(with: containerModel, for: view as? MVMCoreUIViewConstrainingProtocol)
}
// MARK:- ContainerProtocol
public func alignHorizontal(_ alignment: UIStackView.Alignment) {
containerHelper.alignHorizontal(alignment)
}
public func alignVertical(_ alignment: UIStackView.Alignment) {
containerHelper.alignVertical(alignment)
}
public func constrainView(_ view: UIView) {
containerHelper.constrainView(view)
}
}
// MARK: - MVMCoreViewProtocol

View File

@ -0,0 +1,265 @@
//
// Container.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/11/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public protocol ContainerModelProtocol: Model {
var horizontalAlignment: UIStackView.Alignment? { get set }
var verticalAlignment: UIStackView.Alignment? { get set }
var useHorizontalMargins: Bool? { get set }
var useVerticalMargins: Bool? { get set }
}
public class ContainerHelper: NSObject {
var leftConstraint: NSLayoutConstraint?
var topConstraint: NSLayoutConstraint?
var bottomConstraint: NSLayoutConstraint?
var rightConstraint: NSLayoutConstraint?
var alignCenterHorizontalConstraint: NSLayoutConstraint?
var alignCenterLeftConstraint: NSLayoutConstraint?
var alignCenterRightConstraint: NSLayoutConstraint?
var alignCenterVerticalConstraint: NSLayoutConstraint?
var alignCenterTopConstraint: NSLayoutConstraint?
var alignCenterBottomConstraint: NSLayoutConstraint?
var leftLowConstraint: NSLayoutConstraint?
var topLowConstraint: NSLayoutConstraint?
var bottomLowConstraint: NSLayoutConstraint?
var rightLowConstraint: NSLayoutConstraint?
func constrainView(_ view: UIView) {
guard let margins = view.superview?.layoutMarginsGuide else { return }
leftConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor)
leftConstraint?.isActive = true
topConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor)
topConstraint?.isActive = true
rightConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor)
rightConstraint?.isActive = true
bottomConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor)
bottomConstraint?.isActive = true
alignCenterHorizontalConstraint = view.centerXAnchor.constraint(equalTo: margins.centerXAnchor)
alignCenterLeftConstraint = view.leftAnchor.constraint(greaterThanOrEqualTo: margins.leftAnchor)
alignCenterRightConstraint = margins.rightAnchor.constraint(greaterThanOrEqualTo: view.rightAnchor)
alignCenterVerticalConstraint = view.centerYAnchor.constraint(equalTo: margins.centerYAnchor)
alignCenterTopConstraint = view.topAnchor.constraint(greaterThanOrEqualTo: margins.topAnchor)
alignCenterBottomConstraint = margins.bottomAnchor.constraint(greaterThanOrEqualTo: view.bottomAnchor)
leftLowConstraint = view.leftAnchor.constraint(equalTo: margins.leftAnchor)
leftLowConstraint?.priority = UILayoutPriority(rawValue: 200)
leftLowConstraint?.isActive = true
topLowConstraint = view.topAnchor.constraint(equalTo: margins.topAnchor)
topLowConstraint?.priority = UILayoutPriority(rawValue: 200)
topLowConstraint?.isActive = true
rightLowConstraint = margins.rightAnchor.constraint(equalTo: view.rightAnchor)
rightLowConstraint?.priority = UILayoutPriority(rawValue: 200)
rightLowConstraint?.isActive = true
bottomLowConstraint = margins.bottomAnchor.constraint(equalTo: view.bottomAnchor)
bottomLowConstraint?.priority = UILayoutPriority(rawValue: 200)
bottomLowConstraint?.isActive = true
setAccessibility(view)
}
func setAccessibility(_ view: UIView) {
guard let superView = view.superview else { return }
superView.isAccessibilityElement = false
if let elements = view.accessibilityElements {
superView.accessibilityElements = elements
} else {
superView.accessibilityElements = [view]
}
}
func alignHorizontal(_ alignment: UIStackView.Alignment) {
switch alignment {
case .center:
alignCenterHorizontalConstraint?.isActive = true
alignCenterLeftConstraint?.isActive = true
alignCenterRightConstraint?.isActive = true
leftConstraint?.isActive = false
rightConstraint?.isActive = false
case .leading:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = false
alignCenterRightConstraint?.isActive = true
leftConstraint?.isActive = true
rightConstraint?.isActive = false
case .trailing:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = true
alignCenterRightConstraint?.isActive = false
leftConstraint?.isActive = false
rightConstraint?.isActive = true
case .fill:
alignCenterHorizontalConstraint?.isActive = false
alignCenterLeftConstraint?.isActive = false
alignCenterRightConstraint?.isActive = false
leftConstraint?.isActive = true
rightConstraint?.isActive = true
default: break
}
}
func alignVertical(_ alignment: UIStackView.Alignment) {
switch alignment {
case .center:
alignCenterVerticalConstraint?.isActive = true
alignCenterTopConstraint?.isActive = true
alignCenterBottomConstraint?.isActive = true
topConstraint?.isActive = false
bottomConstraint?.isActive = false
case .leading:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = false
alignCenterBottomConstraint?.isActive = true
topConstraint?.isActive = true
bottomConstraint?.isActive = false
case .trailing:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = true
alignCenterBottomConstraint?.isActive = false
topConstraint?.isActive = false
bottomConstraint?.isActive = true
case .fill:
alignCenterVerticalConstraint?.isActive = false
alignCenterTopConstraint?.isActive = false
alignCenterBottomConstraint?.isActive = false
topConstraint?.isActive = true
bottomConstraint?.isActive = true
default: break
}
}
func set(with model: ContainerModelProtocol) {
if let horizontalAlignment = model.horizontalAlignment {
alignHorizontal(horizontalAlignment)
}
if let verticalAlignment = model.verticalAlignment {
alignVertical(verticalAlignment)
}
}
static func getAlignment(for string: String) -> UIStackView.Alignment? {
switch string {
case "leading":
return .leading
case "trailing":
return .trailing
case "center":
return .center
case "fill":
return .fill
default:
return nil
}
}
static func getAlignmentString(for alignment: UIStackView.Alignment?) -> String? {
switch alignment {
case .leading:
return "leading"
case .trailing:
return "trailing"
case .center:
return "center"
case .fill:
return "fill"
default:
return nil
}
}
func set(with JSON: [AnyHashable: Any]?, for contained: UIView) {
if let horizontalAlignmentString = JSON?.optionalStringForKey("horizontalAlignment"), let alignment = ContainerHelper.getAlignment(for: horizontalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
alignHorizontal(alignment)
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() {
alignHorizontal(alignment)
}
if let verticalAlignmentString = JSON?.optionalStringForKey("verticalAlignment"), let alignment = ContainerHelper.getAlignment(for: verticalAlignmentString) ?? (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
alignVertical(alignment)
} else if let alignment = (contained as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() {
alignVertical(alignment)
}
}
}
open class Container: View {
<<<<<<< HEAD
=======
var containerModel: ContainerModelProtocol?
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
var view: UIView?
let containerHelper = ContainerHelper()
var containerModel: ContainerModelProtocol? {
get { return model as? ContainerModelProtocol }
}
var topMarginPadding: CGFloat = 0
var bottomMarginPadding: CGFloat = 0
override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let containerModel = model as? ContainerModelProtocol else { return }
containerHelper.set(with: containerModel)
}
}
// MARK: - MVMCoreViewProtocol
public extension Container {
override func updateView(_ size: CGFloat) {
super.updateView(size)
(view as? MVMCoreViewProtocol)?.updateView(size)
MFStyler.setMarginsFor(self, size: size, defaultHorizontal: containerModel?.useHorizontalMargins ?? true, top: containerModel?.useHorizontalMargins ?? true ? topMarginPadding : 0, bottom: containerModel?.useHorizontalMargins ?? true ? bottomMarginPadding : 0)
}
/// Will be called only once.
override func setupView() {
super.setupView()
backgroundColor = .clear
}
func addAndContain(_ view: UIView) {
view.translatesAutoresizingMaskIntoConstraints = false
addSubview(view)
containerHelper.constrainView(view)
self.view = view
}
convenience init(andContain view: UIView) {
self.init()
addAndContain(view)
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public extension Container {
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
guard let view = view else { return }
containerHelper.set(with: json, for: view)
}
override func reset() {
super.reset()
(view as? MVMCoreUIMoleculeViewProtocol)?.reset?()
}
func setAsMolecule() {
(view as? MVMCoreUIMoleculeViewProtocol)?.setAsMolecule?()
}
}

View File

@ -0,0 +1,15 @@
//
// ContainerProtocol.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol ContainerProtocol {
func alignHorizontal(_ alignment: UIStackView.Alignment)
func alignVertical(_ alignment: UIStackView.Alignment)
func constrainView(_ view: UIView)
}

View File

@ -16,11 +16,33 @@ import Foundation
enum FooterCodingKeys: String, CodingKey {
case backgroundColor
}
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = PaddingDefaultVerticalSpacing
}
if bottomMarginPadding == nil {
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
try super.init(from: decoder)
setDefaults()
}
public override func encode(to encoder: Encoder) throws {

View File

@ -0,0 +1,37 @@
//
// FooterModel.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 11/27/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class FooterModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "footer"
public var backgroundColor: Color?
enum FooterCodingKeys: String, CodingKey {
case backgroundColor
}
required public init(from decoder: Decoder) throws {
<<<<<<< HEAD
let typeContainer = try decoder.container(keyedBy: FooterCodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
try super.init(from: decoder)
=======
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
self.backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
self.molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
>>>>>>> 83b0a554049f764888ce9db27dbd7fa503fddf01
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: FooterCodingKeys.self)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
}
}

View File

@ -18,19 +18,34 @@ import Foundation
case line
case backgroundColor
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
// Default Values
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = PaddingDefaultVerticalSpacing
}
if bottomMarginPadding == nil {
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
line?.type = .heavy
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let typeContainer = try decoder.container(keyedBy: HeaderCodingKeys.self)
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
setDefaults()
}
public override func encode(to encoder: Encoder) throws {

View File

@ -19,6 +19,11 @@ public final class Color: Codable {
//--------------------------------------------------
public let uiColor: UIColor
public var cgColor: CGColor {
return uiColor.cgColor
}
public private(set) var hex: String = ""
public private(set) var name: String = ""

View File

@ -0,0 +1,186 @@
//
// DoughnutChart.swift
// MVMCoreUI
//
// Created by Murugan, Vimal on 07/01/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
open class DoughnutChart: View {
var doughnutLayer = CALayer()
var titleLabel = Label.commonLabelH3(true)
var subTitleLabel = Label.commonLabelB2(true)
var doughnutChartModel: DoughnutChartModel? {
get { return model as? DoughnutChartModel }
}
var labelContainer = MVMCoreUICommonViewsUtility.commonView()
var labelContainerLeftConstraint: NSLayoutConstraint?
var labelContainerTopConstraint: NSLayoutConstraint?
var labelContainerBottomConstraint: NSLayoutConstraint?
var labelContainerRightConstraint: NSLayoutConstraint?
var heightConstraint: NSLayoutConstraint?
static let heightConstant: CGFloat = 150
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: heightConstant)!
var height: CGFloat = heightConstant {
didSet {
if height != oldValue {
sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: height)!
updateContainer()
drawGraph()
}
}
}
open override func updateView(_ size: CGFloat) {
super.updateView(size)
titleLabel.updateView(size)
subTitleLabel.updateView(size)
updateContainer()
drawGraph()
}
open override func reset() {
super.reset()
titleLabel.reset()
subTitleLabel.reset()
clearLayers()
}
public override func setAsMolecule() {
titleLabel.setAsMolecule()
subTitleLabel.setAsMolecule()
}
open override func setupView() {
super.setupView()
guard labelContainer.superview == nil else {
return
}
addSubview(labelContainer)
labelContainer.addSubview(titleLabel)
labelContainer.addSubview(subTitleLabel)
titleLabel.textAlignment = .center
subTitleLabel.textAlignment = .center
//Make label font size to adjust width if label content is high
titleLabel.numberOfLines = 1
titleLabel.adjustsFontSizeToFitWidth = true
layer.addSublayer(doughnutLayer)
heightConstraint = heightAnchor.constraint(equalToConstant:
sizeObject.getValueBasedOnApplicationWidth())
heightConstraint?.isActive = true
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
labelContainerLeftConstraint = labelContainer.leftAnchor.constraint(greaterThanOrEqualTo: leftAnchor, constant: lineWidth())
labelContainerLeftConstraint?.isActive = true
labelContainerTopConstraint = labelContainer.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: lineWidth())
labelContainerTopConstraint?.isActive = true
labelContainerRightConstraint = rightAnchor.constraint(greaterThanOrEqualTo: labelContainer.rightAnchor, constant: lineWidth())
labelContainerRightConstraint?.isActive = true
labelContainerBottomConstraint = bottomAnchor.constraint(greaterThanOrEqualTo: labelContainer.bottomAnchor, constant: lineWidth())
labelContainerBottomConstraint?.isActive = true
labelContainer.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
labelContainer.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
NSLayoutConstraint.constraintPinSubview(titleLabel, pinTop: true, pinBottom: false, pinLeft: true, pinRight: true)
NSLayoutConstraint.constraintPinSubview(subTitleLabel, pinTop: false, pinBottom: true, pinLeft: true, pinRight: true)
_ = NSLayoutConstraint(pinFirstView: titleLabel, toSecondView: subTitleLabel, withConstant: 0, directionVertical: true)
//Rotate view for initial draw
doughnutLayer.transform = CATransform3DMakeRotation(1 * .pi, 0.0, 0.0, 1.0)
}
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
clearLayers()
guard let doughnutChartModel = doughnutChartModel else {
return
}
titleLabel.setWithModel(doughnutChartModel.title, delegateObject, additionalData)
subTitleLabel.setWithModel(doughnutChartModel.subtitle, delegateObject, additionalData)
titleLabel.textAlignment = .center
subTitleLabel.textAlignment = .center
updateLabelContainer()
drawGraph()
}
func drawGraph() {
clearLayers()
let widthHeight = sizeObject.getValueBasedOnApplicationWidth()
doughnutLayer.frame = CGRect(x: 0, y: 0,
width: widthHeight,
height: widthHeight)
if let doughnutChart = doughnutChartModel {
var prevPercent: CGFloat = 0.0
for model in doughnutChart.sections {
prevPercent += drawBar(model, prevPercent)
}
}
}
func drawBar(_ chartModel: DoughnutChartItemModel, _ prevPercent: CGFloat) -> CGFloat {
let shapeLayer = CAShapeLayer()
shapeLayer.frame = doughnutLayer.frame
shapeLayer.lineWidth = lineWidth()
shapeLayer.fillColor = nil
shapeLayer.strokeColor = chartModel.color.uiColor.cgColor
let arcCenter = shapeLayer.position
let radius = shapeLayer.bounds.size.width / 2.0 - lineWidth()/2.0
let value: CGFloat = chartModel.percent
let gap: CGFloat = spaceRequired() ? lineGap() : 0.0
let startAngle = ((prevPercent / 100.0) * 2 * .pi) - (0.5 * .pi)
let endAngle = ((value / 100.0) * 2 * .pi) + startAngle - gap
let circlePath = UIBezierPath(arcCenter: arcCenter,
radius: radius,
startAngle: startAngle,
endAngle: endAngle,
clockwise: true)
shapeLayer.path = circlePath.cgPath
doughnutLayer.addSublayer(shapeLayer)
return value
}
func clearLayers() {
doughnutLayer.sublayers?.forEach({ $0.removeFromSuperlayer() })
}
func updateContainer() {
heightConstraint?.constant = sizeObject.getValueBasedOnApplicationWidth()
updateLabelContainer()
setNeedsDisplay()
}
func lineWidth() -> CGFloat {
return 30
}
func lineGap() -> CGFloat {
//If array is having the single item then no space required
return doughnutChartModel?.sections.count == 1 ? 0.0 : 0.05
}
func spaceRequired() -> Bool {
return doughnutChartModel?.spaceRequired ?? true
}
func updateLabelContainer() {
labelContainer.setNeedsDisplay()
labelContainer.layoutIfNeeded()
let radius = sizeObject.getValueBasedOnApplicationWidth()/2 - lineWidth()
let labelheight = labelContainer.frame.height/2
let padding = sizeObject.getValueBasedOnApplicationWidth()/2 - sqrt(pow(radius, 2) - pow(labelheight, 2))
labelContainerLeftConstraint?.constant = padding
labelContainerRightConstraint?.constant = padding
labelContainerTopConstraint?.constant = max(radius - labelheight, labelheight)
labelContainerBottomConstraint?.constant = max(radius - labelheight, labelheight)
}
}

View File

@ -0,0 +1,36 @@
//
// DoughnutChartModel.swift
// MVMCoreUI
//
// Created by Murugan, Vimal on 10/01/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class DoughnutChartModel: MoleculeProtocol {
public var backgroundColor: Color?
public static var identifier: String = "doughnutChart"
public var title: LabelModel?
public var subtitle: LabelModel?
public var sections: [DoughnutChartItemModel]
public var spaceRequired: Bool?
public init(sections: [DoughnutChartItemModel]) {
self.sections = sections
}
}
@objcMembers public class DoughnutChartItemModel: MoleculeProtocol {
public var backgroundColor: Color?
public static var identifier: String = "doughnutChartItem"
public var label: LabelModel
@Percent public var percent: CGFloat
public var color: Color
public init(percent: CGFloat, color: Color, label: LabelModel) {
self.percent = percent
self.color = color
self.label = label
}
}

View File

@ -0,0 +1,160 @@
//
// DoughnutChartView.swift
// MVMCoreUI
//
// Created by Murugan, Vimal on 26/12/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers open class DoughnutChartView: View {
var doughnutChart = DoughnutChart(frame: CGRect.zero)
var colorLablesStack = ColorViewLabelsStack()
var doughnutChartModel: DoughnutChartModel? {
get { return model as? DoughnutChartModel }
}
open override func setupView() {
super.setupView()
guard doughnutChart.superview == nil else {
return
}
doughnutChart.translatesAutoresizingMaskIntoConstraints = false
addSubview(doughnutChart)
colorLablesStack.translatesAutoresizingMaskIntoConstraints = false
addSubview(colorLablesStack)
doughnutChart.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
doughnutChart.topAnchor.constraint(equalTo: topAnchor, constant: PaddingFour).isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: doughnutChart.bottomAnchor).isActive = true
let doughnutBottomAnchor = bottomAnchor.constraint(equalTo: doughnutChart.bottomAnchor)
doughnutBottomAnchor.priority = UILayoutPriority(rawValue: 200)
doughnutBottomAnchor.isActive = true
let colorLablesBottomAnchor = bottomAnchor.constraint(equalTo: colorLablesStack.bottomAnchor)
colorLablesBottomAnchor.priority = UILayoutPriority(rawValue: 204)
colorLablesBottomAnchor.isActive = true
let colorLablesTopAnchor = colorLablesStack.topAnchor.constraint(equalTo: doughnutChart.topAnchor)
colorLablesTopAnchor.priority = .defaultLow
colorLablesTopAnchor.isActive = true
colorLablesStack.topAnchor.constraint(greaterThanOrEqualTo: doughnutChart.topAnchor).isActive = true
bottomAnchor.constraint(greaterThanOrEqualTo: colorLablesStack.bottomAnchor).isActive = true
trailingAnchor.constraint(equalTo: colorLablesStack.trailingAnchor).isActive = true
let centerY = colorLablesStack.centerYAnchor.constraint(equalTo: doughnutChart.centerYAnchor)
centerY.priority = UILayoutPriority(rawValue: 500)
centerY.isActive = true
colorLablesStack.leadingAnchor.constraint(equalTo: doughnutChart.trailingAnchor, constant: PaddingThree).isActive = true
colorLablesStack.backgroundColor = .clear
}
open override func updateView(_ size: CGFloat) {
super.updateView(size)
doughnutChart.updateView(size)
colorLablesStack.updateView(size)
}
open override func reset() {
super.reset()
doughnutChart.reset()
colorLablesStack.reset()
}
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = doughnutChartModel else { return }
doughnutChart.setWithModel(model, delegateObject, additionalData)
// Create the stack model
var stackItems: [MoleculeStackItemModel] = []
for item in model.sections {
stackItems.append(MoleculeStackItemModel(with: item))
}
let stack = MoleculeStackModel(molecules: stackItems)
stack.verticalAlignment = .fill
colorLablesStack.setWithModel(stack, delegateObject, additionalData)
}
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: DoughnutChartModel.self) else { return }
setWithModel(model, delegateObject, additionalData)
}
}
extension DoughnutChartView: MVMCoreUIViewConstrainingProtocol {
open func horizontalAlignment() -> UIStackView.Alignment {
return .leading
}
}
class ColorViewLabelsStack: MoleculeStackView {
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
guard let stackItemModels = stackModel?.molecules else { return }
for model in stackItemModels {
let view = ColorViewWithLabel()
let stackItem = MoleculeStackItem(andContain: view)
stackItem.setWithModel(model, delegate, nil)
stackItems.append(stackItem)
}
}
}
class ColorViewWithLabel: View {
var label = Label.commonLabelB2(true)
var colorView = MVMCoreUICommonViewsUtility.commonView()
private var sizeObject = MFStyler.sizeObjectGeneric(forCurrentDevice: 8)!
var heightConstraint: NSLayoutConstraint?
override func setupView() {
super.setupView()
guard colorView.superview == nil else {
return
}
translatesAutoresizingMaskIntoConstraints = false
addSubview(colorView)
addSubview(label)
heightConstraint = colorView.heightAnchor.constraint(equalToConstant: sizeObject.getValueBasedOnApplicationWidth())
heightConstraint?.isActive = true
colorView.widthAnchor.constraint(equalTo: colorView.heightAnchor).isActive = true
colorView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
colorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
label.leadingAnchor.constraint(equalTo: colorView.trailingAnchor, constant: PaddingOne).isActive = true
label.topAnchor.constraint(equalTo: topAnchor).isActive = true
trailingAnchor.constraint(equalTo: label.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
}
override func updateView(_ size: CGFloat) {
super.updateView(size)
label.updateView(size)
heightConstraint?.constant = sizeObject.getValueBased(onSize: size)
setNeedsDisplay()
}
override func reset() {
super.reset()
label.reset()
}
override func setAsMolecule() {
label.setAsMolecule()
}
override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let chartItemModel = model as? DoughnutChartItemModel else {
return
}
label.setWithModel(chartItemModel.label, delegateObject, additionalData)
colorView.backgroundColor = chartItemModel.color.uiColor
}
}

View File

@ -84,17 +84,19 @@ import UIKit
}
open func setupConstraintsForViewWithButtons() {
guard let viewForButtons = viewForButtons, let primaryButton = primaryButton, let secondaryButton = secondaryButton else {
return
}
guard let viewForButtons = viewForButtons,
let primaryButton = primaryButton,
let secondaryButton = secondaryButton
else { return }
viewForButtons.addSubview(primaryButton)
viewForButtons.addSubview(secondaryButton)
secondaryButton.widthAnchor.constraint(equalTo: primaryButton.widthAnchor, multiplier: 1).isActive = true
secondaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true
primaryButton.topAnchor.constraint(equalTo: viewForButtons.topAnchor).isActive = true
viewForButtons.bottomAnchor.constraint(equalTo: secondaryButton.bottomAnchor).isActive = true
viewForButtons.bottomAnchor.constraint(equalTo: primaryButton.bottomAnchor).isActive = true
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[leftButton]-10-[rightButton]-0-|", options: NSLayoutConstraint.FormatOptions.alignAllCenterY, metrics: nil, views: ["leftButton": secondaryButton, "rightButton": primaryButton]))
NSLayoutConstraint.constraintPinSubview(primaryButton, pinTop: true, pinBottom: true, pinLeft: true, pinRight: false)
NSLayoutConstraint.constraintPinSubview(secondaryButton, pinTop: false, pinBottom: false, pinLeft: false, pinRight: true)
let constraint = secondaryButton.leadingAnchor.constraint(equalTo: primaryButton.trailingAnchor, constant: 10)
constraint.priority = UILayoutPriority(900)
constraint.isActive = true
}
func setupWithTwoButtons() {
@ -107,7 +109,6 @@ import UIKit
pinView(toSuperView: viewForButtons)
alignCenterHorizontal()
createPrimaryButton()
createSecondaryButton()
setupConstraintsForViewWithButtons()
@ -297,8 +298,8 @@ extension TwoButtonView {
}
}
extension TwoButtonView: MoleculeViewProtocol {
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
extension TwoButtonView: ModelMoleculeViewProtocol {
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? TwoButtonViewModel else { return }
setupUI(primaryButtonShowing: model.primaryButton != nil, secondaryButtonShowing: model.secondaryButton != nil)
setDefaultCustom()

View File

@ -24,6 +24,27 @@ import MVMCore
case line
case style
}
/// Defaults to set
func setDefaults() {
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
if topMarginPadding == nil {
topMarginPadding = 24
}
if bottomMarginPadding == nil {
bottomMarginPadding = 24
}
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
setDefaults()
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: ListItemCodingKeys.self)
@ -34,15 +55,8 @@ import MVMCore
if let style = try typeContainer.decodeIfPresent(String.self, forKey: .style) {
self.style = style
}
try super.init(from: decoder)
if useHorizontalMargins == nil {
useHorizontalMargins = true
}
if useVerticalMargins == nil {
useVerticalMargins = true
}
setDefaults()
}
public override func encode(to encoder: Encoder) throws {

View File

@ -92,7 +92,7 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
}
if molecule == nil {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, true) {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(collectionModel.molecule, delegateObject, false) {
contentView.insertSubview(moleculeView, at: 0)
containerHelper.constrainView(moleculeView)
molecule = moleculeView
@ -114,11 +114,13 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
backgroundColor = .white
}
public class func name(forReuse molecule: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let molecule = molecule?.optionalDictionaryForKey(KeyMolecule) else {
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let molecule = (model as? CarouselItemModel)?.molecule,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) as? ModelMoleculeViewProtocol.Type,
let name = moleculeClass.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
return nil
}
return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName)
return name
}
public func updateView(_ size: CGFloat) {

View File

@ -0,0 +1,16 @@
//
// MoleculeStackItem.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/13/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
// A list item that contains a molecule
import UIKit
open class MoleculeStackItem: MoleculeContainer {
var stackItemModel: StackItemModel? {
get { return model as? StackItemModel }
}
}

View File

@ -0,0 +1,45 @@
//
// MoleculeStackItem.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 10/4/19.
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
import Foundation
@objcMembers public class MoleculeStackItemModel: MoleculeContainerModel, MoleculeProtocol, StackItemModelProtocol {
public static var identifier: String = "stackItem"
public var backgroundColor: Color?
public var spacing: CGFloat?
public var percent: Int?
public var gone: Bool = false
enum MoleculeStackItemCodingKeys: String, CodingKey {
case spacing
case percent
case gone
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
percent = try typeContainer.decodeIfPresent(Int.self, forKey: .percent)
if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) {
self.gone = gone
}
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
try container.encodeIfPresent(spacing, forKey: .spacing)
try container.encodeIfPresent(percent, forKey: .percent)
try container.encode(gone, forKey: .gone)
}
}

View File

@ -13,24 +13,23 @@ import UIKit
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model,
let moleculeModel = (model as? ListItemModel)?.molecule,
let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, true) else {
return
guard let moleculeModel = (model as? ListItemModel)?.molecule else { return }
if molecule != nil {
(molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeModel, delegateObject, additionalData)
} else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject, false) {
addMolecule(moleculeView)
}
addMolecule(moleculeView)
}
public override class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moleculeModel = (molecule as? ListItemModel)?.molecule else {
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moleculeModel = (model as? ListItemModel)?.molecule else {
return "\(self)<>"
}
let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol
let moleculeName = className?.nameForReuse(molecule, delegateObject) ?? moleculeModel.moleculeName ?? ""
let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type
let moleculeName = className?.nameForReuse(moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? ""
return "\(self)<\(moleculeName)>"
}
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule),
let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else {
@ -39,7 +38,7 @@ import UIKit
return theClass.requiredModules?(moleculeJSON, delegateObject: delegateObject, error: error)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
guard let moleculeModel = (molecule as? MoleculeContainerModel)?.molecule,
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type,
let height = classType.estimatedHeight(forRow: moleculeModel, delegateObject: delegateObject) else {

View File

@ -2,13 +2,13 @@
// StackItem.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/13/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
import Foundation
open class StackItem: MoleculeContainer {
open class StackItem: Container {
var stackItemModel: StackItemModel? {
get { return model as? StackItemModel }
}

View File

@ -0,0 +1,100 @@
//
// StackItem.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 12/13/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
open class StackItemModel: ContainerModelProtocol, MoleculeProtocol {
public static var identifier: String = "stackItem"
public var backgroundColor: String?
public var view: StackItem?
public var molecule: MoleculeProtocol
public var spacing: CGFloat? = 16
public var percentage: Int? = 0
public var verticalAlignment: UIStackView.Alignment?
public var horizontalAlignment: UIStackView.Alignment?
public var useHorizontalMargins: Bool? = false
public var useVerticalMargins: Bool? = false
public var gone: Bool? = false
<<<<<<< HEAD
enum CodingKeys: String, CodingKey {
case molecule
case spacing
case percentage
case verticalAlignment
case horizontalAlignment
case useHorizontalMargins
case useVerticalMargins
case gone
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
molecule = try typeContainer.decodeMolecule(codingKey: .molecule)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage)
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
}
if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
}
useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins)
useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins)
gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeModel(molecule, forKey: .molecule)
try container.encodeIfPresent(spacing, forKey: .spacing)
try container.encodeIfPresent(percentage, forKey: .percentage)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins)
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
try container.encodeIfPresent(gone, forKey: .gone)
=======
init(with view: StackItem) {
self.view = view
view.containerModel = self
}
init(with view: StackItem, json: [AnyHashable: Any]?) {
self.view = view
view.containerModel = self
update(with: json)
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
}
func update(with json: [AnyHashable: Any]?) {
gone = json?.boolForKey("gone") ?? (json == nil)
spacing = json?.optionalCGFloatForKey("spacing")
percentage = json?["percent"] as? Int
if let horizontalAlignmentString = json?.optionalStringForKey("horizontalAlignment") {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
} else {
horizontalAlignment = nil
}
if let verticalAlignmentString = json?.optionalStringForKey("verticalAlignment") {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
} else {
verticalAlignment = nil
}
useHorizontalMargins = json?.optionalBoolForKey("useHorizontalMargins") ?? false
useVerticalMargins = json?.optionalBoolForKey("useVerticalMargins") ?? false
}
}
open class StackItem: MoleculeContainer {
}

View File

@ -1,45 +1,20 @@
//
// MoleculeStackItem.swift
// StackItemModel.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 10/4/19.
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class StackItemModel: MoleculeContainerModel, MoleculeProtocol {
public static var identifier: String = "stackItem"
public var backgroundColor: Color?
@objcMembers public class StackItemModel: StackItemModelProtocol, Codable {
public var spacing: CGFloat?
public var percentage: Int? = 0
public var percent: Int?
public var gone: Bool = false
enum MoleculeStackItemCodingKeys: String, CodingKey {
case spacing
case percentage
case gone
}
public override init(with moleculeModel: MoleculeProtocol) {
super.init(with: moleculeModel)
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing)
percentage = try typeContainer.decodeIfPresent(Int.self, forKey: .percentage)
if let gone = try typeContainer.decodeIfPresent(Bool.self, forKey: .gone) {
self.gone = gone
}
try super.init(from: decoder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: MoleculeStackItemCodingKeys.self)
try container.encodeIfPresent(spacing, forKey: .spacing)
try container.encodeIfPresent(percentage, forKey: .percentage)
try container.encode(gone, forKey: .gone)
public convenience init(gone: Bool) {
self.init()
self.gone = gone
}
}

View File

@ -0,0 +1,15 @@
//
// StackItemModelProtocol.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol StackItemModelProtocol {
var spacing: CGFloat? { get set }
var percent: Int? { get set }
var gone: Bool { get set }
}

View File

@ -179,15 +179,20 @@ import UIKit
backgroundColor = .white
}
public class func name(forReuse molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
return molecule?.moleculeName ?? ""
public class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
}
// MARK: - Arrow
/// Adds the standard mvm style caret to the accessory view
@objc public func addCaretViewAccessory() {
guard accessoryView == nil else { return }
caretView = CaretView(lineWidth: 1)
caretView?.translatesAutoresizingMaskIntoConstraints = true
caretView?.size = .small(.vertical)
caretView?.setConstraints()

View File

@ -8,8 +8,8 @@
import UIKit
@objcMembers public class CornerLabels: ViewConstrainingView {
@objcMembers public class CornerLabels: View {
var middleView: UIView?
let topLeftLabel = Label.commonLabelB1(true)
let topRightLabel = Label.commonLabelB1(true)
let bottomLeftLabel = Label.commonLabelB3(true)
@ -38,18 +38,19 @@ import UIKit
var topLabelToMoleculeConstraint: NSLayoutConstraint?
var bottomLabelToMoleculeConstraint: NSLayoutConstraint?
public override func addMolecule(_ molecule: UIView) {
insertSubview(molecule, at: 0)
public func addMiddleView(_ view: UIView) {
insertSubview(view, at: 0)
topLabelToMoleculeConstraint?.isActive = false
bottomLabelToMoleculeConstraint?.isActive = false
molecule.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
layoutMarginsGuide.rightAnchor.constraint(equalTo: molecule.rightAnchor).isActive = true
view.leftAnchor.constraint(equalTo: layoutMarginsGuide.leftAnchor).isActive = true
layoutMarginsGuide.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
topLabelToMoleculeConstraint = molecule.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule)
topLabelToMoleculeConstraint = view.topAnchor.constraint(equalTo: topLabelsView.bottomAnchor, constant: spaceAboveMolecule)
topLabelToMoleculeConstraint?.isActive = true
bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: molecule.bottomAnchor, constant: spaceBelowMolecule)
bottomLabelToMoleculeConstraint = bottomLabelsView.topAnchor.constraint(equalTo: view.bottomAnchor, constant: spaceBelowMolecule)
bottomLabelToMoleculeConstraint?.isActive = true
self.middleView = view
}
// MARK: - MVMCoreViewProtocol
@ -59,12 +60,11 @@ import UIKit
topRightLabel.updateView(size)
bottomLeftLabel.updateView(size)
bottomRightLabel.updateView(size)
(middleView as? MVMCoreViewProtocol)?.updateView(size)
}
public override func setupView() {
super.setupView()
shouldSetupMoleculeFromJSON = true
guard topLeftLabel.superview == nil else {
return
}
@ -141,17 +141,6 @@ import UIKit
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
topLeftLabel.setWithJSON(json?.optionalDictionaryForKey("topLeftLabel"), delegateObject: delegateObject, additionalData: additionalData)
topRightLabel.setWithJSON(json?.optionalDictionaryForKey("topRightLabel"), delegateObject: delegateObject, additionalData: additionalData)
bottomLeftLabel.setWithJSON(json?.optionalDictionaryForKey("bottomLeftLabel"), delegateObject: delegateObject, additionalData: additionalData)
bottomRightLabel.setWithJSON(json?.optionalDictionaryForKey("bottomRightLabel"), delegateObject: delegateObject, additionalData: additionalData)
topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
}
public override func setAsMolecule() {
super.setAsMolecule()
styleDefault()
@ -163,8 +152,7 @@ import UIKit
styleDefault()
spaceAboveMolecule = 6.0
spaceBelowMolecule = 6.0
molecule?.reset?()
(middleView as? MoleculeViewProtocol)?.reset?()
}
func styleDefault() {
@ -174,25 +162,27 @@ import UIKit
bottomRightLabel.styleB3(true)
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return 34
}
}
extension CornerLabels: MoleculeViewProtocol {
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? CornerLabelsModel,
let data = try? model.encode(using: JSONEncoder()),
let json = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any] else {
return
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? CornerLabelsModel else { return }
if middleView != nil {
(middleView as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData)
} else {
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model.molecule, delegateObject) {
addMiddleView(molecule)
}
}
self.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
// topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData)
// topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData)
// bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData)
// bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData)
//
// topLabelToMoleculeConstraint?.constant = (molecule != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
// bottomLabelToMoleculeConstraint?.constant = (molecule != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
topLeftLabel.setWithModel(model.topLeftLabel, delegateObject, additionalData)
topRightLabel.setWithModel(model.topRightLabel, delegateObject, additionalData)
bottomLeftLabel.setWithModel(model.bottomLeftLabel, delegateObject, additionalData)
bottomRightLabel.setWithModel(model.bottomRightLabel, delegateObject, additionalData)
topLabelToMoleculeConstraint?.constant = (middleView != nil && (topLeftLabel.hasText || topRightLabel.hasText)) ? spaceAboveMolecule : 0
bottomLabelToMoleculeConstraint?.constant = (middleView != nil && (bottomLeftLabel.hasText || bottomRightLabel.hasText)) ? spaceBelowMolecule : 0
}
}

View File

@ -41,7 +41,7 @@ import UIKit
super.setWithModel(model, delegateObject, additionalData)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public class override func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 30
}

View File

@ -8,9 +8,9 @@
import UIKit
@objcMembers public class LabelSwitch: ViewConstrainingView {
@objcMembers public class LabelSwitch: ViewConstrainingView, ModelMoleculeViewProtocol {
let label = Label.commonLabelB1(true)
let mvmSwitch = MVMCoreUISwitch.mvmSwitchDefault()
let mvmSwitch = Toggle()
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
@ -40,6 +40,14 @@ import UIKit
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData)
}
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let labelToggleModel = model as? LabelToggleModel else {
return
}
label.setWithModel(labelToggleModel.label, delegateObject, additionalData)
mvmSwitch.setWithModel(labelToggleModel.toggle, delegateObject, additionalData)
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
return MVMCoreUISwitch.estimatedHeight(forRow: json, delegateObject: delegateObject)

View File

@ -0,0 +1,16 @@
//
// LabelToggle.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 1/15/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public class LabelToggleModel: MoleculeProtocol {
public static var identifier: String = "labelToggle"
public var backgroundColor: Color?
public var label: LabelModel
public var toggle: ToggleModel
}

View File

@ -10,14 +10,14 @@ import Foundation
public protocol ModelMoleculeViewProtocol {
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?)
func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String?
static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat?
static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]?
}
extension ModelMoleculeViewProtocol {
public func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return nil
public static func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return nil
@ -25,7 +25,6 @@ extension ModelMoleculeViewProtocol {
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
return nil
}
// Temporary
public static func decodeJSONToModel<T>(json: [AnyHashable: Any], type: T.Type) throws -> T where T : Decodable {
let data = try JSONSerialization.data(withJSONObject: json)

View File

@ -29,7 +29,7 @@ open class ModuleMolecule: Container {
}
if moduleMolecule == nil {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, true) {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, false) {
addSubview(moleculeView)
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values))
moduleMolecule = moleculeView as? (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol)
@ -46,7 +46,7 @@ open class ModuleMolecule: Container {
}
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
guard let moduleMolecule = molecule as? ModuleMoleculeModel,
let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName),
@ -58,10 +58,10 @@ open class ModuleMolecule: Container {
return height
}
public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moduleMolecule = model as? ModuleMoleculeModel,
let moduleModel = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMolecule.moduleName),
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol,
let classType = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moduleModel) as? ModelMoleculeViewProtocol.Type,
let name = classType.nameForReuse(moduleModel, delegateObject) else {
// Critical error
return "moduleMolecule<>"
@ -69,7 +69,7 @@ open class ModuleMolecule: Container {
return name
}
public static func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let moduleName = (molecule as? ModuleMoleculeModel)?.moduleName,
let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {

View File

@ -0,0 +1,116 @@
//
// ModuleMolecule.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 6/25/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
open class ModuleMoleculeModel: ContainerModelProtocol {
public static var identifier: String = "moduleMolecule"
public var molecule: MoleculeProtocol?
public var moduleName: String
public var horizontalAlignment: UIStackView.Alignment? = .fill
public var verticalAlignment: UIStackView.Alignment? = .fill
public var useHorizontalMargins: Bool? = false
public var useVerticalMargins: Bool? = false
enum CodingKeys: String, CodingKey {
case molecule
case moduleName
case horizontalAlignment
case verticalAlignment
case useHorizontalMargins
case useVerticalMargins
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
moduleName = try typeContainer.decode(String.self, forKey:.moduleName)
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {
verticalAlignment = ContainerHelper.getAlignment(for: verticalAlignmentString)
}
if let horizontalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .horizontalAlignment) {
horizontalAlignment = ContainerHelper.getAlignment(for: horizontalAlignmentString)
}
useVerticalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useVerticalMargins)
useHorizontalMargins = try typeContainer.decodeIfPresent(Bool.self, forKey: .useHorizontalMargins)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moduleName, forKey: .moduleName)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: verticalAlignment), forKey: .verticalAlignment)
try container.encodeIfPresent(ContainerHelper.getAlignmentString(for: horizontalAlignment), forKey: .horizontalAlignment)
try container.encodeIfPresent(useVerticalMargins, forKey: .useVerticalMargins)
try container.encodeIfPresent(useHorizontalMargins, forKey: .useHorizontalMargins)
}
}
open class ModuleMolecule: Container {
<<<<<<< HEAD
var moduleMoleculeModel: ModuleMoleculeModel? {
get { return model as? ModuleMoleculeModel }
=======
public override func setupView() {
super.setupView()
containerModel = ModuleMoleculeModel()
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
}
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
#warning("need to change getter to get moduleModel instead to use.")
super.setWithModel(model, delegateObject, additionalData)
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return
}
if view == nil {
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: false) {
addAndContain(moleculeView)
}
} else {
(view as? MVMCoreUIMoleculeViewProtocol)?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData)
}
}
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
guard let moduleName = json?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return 0
}
return MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.estimatedHeight?(forRow: module, delegateObject: delegateObject) ?? 0
}
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
guard let moduleName = molecule?.optionalStringForKey("moduleName"), let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
// Critical error
return "moduleMolecule<>"
}
return "moduleMolecule<" + (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: module)?.name?(forReuse: module, delegateObject: delegateObject) ?? module.stringForkey(KeyMoleculeName)) + ">"
}
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
let moduleName = json?.optionalStringForKey("moduleName")
if moduleName == nil || delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) == nil {
if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) {
error?.pointee = errorObject
MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject)
}
}
if let moduleName = moduleName {
return [moduleName]
}
return nil
}
}

View File

@ -9,6 +9,11 @@
import UIKit
open class MoleculeContainer: Container {
/// Can be overriden to change how the molecule is added to the hierarchy.
public func addMolecule(_ molecule: UIView) {
addAndContain(molecule)
}
override public func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule) else {
@ -31,7 +36,7 @@ open class MoleculeContainer: Container {
(view as? ModelMoleculeViewProtocol)?.setWithModel(casteModel.molecule, delegateObject, additionalData)
} else {
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(casteModel.molecule, delegateObject) {
addAndContain(molecule)
addMolecule(molecule)
}
}
}

View File

@ -0,0 +1,90 @@
//
// StandardHeaderView.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 2/12/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public class StandardHeaderView: MoleculeContainer {
var line: Line?
// MARK: - MVMCoreViewProtocol
open override func updateView(_ size: CGFloat) {
super.updateView(size)
line?.updateView(size)
}
public override func setupView() {
super.setupView()
topMarginPadding = PaddingDefaultVerticalSpacing
bottomMarginPadding = PaddingDefaultVerticalSpacing
guard line == nil else { return }
let line = Line()
line.style = .heavy
addSubview(line)
NSLayoutConstraint.pinViewBottom(toSuperview: line, useMargins: false, constant: 0).isActive = true
NSLayoutConstraint.pinViewLeft(toSuperview: line, useMargins: true, constant: 0).isActive = true
NSLayoutConstraint.pinViewRight(toSuperview: line, useMargins: true, constant: 0).isActive = true
self.line = line
}
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
}
}
<<<<<<< HEAD
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let headerModel = model as? HeaderModel else {
return
}
if let seperatorModel = headerModel.seperator as? LineModel {
line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
}
}
=======
// open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
// //TODO: Need to create setWithModel in ViewConstraining View
//
// #warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
// //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
// setUpWithModel(model, delegateObject, additionalData)
//
// // This molecule will by default handle margins.
// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false)
// (molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetVerticalMargins?(false)
//
// guard let headerModel = model as? HeaderModel else {
// return
// }
//
// if let seperatorModel = headerModel.seperator as? LineModel {
// line?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
// }
// }
>>>>>>> e36d487d326f710d7302c6d9bcb758d209ad329c
open override func reset() {
super.reset()
line?.style = .heavy
topMarginPadding = PaddingDefaultVerticalSpacing
bottomMarginPadding = PaddingDefaultVerticalSpacing
}
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
if let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON)?.estimatedHeight?(forRow: moleculeJSON, delegateObject: delegateObject) {
return height + PaddingDefaultVerticalSpacing + PaddingDefaultVerticalSpacing
}
return 121
}
}

View File

@ -19,7 +19,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
}
@objcMembers open class EyebrowHeadlineBodyLink: Container {
let stack = MoleculeStackView(frame: .zero)
let stack = Stack<StackModel>(frame: .zero)
let eyebrow = Label.commonLabelB3(true)
let headline = Label.commonLabelB1(true)
let body = Label.commonLabelB2(true)
@ -34,19 +34,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
guard stack.superview == nil else {
return
}
let eyebrowStackItem = StackItemModel(with: casteModel!.eyeBrow!)
let headlineStackItem = StackItemModel(with: casteModel!.headline!)
let bodyStackItem = StackItemModel(with: casteModel!.body!)
let linkStackItem = StackItemModel(with: casteModel!.link!)
// To visually take into account the extra padding in the intrinsic content of a button.
linkStackItem.spacing = -6
let stackModel = MoleculeStackModel(molecules: [eyebrowStackItem,headlineStackItem,bodyStackItem,linkStackItem])
stackModel.spacing = 0
stack.model = stackModel
stack.stackItems = [StackItem(andContain: eyebrow),StackItem(andContain: headline),StackItem(andContain: body),StackItem(andContain: link)]
addSubview(stack)
NSLayoutConstraint.constraintPinSubview(toSuperview: stack)
}
@ -64,13 +52,14 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
headline.setWithModel(casteModel?.headline, delegateObject, additionalData)
body.setWithModel(casteModel?.body, delegateObject, additionalData)
link.setWithModel(casteModel?.link, delegateObject, additionalData)
(stack.stackItems[0].model as? StackItemModel)?.gone = !eyebrow.hasText
(stack.stackItems[1].model as? StackItemModel)?.gone = !headline.hasText
(stack.stackItems[2].model as? StackItemModel)?.gone = !body.hasText
(stack.stackItems[3].model as? StackItemModel)?.gone = ((link.titleLabel?.text?.count) ?? 0) == 0
// Create a stack model to use for the internal stack.
let stackModel = StackModel(molecules: [StackItemModel(gone: !eyebrow.hasText),StackItemModel(gone: !headline.hasText),StackItemModel(gone: !body.hasText),StackItemModel(gone: (link.titleLabel?.text?.count ?? 0) == 0)])
stackModel.spacing = 0
stack.model = stackModel
stack.restack()
}
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
guard let json = json, let model = try? Self.decodeJSONToModel(json: json, type: EyebrowHeadlineBodyLinkModel.self) else { return }
setWithModel(model, delegateObject, additionalData)
@ -85,7 +74,7 @@ struct EyebrowHeadlineBodyLinkModel: MoleculeProtocol {
body.styleB2(true)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 65
}
}

View File

@ -7,7 +7,7 @@
//
import Foundation
@objcMembers public class HeadLineBodyCaretLinkImage: ViewConstrainingView {
@objcMembers public class HeadLineBodyCaretLinkImage: View {
let headlineBody = HeadlineBody(frame: .zero)
let caretButton = CaretButton(frame: .zero)
@ -34,7 +34,7 @@ import Foundation
}
let view = MVMCoreUICommonViewsUtility.commonView()
addSubview(view)
pinView(toSuperView: view)
NSLayoutConstraint.constraintPinSubview(toSuperview: view)
view.addSubview(headlineBody)
view.addSubview(caretButton)
@ -78,7 +78,16 @@ import Foundation
backgroundImageView.reset()
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return 320
}
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
super.setWithModel(model, delegateObject, additionalData)
guard let model = model as? HeadlineBodyCaretLinkImageModel else { return }
headlineBody.setWithModel(model.headlineBody, delegateObject, additionalData)
caretButton.setWithModel(model.caretLink, delegateObject, additionalData)
backgroundImageView.setWithModel(model.image, delegateObject, additionalData)
}
}

View File

@ -0,0 +1,17 @@
//
// headlineBodyCaretLinkImageModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/14/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import UIKit
public class HeadlineBodyCaretLinkImageModel: MoleculeProtocol {
public static var identifier: String = "headlineBodyCaretLinkImage"
public var backgroundColor: Color?
public var caretLink: LinkModel?
public var headlineBody: HeadlineBodyModel
public var image: ImageViewModel
}

View File

@ -10,8 +10,8 @@ import Foundation
@objcMembers public class HeadlineBodyModel: MoleculeProtocol {
public static var identifier: String = "headlineBody"
public var headline: LabelModel
public var body: LabelModel
public var headline: LabelModel?
public var body: LabelModel?
public var style: String?
public var backgroundColor: Color?

View File

@ -151,7 +151,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
open func setupPagingMolecule(_ molecule: PagingMoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) {
var pagingView: (UIView & MVMCoreUIPagingProtocol)? = nil
if let molecule = molecule {
pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, true) as? (UIView & MVMCoreUIPagingProtocol)
pagingView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(molecule, delegateObject, false) as? (UIView & MVMCoreUIPagingProtocol)
}
addPaging(view: pagingView, position: (CGFloat(molecule?.position ?? 20)))
}
@ -169,7 +169,7 @@ open class Carousel: ViewConstrainingView, ModelMoleculeViewProtocol {
/// Returns the (identifier, class) of the molecule for the given map.
func getMoleculeInfo(with molecule: MoleculeProtocol, delegateObject: MVMCoreUIDelegateObject?) -> (identifier: String, class: AnyClass, molecule: MoleculeProtocol)? {
guard let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(molecule) ,
let moleculeName = (className as? ModelMoleculeViewProtocol)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
let moleculeName = (className as? ModelMoleculeViewProtocol.Type)?.nameForReuse(molecule, delegateObject) ?? molecule.moleculeName else {
return nil
}
return (moleculeName, className, molecule)

View File

@ -5,17 +5,19 @@
// Created by Suresh, Kamlesh on 10/3/19.
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
//
// A stack that has a list molecule stack items.
import Foundation
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol {
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol, StackModelProtocol {
public static var identifier: String = "stack"
public var backgroundColor: Color?
public var molecules: [StackItemModel]
public var molecules: [MoleculeStackItemModel]
public var axis: NSLayoutConstraint.Axis = .vertical
public var spacing: CGFloat = 16.0
public var useStackSpacingBeforeFirstItem = false
public init(molecules: [StackItemModel]) {
public init(molecules: [MoleculeStackItemModel]) {
self.molecules = molecules
super.init()
}
@ -29,7 +31,7 @@ import Foundation
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self)
molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules)
molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules)
if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) {
axis = optionalAxis
}

View File

@ -8,260 +8,27 @@
import UIKit
open class MoleculeStackView: Container {
var contentView: UIView = MVMCoreUICommonViewsUtility.commonView()
var useStackSpacingBeforeFirstItem = false
var stackModel: MoleculeStackModel? {
open class MoleculeStackView: Stack<MoleculeStackModel> {
override var stackModel: MoleculeStackModel? {
get { return model as? MoleculeStackModel }
}
var stackItems: [StackItem] = []
var moleculesShouldSetHorizontalMargins = false
var moleculesShouldSetVerticalMargins = false
// MARK: - Helpers
public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) {
let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant)
constraint.priority = priority
constraint.isActive = true
}
/// Restacks the existing items.
func restack() {
removeAllItemViews()
let stackItems = self.stackItems
self.stackItems = []
let lastItem = stackItems.last(where: { (item) -> Bool in
return !item.stackItemModel!.gone
})
for item in stackItems {
addStackItem(item, lastItem: item === lastItem)
}
}
/// Removes all stack items views from the view.
func removeAllItemViews() {
for item in stackItems {
item.removeFromSuperview()
}
/// Convenience function, adds a molecule to a MoleculeStackItem to the MoleculeStack
func addMolecule(_ view: View, lastItem: Bool) {
guard let model = view.model else { return }
let stackItemModel = MoleculeStackItemModel(with: model)
let stackItem = MoleculeStackItem(andContain: view)
addView(stackItem, stackItemModel, lastItem: lastItem)
}
// MARK: - Inits
public override init(frame: CGRect) {
super.init(frame: frame)
}
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.init(frame: CGRect.zero)
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - MFViewProtocol
public override func setupView() {
super.setupView()
guard contentView.superview == nil else {
return
}
MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0)
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
addSubview(contentView)
containerHelper.constrainView(contentView)
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
for item in stackItems {
item.updateView(size)
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func reset() {
super.reset()
backgroundColor = .clear
for item in stackItems {
item.reset()
}
}
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
let previousModel = stackModel
super.setWithModel(model, delegateObject, additionalData)
removeAllItemViews()
// If the items in the stack are different, clear them, create new ones.
if (previousModel == nil) || nameForReuse(previousModel, delegateObject) != nameForReuse(model, delegateObject) {
stackItems = []
createStackItemsFromModel(with: delegateObject)
} else if let models = stackModel?.molecules {
for (index, element) in models.enumerated() {
stackItems[index].setWithModel(element, delegateObject, additionalData)
}
}
restack()
stackModel?.useHorizontalMargins = moleculesShouldSetHorizontalMargins
stackModel?.useVerticalMargins = moleculesShouldSetVerticalMargins
}
public override func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let model = model as? MoleculeStackModel else {
return "stack<>"
}
var name = "stack<"
for case let item in model.molecules {
if let moleculeName = item.molecule.moleculeName {
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol, let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
name.append(nameForReuse + ",")
} else {
name.append(moleculeName + ",")
}
}
}
name.append(">")
return name
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
if model == nil {
let data = try! JSONSerialization.data(withJSONObject: json!)
let decoder = JSONDecoder()
let model = try! decoder.decode(MoleculeStackModel.self, from: data)
setWithModel(model, delegateObject, additionalData)
} else {
setWithModel(model, delegateObject, additionalData)
}
}
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let molecules = molecule?.optionalArrayForKey(KeyMolecules) else {
return "stack<>"
}
var name = "stack<"
for case let item as [AnyHashable: Any] in molecules {
if let molecule = item.optionalDictionaryForKey(KeyMolecule), let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? molecule.optionalStringForKey(KeyMoleculeName) {
name.append(moleculeName + ",")
}
}
name.append(">")
return name
}
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
guard let items = json?.optionalArrayForKey(KeyMolecules) else {
return 0
}
let horizontal = json?.optionalStringForKey("axis") == "horizontal"
var estimatedHeight: CGFloat = 0
for case let item as [AnyHashable: AnyHashable] in items {
if let molecule = item.optionalDictionaryForKey(KeyMolecule) {
let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.estimatedHeight?(forRow: molecule, delegateObject: delegateObject)
if !horizontal {
// Vertical stack aggregates the items
let spacing = item.optionalCGFloatForKey("spacing") ?? (estimatedHeight != 0 ? (json?.optionalCGFloatForKey("spacing") ?? 16) : 0)
estimatedHeight += ((height ?? 0) + spacing)
} else if let height = height {
// Horizontal stack takes the tallest item.
estimatedHeight = max(estimatedHeight, height)
}
}
}
return estimatedHeight
}
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let items = json?.optionalArrayForKey(KeyMolecules) else {
return nil
}
var modules: [String] = []
for case let item as [AnyHashable: AnyHashable] in items {
if let molecule = item.optionalDictionaryForKey(KeyMolecule), let modulesForMolecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: molecule)?.requiredModules?(molecule, delegateObject: delegateObject, error: error) {
modules += modulesForMolecule
}
}
return modules.count > 0 ? modules : nil
}
// MARK: - Adding to stack
/// Creates all of the stackItems for the stackItemModels
func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
override func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
guard let stackItemModels = stackModel?.molecules else { return }
for model in stackItemModels {
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? StackItem {
if let stackItem = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(model, delegate) as? MoleculeStackItem {
stackItems.append(stackItem)
}
}
}
/// Adds the view to the stack.
func addView(_ view: View, lastItem: Bool) {
guard let model = view.model else { return }
let stackItem = StackItem(andContain: view)
stackItem.model = StackItemModel(with: model)
addStackItem(stackItem, lastItem: lastItem)
}
/// Adds the stack item view
private func addStackItem(_ stackItem: StackItem, lastItem: Bool) {
let stackModel = self.stackModel!
let model = stackItem.stackItemModel!
guard !model.gone else {
// Gone views do not show
return
}
contentView.addSubview(stackItem)
stackItem.translatesAutoresizingMaskIntoConstraints = false
let spacing = model.spacing ?? stackModel.spacing
let verticalAlignment = model.verticalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percentage == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
let horizontalAlignment = model.horizontalAlignment ?? (stackItem.view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percentage == nil ? .fill : .leading)
stackItem.containerHelper.alignHorizontal(horizontalAlignment)
stackItem.containerHelper.alignVertical(verticalAlignment)
let first = stackItems.first { !($0.stackItemModel?.gone ?? false) } == nil
if stackModel.axis == .vertical {
if first {
pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
} else if let previousView = stackItems.last(where: { item in
return !item.stackItemModel!.gone
}) {
stackItem.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true
}
pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: stackItem, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
if let percent = model.percentage {
stackItem.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {
pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
}
} else {
if first {
// First horizontal item has no spacing by default unless told otherwise.
pinView(stackItem, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
} else if let previousView = stackItems.last(where: { item in
return !item.stackItemModel!.gone
}) {
stackItem.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true
}
pinView(stackItem, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: stackItem, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
if let percent = model.percentage {
stackItem.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {
pinView(contentView, toView: stackItem, attribute: .right, relation: .equal, priority: .required, constant: 0)
}
}
stackItems.append(stackItem)
}
}

View File

@ -0,0 +1,238 @@
//
// Stack.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
open class Stack<T>: Container where T: StackModelProtocol {
var contentView: UIView = MVMCoreUICommonViewsUtility.commonView()
var stackModel: T? {
get { return model as? T }
}
var stackItems: [UIView] = []
// MARK: - Helpers
public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) {
let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant)
constraint.priority = priority
constraint.isActive = true
}
/// Restacks the existing items.
func restack() {
removeAllItemViews()
guard let stackModel = stackModel else { return }
let stackItems = self.stackItems
self.stackItems = []
let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in
return !item.gone
})
for (index, view) in stackItems.enumerated() {
addView(view, stackModel.molecules[index], lastItem: lastItemIndex == index)
}
}
/// Removes all stack items views from the view.
func removeAllItemViews() {
for item in stackItems {
item.removeFromSuperview()
}
}
// MARK: - Inits
public override init(frame: CGRect) {
super.init(frame: frame)
}
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.init(frame: CGRect.zero)
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
}
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - MFViewProtocol
public override func setupView() {
super.setupView()
guard contentView.superview == nil else {
return
}
MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0)
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
addSubview(contentView)
containerHelper.constrainView(contentView)
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
}
public override func updateView(_ size: CGFloat) {
super.updateView(size)
for item in stackItems {
(item as? MVMCoreViewProtocol)?.updateView(size)
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func reset() {
super.reset()
backgroundColor = .clear
for item in stackItems {
(item as? MoleculeViewProtocol)?.reset?()
}
}
public override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
let previousModel = self.model
super.setWithModel(model, delegateObject, additionalData)
removeAllItemViews()
// If the items in the stack are different, clear them, create new ones.
if (previousModel == nil) || MoleculeStackView.nameForReuse(previousModel, delegateObject) != MoleculeStackView.nameForReuse(model, delegateObject) {
stackItems = []
createStackItemsFromModel(with: delegateObject)
} else if let models = stackModel?.molecules {
for (index, element) in models.enumerated() {
(stackItems[index] as? ModelMoleculeViewProtocol)?.setWithModel(element as? MoleculeProtocol, delegateObject, additionalData)
}
}
restack()
}
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
if let model = model {
setWithModel(model, delegateObject, additionalData)
} else if let json = json,
let data = try? JSONSerialization.data(withJSONObject: json),
let model = try? JSONDecoder().decode(MoleculeStackModel.self, from: data) {
setWithModel(model, delegateObject, additionalData)
}
}
public override class func nameForReuse(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
// This will aggregate names of molecules to make an id.
guard let model = model as? MoleculeStackModel else {
return "stack<>"
}
var name = "stack<"
for case let item in model.molecules {
if let moleculeName = item.molecule.moleculeName {
if let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping[moleculeName] as? ModelMoleculeViewProtocol.Type,
let nameForReuse = moleculeClass.nameForReuse(item.molecule, delegateObject) {
name.append(nameForReuse + ",")
} else {
name.append(moleculeName + ",")
}
}
}
name.append(">")
return name
}
// Need to update to take into account first spacing flag
public override class func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
guard let model = molecule as? MoleculeStackModel else { return 0 }
let horizontal = model.axis == .horizontal
var estimatedHeight: CGFloat = 0
for case let item in model.molecules {
if item.gone { continue }
let height = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(forRow: item, delegateObject: delegateObject) ?? 0
if !horizontal {
// Vertical stack aggregates the items
let spacing = item.spacing ?? model.spacing
estimatedHeight += (height + spacing)
} else {
// Horizontal stack takes the tallest item.
estimatedHeight = max(estimatedHeight, height)
}
}
return estimatedHeight
}
public override class func requiredModules(_ molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
guard let model = molecule as? MoleculeStackModel else { return nil }
var modules: [String] = []
for case let item in model.molecules {
if let modulesForMolecule = (MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(item) as? ModelMoleculeViewProtocol.Type)?.requiredModules(item, delegateObject: delegateObject, error: error) {
modules += modulesForMolecule
}
}
return modules.count > 0 ? modules : nil
}
// MARK: - Adding to stack
/// Can be subclassed to create views when we get stack item models and have no views yet
func createStackItemsFromModel(with delegate: MVMCoreUIDelegateObject?) {
}
/// Convenience function, adds a view to a StackItem to the Stack
func addViewToItemToStack(_ view: UIView, lastItem: Bool) {
let stackItemModel = StackItemModel()
let stackItem = StackItem(andContain: view)
addView(stackItem, stackItemModel, lastItem: lastItem)
}
/// Adds the stack item view
func addView(_ view: UIView,_ model: StackItemModelProtocol, lastItem: Bool) {
guard let stackModel = self.stackModel else { return }
guard !model.gone else {
// Gone views do not show
stackItems.append(view)
return
}
contentView.addSubview(view)
view.translatesAutoresizingMaskIntoConstraints = false
let spacing = model.spacing ?? stackModel.spacing
if let container = view as? ContainerProtocol {
let verticalAlignment = (model as? ContainerModelProtocol)?.verticalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.verticalAlignment?() ?? (model.percent == nil && stackModel.axis == .vertical ? .fill : (stackModel.axis == .vertical ? .leading : .center))
let horizontalAlignment = (model as? ContainerModelProtocol)?.horizontalAlignment ?? (view as? MVMCoreUIViewConstrainingProtocol)?.horizontalAlignment?() ?? (stackModel.axis == .vertical || model.percent == nil ? .fill : .leading)
container.alignHorizontal(horizontalAlignment)
container.alignVertical(verticalAlignment)
}
let first = contentView.subviews.count == 1
if stackModel.axis == .vertical {
if first {
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
} else if let previousView = stackItems.last(where: { item in
return !model.gone
}) {
view.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: spacing).isActive = true
}
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: view, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
if let percent = model.percent {
view.heightAnchor.constraint(equalTo: contentView.heightAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {
pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
}
} else {
if first {
// First horizontal item has no spacing by default unless told otherwise.
pinView(view, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: stackModel.useStackSpacingBeforeFirstItem ? spacing : model.spacing ?? 0)
} else if let previousView = stackItems.last(where: { item in
return !model.gone
}) {
view.leftAnchor.constraint(equalTo: previousView.rightAnchor, constant: spacing).isActive = true
}
pinView(view, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 0)
pinView(contentView, toView: view, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
if let percent = model.percent {
view.widthAnchor.constraint(equalTo: contentView.widthAnchor, multiplier: CGFloat(percent)/100.0).isActive = true
}
if lastItem {
pinView(contentView, toView: view, attribute: .right, relation: .equal, priority: .required, constant: 0)
}
}
stackItems.append(view)
}
}

View File

@ -0,0 +1,49 @@
//
// StackModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
@objcMembers public class StackModel: StackModelProtocol, MoleculeProtocol {
public static var identifier: String = "simpleStack"
public var backgroundColor: Color?
public var molecules: [StackItemModel]
public var axis: NSLayoutConstraint.Axis = .vertical
public var spacing: CGFloat = 16.0
public var useStackSpacingBeforeFirstItem = false
public init(molecules: [StackItemModel]) {
self.molecules = molecules
}
enum StackCodingKeys: String, CodingKey {
case moleculeName
case backgroundColor
case molecules
case axis
case spacing
}
required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: StackCodingKeys.self)
molecules = try typeContainer.decode([StackItemModel].self, forKey: .molecules)
if let axisString = try typeContainer.decodeIfPresent(String.self, forKey: .axis), let optionalAxis = NSLayoutConstraint.Axis(rawValue: axisString) {
axis = optionalAxis
}
if let spacing = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .spacing) {
self.spacing = spacing
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StackCodingKeys.self)
try container.encodeIfPresent(molecules, forKey: .molecules)
try container.encodeIfPresent(axis.rawValueString, forKey: .axis)
try container.encodeIfPresent(spacing, forKey: .spacing)
}
}

View File

@ -0,0 +1,18 @@
//
// StackModel.swift
// MVMCoreUI
//
// Created by Scott Pfeil on 1/16/20.
// Copyright © 2020 Verizon Wireless. All rights reserved.
//
import Foundation
public protocol StackModelProtocol {
associatedtype AnyStackItemModel: StackItemModelProtocol
var molecules: [AnyStackItemModel] { get set }
var axis: NSLayoutConstraint.Axis { get set }
var spacing: CGFloat { get set }
var useStackSpacingBeforeFirstItem: Bool { get set }
}

View File

@ -10,7 +10,7 @@ import UIKit
@objcMembers open class CoreUIObject: MVMCoreObject {
public var moleculeMap: MVMCoreUIMoleculeMappingObject?
open override func defaultInitialSetup() {
cache = MVMCoreCache()
sessionHandler = MVMCoreSessionTimeHandler()
@ -19,5 +19,6 @@ import UIKit
viewControllerMapping = MVMCoreUIViewControllerMappingObject()
loggingDelegate = MVMCoreUILoggingHandler()
moleculeMap = MVMCoreUIMoleculeMappingObject()
MoleculeObjectMapping.registerObjects()
}
}

View File

@ -31,7 +31,6 @@
@"button": PrimaryButton.class,
@"link": MFTextButton.class,
@"header": StandardHeaderView.class,
@"stack": MoleculeStackView.class,
@"twoButtonView": TwoButtonView.class,
@"footer": StandardFooterView.class,
@"caretView": CaretView.class,
@ -53,7 +52,7 @@
@"radioButtonLabel": RadioButtonLabel.class,
@"listItem": MoleculeTableViewCell.class,
@"accordionListItem": AccordionMoleculeTableViewCell.class,
@"toggle": MVMCoreUISwitch.class,
@"toggle": Toggle.class,
@"leftRightLabelView": LeftRightLabelView.class,
@"actionDetailWithImage": ActionDetailWithImage.class,
@"image": MFLoadImageView.class,
@ -71,10 +70,12 @@
@"tabsListItem": TabsTableViewCell.class,
@"dropDownListItem": DropDownFilterTableViewCell.class,
@"headlineBodyButton": HeadlineBodyButton.class,
@"stackItem": StackItem.class,
@"stackItem": MoleculeStackItem.class,
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
@"unOrderedList": UnOrderedList.class,
@"numberedList": NumberedList.class,
@"headlineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class,
@"doughnutChart": DoughnutChartView.class,
@"headLineBodyCaretLinkImage" : HeadLineBodyCaretLinkImage.class
} mutableCopy];
});
@ -85,13 +86,6 @@
return [MVMCoreActionUtility initializerClassCheck:[CoreUIObject sharedInstance].moleculeMap classToVerify:self];
}
- (instancetype)init {
if (self = [super init]) {
[MoleculeObjectMapping registerObjects];
}
return self;
}
- (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json {
NSString *moleculeName = [json string:KeyMoleculeName];
if (moleculeName) {

View File

@ -10,11 +10,15 @@ import Foundation
@objcMembers public class MoleculeObjectMapping: NSObject {
public static func registerObjects() {
let mapping = MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping
mapping?.setObject(MoleculeStackView.self, forKey: "stack" as NSString)
ModelRegistry.register(LabelModel.self)
ModelRegistry.register(HeaderModel.self)
ModelRegistry.register(FooterModel.self)
ModelRegistry.register(HeadlineBodyModel.self)
ModelRegistry.register(MoleculeStackModel.self)
ModelRegistry.register(StackItemModel.self)
ModelRegistry.register(MoleculeStackItemModel.self)
ModelRegistry.register(TextFieldModel.self)
ModelRegistry.register(ProgressBarModel.self)
ModelRegistry.register(MultiProgressBarModel.self)
@ -25,10 +29,14 @@ import Foundation
ModelRegistry.register(ScrollerModel.self)
ModelRegistry.register(CornerLabelsModel.self)
ModelRegistry.register(LineModel.self)
ModelRegistry.register(CircleProgressModel.self)
ModelRegistry.register(HeadlineBodyCaretLinkImageModel.self)
ModelRegistry.register(ToggleModel.self)
// buttons
ModelRegistry.register(ButtonModel.self)
ModelRegistry.register(TwoButtonViewModel.self)
ModelRegistry.register(LinkModel.self)
ModelRegistry.register(CaretLinkModel.self)
// list items
ModelRegistry.register(ListItemModel.self)
ModelRegistry.register(DropDownListItemModel.self)
@ -42,12 +50,14 @@ import Foundation
ModelRegistry.register(LabelAttributeUnderlineModel.self)
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
ModelRegistry.register(LabelAttributeActionModel.self)
//
//ModelRegistry.register(ModuleMoleculeModel.self)
ModelRegistry.register(LeftRightLabelModel.self)
ModelRegistry.register(CaretViewModel.self)
ModelRegistry.register(CaretLinkModel.self)
//
ModelRegistry.register(LabelToggleModel.self)
ModelRegistry.register(DoughnutChartModel.self)
ModelRegistry.register(NumberedListModel.self)
ModelRegistry.register(UnOrderedListModel.self)
}

View File

@ -34,15 +34,20 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
open override func viewForTop() -> UIView {
guard let headerModel = templateModel?.header,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return super.viewForTop()
}
// Temporary, Default the horizontal padding
if var container = templateModel?.header as? ContainerModelProtocol, container.useHorizontalMargins == nil {
container.useHorizontalMargins = true
}
return molecule
}
override open func viewForBottom() -> UIView {
guard let footerModel = templateModel?.footer,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return super.viewForBottom()
}
return molecule
@ -167,7 +172,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
func getMoleculeInfo(with listItem: ListItemModelProtocol?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol)? {
guard let listItem = listItem,
let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem),
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else {
let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName else {
return nil
}
return (moleculeName, moleculeClass, listItem)

View File

@ -36,7 +36,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
open override func viewForTop() -> UIView? {
guard let headerModel = templateModel?.header,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return nil
}
return molecule
@ -49,15 +49,15 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
}
let stack = MoleculeStackView(frame: .zero)
stack.useStackSpacingBeforeFirstItem = true
stack.moleculesShouldSetHorizontalMargins = true
moleculeStackModel.useStackSpacingBeforeFirstItem = true
moleculeStackModel.useHorizontalMargins = true
stack.setWithModel(moleculeStackModel, delegateObject() as? MVMCoreUIDelegateObject, nil)
return stack
}
override open func viewForBottom() -> UIView? {
guard let footerModel = templateModel?.footer,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return nil
}
return molecule

View File

@ -29,7 +29,7 @@ import UIKit
open override func viewForTop() -> UIView? {
guard let headerModel = templateModel?.header,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(headerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return nil
}
return molecule
@ -37,7 +37,7 @@ import UIKit
open override func viewForMiddle() -> UIView? {
guard let middleModel = templateModel?.middle,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(middleModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return nil
}
return molecule
@ -45,7 +45,7 @@ import UIKit
override open func viewForBottom() -> UIView? {
guard let footerModel = templateModel?.footer,
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(footerModel, delegateObject() as? MVMCoreUIDelegateObject, false) else {
return nil
}
return molecule

View File

@ -30,6 +30,11 @@ import Foundation
try container.encode(axis.rawValueString, forKey: .axis)
}
*/
enum AxisError: Error {
case notAnAxis
}
extension NSLayoutConstraint.Axis: RawRepresentable {
init?(rawValue: String) {
@ -54,3 +59,29 @@ extension NSLayoutConstraint.Axis: RawRepresentable {
}
}
}
@propertyWrapper
public struct Axis {
public var wrappedValue: NSLayoutConstraint.Axis
public init(wrappedValue value: NSLayoutConstraint.Axis) {
self.wrappedValue = value
}
}
extension Axis: Codable {
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.singleValueContainer()
let string = try typeContainer.decode(String.self)
guard let axis = NSLayoutConstraint.Axis(rawValue: string) else {
throw AxisError.notAnAxis
}
wrappedValue = axis
}
public func encode(to encoder: Encoder) throws {
let string = wrappedValue.rawValueString
var container = encoder.singleValueContainer()
try container.encode(string)
}
}