From 1a3d3eb36f7db9ac84014bd988ddaa66639e3070 Mon Sep 17 00:00:00 2001 From: panxi Date: Tue, 12 Nov 2019 17:36:00 -0500 Subject: [PATCH] update with new code, move core code to mvmcore --- MVMCoreUI.xcodeproj/project.pbxproj | 60 +++------ MVMCoreUI/Models/Decoder.swift | 45 ------- MVMCoreUI/Models/Encoder.swift | 27 ---- MVMCoreUI/Models/Extensions/ModelHelper.swift | 22 ++++ MVMCoreUI/Models/Holder.swift | 16 --- MVMCoreUI/Models/HolderManager.swift | 79 ------------ MVMCoreUI/Models/JSON/JSON.swift | 10 -- MVMCoreUI/Models/JSON/JSONValue.swift | 122 ------------------ MVMCoreUI/Models/MoleculeHolder.swift | 13 -- MVMCoreUI/Models/MoleculeProtocol.swift | 2 +- .../Models/Molecules/ActionMapModel.swift | 19 --- .../Models/Molecules/FormModelProtocol.swift | 2 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 25 +++- .../{SeperatorModel.swift => LineModel.swift} | 0 .../Models/Molecules/ListItemModel.swift | 25 +++- .../Molecules/MoleculeStackItemModel.swift | 20 ++- MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- ...UIMoleculeMappingObject+ModelMapping.swift | 16 +-- 18 files changed, 111 insertions(+), 394 deletions(-) delete mode 100644 MVMCoreUI/Models/Decoder.swift delete mode 100644 MVMCoreUI/Models/Encoder.swift create mode 100644 MVMCoreUI/Models/Extensions/ModelHelper.swift delete mode 100644 MVMCoreUI/Models/Holder.swift delete mode 100644 MVMCoreUI/Models/HolderManager.swift delete mode 100644 MVMCoreUI/Models/JSON/JSON.swift delete mode 100644 MVMCoreUI/Models/JSON/JSONValue.swift delete mode 100644 MVMCoreUI/Models/MoleculeHolder.swift delete mode 100644 MVMCoreUI/Models/Molecules/ActionMapModel.swift rename MVMCoreUI/Models/Molecules/{SeperatorModel.swift => LineModel.swift} (100%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 26d52bb7..cc93db84 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -24,7 +24,7 @@ 017BEB442362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */; }; 017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; }; 017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; }; - 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* SeperatorModel.swift */; }; + 017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; }; 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */; }; 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, ); }; }; @@ -32,21 +32,13 @@ 01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; }; 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; }; 01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; - 01EB367923609281006832FA /* JSONValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367723609281006832FA /* JSONValue.swift */; }; - 01EB367A23609281006832FA /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367823609281006832FA /* JSON.swift */; }; - 01EB367D2360929F006832FA /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367B2360929F006832FA /* Decoder.swift */; }; - 01EB367E2360929F006832FA /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367C2360929F006832FA /* Encoder.swift */; }; - 01EB3681236092AE006832FA /* Holder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB367F236092AE006832FA /* Holder.swift */; }; - 01EB3682236092AE006832FA /* HolderManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3680236092AE006832FA /* HolderManager.swift */; }; 01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; }; - 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3685236097F1006832FA /* MoleculeHolder.swift */; }; 01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; }; 01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; }; 01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; }; 01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; }; 01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; }; 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; }; - 01EB369523609801006832FA /* ActionMapModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368E23609801006832FA /* ActionMapModel.swift */; }; 0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; }; 0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; }; 0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */; }; @@ -55,6 +47,7 @@ 943784F5236B77BB006A1E82 /* GraphView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F3236B77BB006A1E82 /* GraphView.swift */; }; 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; }; 9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; }; + 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946EE1B9237B66D80036751F /* ModelHelper.swift */; }; 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; }; D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */; }; @@ -246,28 +239,20 @@ 017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelExtension.swift"; sourceTree = ""; }; 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.swift; sourceTree = ""; }; 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = ""; }; - 017BEB7A236763000024EF95 /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = ""; }; + 017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = ""; }; 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelMapping.swift"; sourceTree = ""; }; 0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = ""; }; 0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = ""; }; 0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = ""; }; 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = ""; }; 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = ""; }; - 01EB367723609281006832FA /* JSONValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONValue.swift; sourceTree = ""; }; - 01EB367823609281006832FA /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = ""; }; - 01EB367B2360929F006832FA /* Decoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decoder.swift; sourceTree = ""; }; - 01EB367C2360929F006832FA /* Encoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Encoder.swift; sourceTree = ""; }; - 01EB367F236092AE006832FA /* Holder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Holder.swift; sourceTree = ""; }; - 01EB3680236092AE006832FA /* HolderManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HolderManager.swift; sourceTree = ""; }; 01EB3683236097C0006832FA /* MoleculeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeProtocol.swift; sourceTree = ""; }; - 01EB3685236097F1006832FA /* MoleculeHolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeHolder.swift; sourceTree = ""; }; 01EB368823609801006832FA /* LabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LabelModel.swift; sourceTree = ""; }; 01EB368923609801006832FA /* ListItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListItemModel.swift; sourceTree = ""; }; 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackItemModel.swift; sourceTree = ""; }; 01EB368B23609801006832FA /* MoleculeStackModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeStackModel.swift; sourceTree = ""; }; 01EB368C23609801006832FA /* HeaderModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderModel.swift; sourceTree = ""; }; 01EB368D23609801006832FA /* HeadlineBodyModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeadlineBodyModel.swift; sourceTree = ""; }; - 01EB368E23609801006832FA /* ActionMapModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionMapModel.swift; sourceTree = ""; }; 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = ""; }; 0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = ""; }; 0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = ""; }; @@ -276,6 +261,7 @@ 943784F3236B77BB006A1E82 /* GraphView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphView.swift; sourceTree = ""; }; 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = ""; }; 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; + 946EE1B9237B66D80036751F /* ModelHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelHelper.swift; sourceTree = ""; }; 948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = ""; }; D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = ""; }; D206997621FB8A0B00CAE0DE /* MVMCoreUINavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUINavigationController.m; sourceTree = ""; }; @@ -470,14 +456,9 @@ isa = PBXGroup; children = ( 017BEB392360EEB40024EF95 /* PageModel.swift */, - 01EB3685236097F1006832FA /* MoleculeHolder.swift */, 01EB3683236097C0006832FA /* MoleculeProtocol.swift */, - 01EB367F236092AE006832FA /* Holder.swift */, - 01EB3680236092AE006832FA /* HolderManager.swift */, - 01EB367B2360929F006832FA /* Decoder.swift */, - 01EB367C2360929F006832FA /* Encoder.swift */, + 946EE1B5237B663A0036751F /* Extensions */, 01EB368723609801006832FA /* Molecules */, - 01EB367623609281006832FA /* JSON */, ); path = Models; sourceTree = ""; @@ -493,15 +474,6 @@ path = FormUIHelpers; sourceTree = ""; }; - 01EB367623609281006832FA /* JSON */ = { - isa = PBXGroup; - children = ( - 01EB367723609281006832FA /* JSONValue.swift */, - 01EB367823609281006832FA /* JSON.swift */, - ); - path = JSON; - sourceTree = ""; - }; 01EB368723609801006832FA /* Molecules */ = { isa = PBXGroup; children = ( @@ -511,14 +483,21 @@ 01EB368B23609801006832FA /* MoleculeStackModel.swift */, 01EB368C23609801006832FA /* HeaderModel.swift */, 01EB368D23609801006832FA /* HeadlineBodyModel.swift */, - 01EB368E23609801006832FA /* ActionMapModel.swift */, 017BEB3F23620A230024EF95 /* TextFieldModel.swift */, 017BEB4123620AD20024EF95 /* FormModelProtocol.swift */, - 017BEB7A236763000024EF95 /* SeperatorModel.swift */, + 017BEB7A236763000024EF95 /* LineModel.swift */, ); path = Molecules; sourceTree = ""; }; + 946EE1B5237B663A0036751F /* Extensions */ = { + isa = PBXGroup; + children = ( + 946EE1B9237B66D80036751F /* ModelHelper.swift */, + ); + path = Extensions; + sourceTree = ""; + }; D224798823142BF2003FCCF9 /* SwitchMolecules */ = { isa = PBXGroup; children = ( @@ -1153,7 +1132,6 @@ D2E1FADB2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift in Sources */, D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */, D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */, - 01EB3686236097F1006832FA /* MoleculeHolder.swift in Sources */, D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */, 01004F3022721C3800991ECC /* RadioButton.swift in Sources */, 017BEB3C2361EA1D0024EF95 /* MFViewController+Model.swift in Sources */, @@ -1161,7 +1139,6 @@ D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */, D29DF25321E6A177003B2FB9 /* MFDigitTextField.m in Sources */, D2B18B7F2360913400A9AEDC /* Control.swift in Sources */, - 01EB3681236092AE006832FA /* Holder.swift in Sources */, D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */, DBC4392122491730001AB423 /* LabelWithInternalButton.swift in Sources */, D224798C231450C8003FCCF9 /* HeadlineBodySwitch.swift in Sources */, @@ -1173,7 +1150,6 @@ D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */, 017BEB3A2360EEB40024EF95 /* PageModel.swift in Sources */, - 01EB367D2360929F006832FA /* Decoder.swift in Sources */, D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, @@ -1198,7 +1174,6 @@ D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */, D2B18B812360945C00A9AEDC /* View.swift in Sources */, D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */, - 01EB367923609281006832FA /* JSONValue.swift in Sources */, D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */, D22479942316AE5E003FCCF9 /* NSLayoutConstraintExtension.swift in Sources */, D282AACB2243C61700C46919 /* ButtonView.swift in Sources */, @@ -1212,7 +1187,7 @@ D29DF18121E69E50003B2FB9 /* MFView.m in Sources */, D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */, D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */, - 017BEB7B236763000024EF95 /* SeperatorModel.swift in Sources */, + 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, 017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */, D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */, D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */, @@ -1232,7 +1207,6 @@ DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, - 01EB367A23609281006832FA /* JSON.swift in Sources */, 017BEB4223620AD20024EF95 /* FormModelProtocol.swift in Sources */, D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */, D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */, @@ -1250,13 +1224,10 @@ 943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */, D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */, 948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */, - 01EB3682236092AE006832FA /* HolderManager.swift in Sources */, D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */, D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */, D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */, - 01EB369523609801006832FA /* ActionMapModel.swift in Sources */, D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */, - 01EB367E2360929F006832FA /* Encoder.swift in Sources */, D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */, DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */, 0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */, @@ -1276,6 +1247,7 @@ 01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */, D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, + 946EE1BA237B66D80036751F /* ModelHelper.swift in Sources */, 01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */, D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */, ); diff --git a/MVMCoreUI/Models/Decoder.swift b/MVMCoreUI/Models/Decoder.swift deleted file mode 100644 index c04e4940..00000000 --- a/MVMCoreUI/Models/Decoder.swift +++ /dev/null @@ -1,45 +0,0 @@ -import Foundation - -public protocol AnyDecoder { - func decode(_ type: T.Type, from data: Data) throws -> T -} - -extension JSONDecoder: AnyDecoder {} -extension PropertyListDecoder: AnyDecoder {} - -extension Data { - public func decode(using decoder: AnyDecoder = JSONDecoder()) throws -> T { - return try decoder.decode(T.self, from: self) - } -} - -extension KeyedDecodingContainerProtocol { - public func decode(forKey key: Key) throws -> T { - return try decode(T.self, forKey: key) - } - - public func decode( - forKey key: Key, - default defaultExpression: @autoclosure () -> T - ) throws -> T { - return try decodeIfPresent(T.self, forKey: key) ?? defaultExpression() - } -} - -extension Decodable { - public static func decode(fileName: String, bundle: Bundle = Bundle.main) throws -> Self { - guard let path = bundle.path(forResource: fileName, ofType: ".json") else { - throw JSONError.pathNotFound - } - - guard let jsonData = try? Data(contentsOf: URL(fileURLWithPath: path)) else { - throw JSONError.data(path: path) - } - - do { - return try jsonData.decode() - } catch { - throw JSONError.other(error: error) - } - } -} diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift deleted file mode 100644 index 0a236a52..00000000 --- a/MVMCoreUI/Models/Encoder.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Foundation - -public protocol AnyEncoder { - func encode(_ value: T) throws -> Data -} - -extension JSONEncoder: AnyEncoder {} -extension PropertyListEncoder: AnyEncoder {} - -extension Encodable { - public func encode(using encoder: AnyEncoder = JSONEncoder()) throws -> Data { - return try encoder.encode(self) - } - - public func toJSON() -> JSONObject? { - guard let data = try? encode() else { return nil } - return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject } - } - - public func toJSONString() -> String? { - guard let data = try? encode(), - let string = String(data: data, encoding: .utf8) else { - return nil - } - return string - } -} diff --git a/MVMCoreUI/Models/Extensions/ModelHelper.swift b/MVMCoreUI/Models/Extensions/ModelHelper.swift new file mode 100644 index 00000000..1f15274f --- /dev/null +++ b/MVMCoreUI/Models/Extensions/ModelHelper.swift @@ -0,0 +1,22 @@ +// +// ModelHelper.swift +// MVMCoreUI +// +// Created by Ryan on 11/12/19. +// Copyright © 2019 Verizon Wireless. All rights reserved. +// + +import Foundation + + + +extension KeyedDecodingContainer where Key : CodingKey{ + + public func decode(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol { + return try decode(codingKey: codingKey, typeCodingKey: .moleculeName) + } + + public func decodeIfPresent(codingKey: KeyedDecodingContainer.Key) throws -> MoleculeProtocol? { + return try decodeIfPresent(codingKey: codingKey, typeCodingKey: .moleculeName) + } +} diff --git a/MVMCoreUI/Models/Holder.swift b/MVMCoreUI/Models/Holder.swift deleted file mode 100644 index 8bb87a58..00000000 --- a/MVMCoreUI/Models/Holder.swift +++ /dev/null @@ -1,16 +0,0 @@ -import Foundation - -public protocol Holdable: Codable { - static var identifier: String { get set } -} - -public protocol Holder: Codable { - associatedtype HoldableType = Holdable - - static var codingKeyName: String { get } - - var name: String { get set } - var object: HoldableType { get set } - - init(name: String, object: HoldableType) -} diff --git a/MVMCoreUI/Models/HolderManager.swift b/MVMCoreUI/Models/HolderManager.swift deleted file mode 100644 index 4101aa95..00000000 --- a/MVMCoreUI/Models/HolderManager.swift +++ /dev/null @@ -1,79 +0,0 @@ -import Foundation - -public class HolderManager { - public enum Error: Swift.Error { - case codingKeyNotFound - case encoderError - case decoderError - case decoderErrorModelNotMapped - } - fileprivate typealias HoldableDecoder = (SingleValueDecodingContainer) throws -> Holdable - fileprivate typealias HoldableEncoder = (Holdable, inout SingleValueEncodingContainer) throws -> Void - fileprivate static var decoders: [String: HoldableDecoder] = [:] - fileprivate static var encoders: [String: HoldableEncoder] = [:] - - public static func register(_ type: A.Type) { - decoders[A.identifier] = { container in - try container.decode(A.self) - } - - encoders[A.identifier] = { name, container in - guard let obj = name as? A else { - throw HolderManager.Error.encoderError - } - try container.encode(obj) - } - } -} - -private struct DynamicKey: CodingKey { - var stringValue: String - init?(stringValue: String) { - self.stringValue = stringValue - } - - var intValue: Int? { return nil } - init?(intValue: Int) { return nil } -} - -//MARK: - Holder Extension -extension Holder { - - public init(from decoder: Decoder) throws { - - //get the CodingKey String name that tells the type of holdable - guard let key = DynamicKey(stringValue: Self.codingKeyName) else { - throw HolderManager.Error.decoderError - } - - //get the type - let typeContainer = try decoder.container(keyedBy: DynamicKey.self) - let type = try typeContainer.decode(String.self, forKey: key) - - //get the container to decode - let container = try decoder.singleValueContainer() - - //get the decoder for the type found - guard let decoder = HolderManager.decoders[type] else { - throw HolderManager.Error.decoderErrorModelNotMapped - } - - //decode the type and ensure it is of HoldableType - guard let obj = try decoder(container) as? HoldableType else { - throw HolderManager.Error.decoderError - } - - //instantiate Self - self = Self(name: type, object: obj) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - guard let encode = HolderManager.encoders[name], - let holdable = object as? Holdable else { - throw HolderManager.Error.encoderError - } - try encode(holdable, &container) - } -} - diff --git a/MVMCoreUI/Models/JSON/JSON.swift b/MVMCoreUI/Models/JSON/JSON.swift deleted file mode 100644 index cf584557..00000000 --- a/MVMCoreUI/Models/JSON/JSON.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -public typealias JSONArray = [[String: Any]] -public typealias JSONObject = [String: Any] - -public enum JSONError: Error { - case pathNotFound - case data(path: String) - case other(error: Error) -} diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift deleted file mode 100644 index 38f4e613..00000000 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ /dev/null @@ -1,122 +0,0 @@ -import Foundation - -public typealias JSONValueArray = [[String: JSONValue]] -public typealias JSONValueObject = [String: JSONValue] - -public enum JSONValueError: Error { - case encode -} - -extension Optional { - func or(_ other: Optional) -> Optional { - switch self { - case .none: return other - case .some: return self - } - } - - func resolve(with error: @autoclosure () -> Error) throws -> Wrapped { - switch self { - case .none: throw error() - case .some(let wrapped): return wrapped - } - } -} - -public enum JSONValue: Codable, Equatable { - case string(String) - case int(Int) - case double(Double) - case bool(Bool) - case object([String: JSONValue]) - case array([JSONValue]) - case null - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - let value = ((try? container.decode(String.self)).map(JSONValue.string)) - .or((try? container.decode(Int.self)).map(JSONValue.int)) - .or((try? container.decode(Double.self)).map(JSONValue.double)) - .or((try? container.decode(Bool.self)).map(JSONValue.bool)) - .or((try? container.decode([String: JSONValue].self)).map(JSONValue.object)) - .or((try? container.decode([JSONValue].self)).map(JSONValue.array)) - - self = value ?? JSONValue.null - } - - func decode() throws -> T { - let encoded = try JSONEncoder().encode(self) - return try JSONDecoder().decode(T.self, from: encoded) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - switch self { - case .string(let string): try container.encode(string) - case .int(let int): try container.encode(int) - case .double(let double): try container.encode(double) - case .bool(let bool): try container.encode(bool) - case .object(let object): try container.encode(object) - case .array(let array): try container.encode(array) - case .null: break - } - } -} - -public func ==(lhs: JSONValue, rhs: JSONValue) -> Bool { - let ld = try? lhs.encode() - let rd = try? lhs.encode() - return ld == rd -} - -extension JSONValue: ExpressibleByStringLiteral { - public init(stringLiteral value: String) { - self = .string(value) - } -} - -extension JSONValue: ExpressibleByIntegerLiteral { - public init(integerLiteral value: Int) { - self = .int(value) - } -} - -extension JSONValue: ExpressibleByFloatLiteral { - public init(floatLiteral value: Double) { - self = .double(value) - } -} - -extension JSONValue: ExpressibleByBooleanLiteral { - public init(booleanLiteral value: Bool) { - self = .bool(value) - } -} - -extension JSONValue: ExpressibleByArrayLiteral { - public init(arrayLiteral elements: JSONValue...) { - self = .array(elements) - } -} - -extension JSONValue: ExpressibleByDictionaryLiteral { - public init(dictionaryLiteral elements: (String, JSONValue)...) { - self = .object([String: JSONValue](uniqueKeysWithValues: elements)) - } -} - -extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String: JSONValue] { - let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) - return try JSONDecoder().decode([String:JSONValue].self, from: data) - } -} - -extension Dictionary where Key == String, Value == JSONValue { - public func toJSONObject() throws -> JSONObject { - let encoded = try JSONEncoder().encode(self) - guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { - throw JSONValueError.encode - } - return json - } -} diff --git a/MVMCoreUI/Models/MoleculeHolder.swift b/MVMCoreUI/Models/MoleculeHolder.swift deleted file mode 100644 index e83889c2..00000000 --- a/MVMCoreUI/Models/MoleculeHolder.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation - -public class MoleculeHolder: Holder { - public static var codingKeyName: String = "moleculeName" - - public var name: String - public var object: MoleculeProtocol - - required public init(name: String, object: MoleculeProtocol) { - self.name = name - self.object = object - } -} diff --git a/MVMCoreUI/Models/MoleculeProtocol.swift b/MVMCoreUI/Models/MoleculeProtocol.swift index 4dcdce60..0bb23cdf 100644 --- a/MVMCoreUI/Models/MoleculeProtocol.swift +++ b/MVMCoreUI/Models/MoleculeProtocol.swift @@ -1,6 +1,6 @@ import Foundation -public protocol MoleculeProtocol: Holdable { +public protocol MoleculeProtocol: Model { var moleculeName: String? {get} var dictionary: [AnyHashable: Any]? {get} } diff --git a/MVMCoreUI/Models/Molecules/ActionMapModel.swift b/MVMCoreUI/Models/Molecules/ActionMapModel.swift deleted file mode 100644 index 3f46db29..00000000 --- a/MVMCoreUI/Models/Molecules/ActionMapModel.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ActionMap.swift -// MVMCoreUI -// -// Created by Suresh, Kamlesh on 10/3/19. -// Copyright © 2019 Suresh, Kamlesh. All rights reserved. -// - -import Foundation - -@objcMembers public class ActionMapModel: Codable { - public var actionType: String? - public var pageType: String? - - public init(actionType: String?, pageType: String?) { - self.actionType = actionType - self.pageType = pageType - } -} diff --git a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift index 7d31912a..4cd76354 100644 --- a/MVMCoreUI/Models/Molecules/FormModelProtocol.swift +++ b/MVMCoreUI/Models/Molecules/FormModelProtocol.swift @@ -8,7 +8,7 @@ import Foundation -public protocol FormModelProtocol: Holdable { +public protocol FormModelProtocol: Model { var required: Bool? {get} var fieldKey: String? {get} var groupName: String? {get} diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index f1224810..db794d10 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -11,12 +11,31 @@ import Foundation @objcMembers public class HeaderModel: MoleculeProtocol { public static var identifier: String = "header" public var moleculeName: String? - public var molecule: MoleculeHolder? - public var seperator: MoleculeHolder? + public var molecule: MoleculeProtocol? + public var seperator: MoleculeProtocol? - public init(molecule: MoleculeHolder?) { + public init(molecule: MoleculeProtocol?){ self.molecule = molecule self.moleculeName = Self.identifier } + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case separator + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + } } diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/LineModel.swift similarity index 100% rename from MVMCoreUI/Models/Molecules/SeperatorModel.swift rename to MVMCoreUI/Models/Molecules/LineModel.swift diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index a1d297fb..e1f9dc68 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -11,12 +11,31 @@ import Foundation @objcMembers public class ListItemModel: MoleculeProtocol { public static var identifier: String = "listItem" public var moleculeName: String? - public var molecule: MoleculeHolder? + public var molecule: MoleculeProtocol? public var actionMap: ActionMapModel? - public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?) { + public init(molecule: MoleculeProtocol?, actionMap: ActionMapModel?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier } -} + + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + case actionMap + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + self.actionMap = try typeContainer.decodeIfPresent(ActionMapModel.self, forKey: .actionMap) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + try container.encodeIfPresent(actionMap, forKey: .actionMap) + }} diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index 3b60f0c1..1ad99dec 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -11,10 +11,26 @@ import Foundation @objcMembers public class MoleculeStackItemModel: MoleculeProtocol { public static var identifier: String = "moleculeStackItem" public var moleculeName: String? - public var molecule: MoleculeHolder? + public var molecule: MoleculeProtocol? - public init(molecule: MoleculeHolder?) { + public init(molecule: MoleculeProtocol?) { self.molecule = molecule self.moleculeName = Self.identifier } + enum CodingKeys: String, CodingKey { + case moleculeName + case molecule + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName) + self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(self.molecule, forKey: .molecule) + } } diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 435d8e02..9b9a5ff2 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -67,7 +67,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol return } - if let seperatorModel = headerModel.seperator?.object as? LineModel { + if let seperatorModel = headerModel.seperator as? LineModel { separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index c9510436..b3a20c2c 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -10,13 +10,13 @@ import Foundation @objc public extension MVMCoreUIMoleculeMappingObject { @objc static func registerObjects() { - HolderManager.register(LabelModel.self) - HolderManager.register(HeaderModel.self) - HolderManager.register(HeadlineBodyModel.self) - HolderManager.register(MoleculeStackModel.self) - HolderManager.register(ListItemModel.self) - HolderManager.register(MoleculeStackItemModel.self) - HolderManager.register(TextFieldModel.self) - HolderManager.register(LineModel.self) + ModelRegistry.register(LabelModel.self) + ModelRegistry.register(HeaderModel.self) + ModelRegistry.register(HeadlineBodyModel.self) + ModelRegistry.register(MoleculeStackModel.self) + ModelRegistry.register(ListItemModel.self) + ModelRegistry.register(MoleculeStackItemModel.self) + ModelRegistry.register(TextFieldModel.self) + ModelRegistry.register(LineModel.self) } }