changes
This commit is contained in:
parent
b4a5ec2ded
commit
3ec024ff27
@ -15,7 +15,22 @@
|
|||||||
0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */; };
|
0116A4E5228B19640094F3ED /* RadioButtonSelectionHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */; };
|
||||||
011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */; };
|
011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */; };
|
||||||
011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; };
|
011B58F223A2AE2C0085F53C /* DropDownListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */; };
|
||||||
|
011D958524042432000E3791 /* RulesProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958424042432000E3791 /* RulesProtocol.swift */; };
|
||||||
|
011D958724042492000E3791 /* FormFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D958624042492000E3791 /* FormFieldProtocol.swift */; };
|
||||||
|
011D95892404249B000E3791 /* FormProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95882404249B000E3791 /* FormProtocol.swift */; };
|
||||||
|
011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959A240451E3000E3791 /* RuleRequiredModel.swift */; };
|
||||||
|
011D959D2404536F000E3791 /* RuleAnyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959C2404536F000E3791 /* RuleAnyModel.swift */; };
|
||||||
|
011D959F240453A1000E3791 /* RuleValueChangeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D959E240453A1000E3791 /* RuleValueChangeModel.swift */; };
|
||||||
|
011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */; };
|
||||||
|
011D95A3240453F8000E3791 /* RuleRegexModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A2240453F8000E3791 /* RuleRegexModel.swift */; };
|
||||||
|
011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A4240455DC000E3791 /* FormGroupRule.swift */; };
|
||||||
|
011D95A924057AC7000E3791 /* FormActionFieldProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */; };
|
||||||
|
011D95AB2405C553000E3791 /* FormItemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AA2405C553000E3791 /* FormItemProtocol.swift */; };
|
||||||
|
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */; };
|
||||||
011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AE2407266E000E3791 /* RadioButtonModel.swift */; };
|
011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D95AE2407266E000E3791 /* RadioButtonModel.swift */; };
|
||||||
|
011D9602240DA20A000E3791 /* ValidProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9601240DA20A000E3791 /* ValidProtocol.swift */; };
|
||||||
|
011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */; };
|
||||||
|
011D9628240EFA1E000E3791 /* MFViewController+Form.swift in Sources */ = {isa = PBXBuildFile; fileRef = 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */; };
|
||||||
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; };
|
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */; };
|
||||||
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; };
|
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */; };
|
||||||
012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */; };
|
012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012A88B0238C880100FE3DA1 /* CarouselPagingModelProtocol.swift */; };
|
||||||
@ -370,7 +385,22 @@
|
|||||||
0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonSelectionHelper.swift; sourceTree = "<group>"; };
|
0116A4E4228B19640094F3ED /* RadioButtonSelectionHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonSelectionHelper.swift; sourceTree = "<group>"; };
|
||||||
011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModelProtocol.swift; sourceTree = "<group>"; };
|
011B58EF23A2AA980085F53C /* ListItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = "<group>"; };
|
011B58F123A2AE2C0085F53C /* DropDownListItemModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownListItemModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D958424042432000E3791 /* RulesProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RulesProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D958624042492000E3791 /* FormFieldProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormFieldProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D95882404249B000E3791 /* FormProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D959A240451E3000E3791 /* RuleRequiredModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleRequiredModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D959C2404536F000E3791 /* RuleAnyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D959E240453A1000E3791 /* RuleValueChangeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleValueChangeModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D95A0240453D0000E3791 /* RuleEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleEqualsModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D95A2240453F8000E3791 /* RuleRegexModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleRegexModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D95A4240455DC000E3791 /* FormGroupRule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormGroupRule.swift; sourceTree = "<group>"; };
|
||||||
|
011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormActionFieldProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D95AA2405C553000E3791 /* FormItemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormItemProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormHolderProtocol.swift; sourceTree = "<group>"; };
|
||||||
011D95AE2407266E000E3791 /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = "<group>"; };
|
011D95AE2407266E000E3791 /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D9601240DA20A000E3791 /* ValidProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidProtocol.swift; sourceTree = "<group>"; };
|
||||||
|
011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RadioButtonLabelModel.swift; sourceTree = "<group>"; };
|
||||||
|
011D9627240EFA1E000E3791 /* MFViewController+Form.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFViewController+Form.swift"; sourceTree = "<group>"; };
|
||||||
012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = "<group>"; };
|
012A889B23889E8400FE3DA1 /* TemplateModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModelProtocol.swift; sourceTree = "<group>"; };
|
||||||
012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = "<group>"; };
|
012A88AC238C418100FE3DA1 /* TemplateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateProtocol.swift; sourceTree = "<group>"; };
|
||||||
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = "<group>"; };
|
012A88AE238C626E00FE3DA1 /* CarouselModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarouselModel.swift; sourceTree = "<group>"; };
|
||||||
@ -748,6 +778,34 @@
|
|||||||
path = ModelProtocols;
|
path = ModelProtocols;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
011D9583240422BF000E3791 /* New */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
011D958A24042794000E3791 /* Rules */,
|
||||||
|
011D95882404249B000E3791 /* FormProtocol.swift */,
|
||||||
|
011D95AC2406BB57000E3791 /* FormHolderProtocol.swift */,
|
||||||
|
011D95AA2405C553000E3791 /* FormItemProtocol.swift */,
|
||||||
|
011D958624042492000E3791 /* FormFieldProtocol.swift */,
|
||||||
|
011D95A824057AC7000E3791 /* FormActionFieldProtocol.swift */,
|
||||||
|
011D9601240DA20A000E3791 /* ValidProtocol.swift */,
|
||||||
|
);
|
||||||
|
path = New;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
011D958A24042794000E3791 /* Rules */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
011D958424042432000E3791 /* RulesProtocol.swift */,
|
||||||
|
011D959A240451E3000E3791 /* RuleRequiredModel.swift */,
|
||||||
|
011D959C2404536F000E3791 /* RuleAnyModel.swift */,
|
||||||
|
011D959E240453A1000E3791 /* RuleValueChangeModel.swift */,
|
||||||
|
011D95A0240453D0000E3791 /* RuleEqualsModel.swift */,
|
||||||
|
011D95A2240453F8000E3791 /* RuleRegexModel.swift */,
|
||||||
|
011D95A4240455DC000E3791 /* FormGroupRule.swift */,
|
||||||
|
);
|
||||||
|
path = Rules;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
012A88EF23985E0100FE3DA1 /* CustomPrimitives */ = {
|
012A88EF23985E0100FE3DA1 /* CustomPrimitives */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -768,6 +826,7 @@
|
|||||||
01C74D87224298E2009C25A3 /* FormUIHelpers */ = {
|
01C74D87224298E2009C25A3 /* FormUIHelpers */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
011D9583240422BF000E3791 /* New */,
|
||||||
0198F79E225679870066C936 /* FormValidationProtocol.swift */,
|
0198F79E225679870066C936 /* FormValidationProtocol.swift */,
|
||||||
0105618A224BBE7700E1557D /* FormValidator.swift */,
|
0105618A224BBE7700E1557D /* FormValidator.swift */,
|
||||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */,
|
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */,
|
||||||
@ -1203,6 +1262,7 @@
|
|||||||
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
|
D29B770F22C281F400D6ACE0 /* ModuleMolecule.swift */,
|
||||||
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */,
|
D28A838423CCCA8900DFE4FC /* ScrollerModel.swift */,
|
||||||
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,
|
D2D6CD3F22E78C1A00D701B8 /* Scroller.swift */,
|
||||||
|
011D9625240EBB16000E3791 /* RadioButtonLabelModel.swift */,
|
||||||
017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */,
|
017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */,
|
||||||
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */,
|
||||||
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */,
|
||||||
@ -1217,6 +1277,7 @@
|
|||||||
D29DF16021E69996003B2FB9 /* MFViewController.h */,
|
D29DF16021E69996003B2FB9 /* MFViewController.h */,
|
||||||
D29DF15F21E69996003B2FB9 /* MFViewController.m */,
|
D29DF15F21E69996003B2FB9 /* MFViewController.m */,
|
||||||
017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */,
|
017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */,
|
||||||
|
011D9627240EFA1E000E3791 /* MFViewController+Form.swift */,
|
||||||
D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */,
|
D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */,
|
||||||
D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */,
|
D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */,
|
||||||
D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */,
|
D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */,
|
||||||
@ -1731,6 +1792,7 @@
|
|||||||
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
||||||
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
|
D29DF11721E6805F003B2FB9 /* UIColor+MFConvenience.m in Sources */,
|
||||||
D2B18B7F2360913400A9AEDC /* Control.swift in Sources */,
|
D2B18B7F2360913400A9AEDC /* Control.swift in Sources */,
|
||||||
|
011D95A924057AC7000E3791 /* FormActionFieldProtocol.swift in Sources */,
|
||||||
0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */,
|
0AA33B3A2398524F0067DD0F /* Toggle.swift in Sources */,
|
||||||
D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */,
|
D29DF12F21E6851E003B2FB9 /* MVMCoreUITopAlertMainView.m in Sources */,
|
||||||
012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */,
|
012A88C8238DB02000FE3DA1 /* ModelMoleculeDelegateProtocol.swift in Sources */,
|
||||||
@ -1744,9 +1806,11 @@
|
|||||||
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */,
|
9445891F2385D2E900DE9FD4 /* CaretViewModel.swift in Sources */,
|
||||||
01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */,
|
01C851D323CF9E740021F976 /* LabelToggleModel.swift in Sources */,
|
||||||
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
||||||
|
011D95A3240453F8000E3791 /* RuleRegexModel.swift in Sources */,
|
||||||
D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */,
|
D2E2A98323D8B32D000B42E6 /* EyebrowHeadlineBodyLinkModel.swift in Sources */,
|
||||||
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
012A88AD238C418100FE3DA1 /* TemplateProtocol.swift in Sources */,
|
||||||
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
||||||
|
011D9602240DA20A000E3791 /* ValidProtocol.swift in Sources */,
|
||||||
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
|
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
|
||||||
D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */,
|
D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */,
|
||||||
D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */,
|
D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */,
|
||||||
@ -1786,6 +1850,7 @@
|
|||||||
AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */,
|
AA11A42123F15D7000D7962F /* ListRightVariablePaymentsModel.swift in Sources */,
|
||||||
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
||||||
012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */,
|
012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */,
|
||||||
|
011D9626240EBB16000E3791 /* RadioButtonLabelModel.swift in Sources */,
|
||||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||||
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
||||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||||
@ -1801,6 +1866,7 @@
|
|||||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||||
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */,
|
0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */,
|
||||||
|
011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */,
|
||||||
01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */,
|
01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */,
|
||||||
31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */,
|
31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */,
|
||||||
D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */,
|
D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */,
|
||||||
@ -1844,6 +1910,7 @@
|
|||||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
||||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
||||||
94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */,
|
94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */,
|
||||||
|
011D958724042492000E3791 /* FormFieldProtocol.swift in Sources */,
|
||||||
011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */,
|
011D95AF2407266E000E3791 /* RadioButtonModel.swift in Sources */,
|
||||||
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */,
|
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */,
|
||||||
D274CA332236A78900B01B62 /* FooterView.swift in Sources */,
|
D274CA332236A78900B01B62 /* FooterView.swift in Sources */,
|
||||||
@ -1856,6 +1923,7 @@
|
|||||||
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */,
|
||||||
D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */,
|
D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */,
|
||||||
C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */,
|
C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */,
|
||||||
|
011D958524042432000E3791 /* RulesProtocol.swift in Sources */,
|
||||||
94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */,
|
94AF4A3F23E9D13900676048 /* MFCaretButton.m in Sources */,
|
||||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||||
@ -1865,6 +1933,7 @@
|
|||||||
012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */,
|
012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */,
|
||||||
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
||||||
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */,
|
9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */,
|
||||||
|
011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */,
|
||||||
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
|
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
|
||||||
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
|
D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */,
|
||||||
D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */,
|
D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */,
|
||||||
@ -1915,13 +1984,16 @@
|
|||||||
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */,
|
94C2D9A123872BCC0006CF46 /* LabelAttributeUnderlineModel.swift in Sources */,
|
||||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
|
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */,
|
||||||
D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */,
|
D2B1E3E522F37D6A0065F95C /* ImageHeadlineBody.swift in Sources */,
|
||||||
|
011D9628240EFA1E000E3791 /* MFViewController+Form.swift in Sources */,
|
||||||
0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */,
|
0A21DB94235E24ED00C160A2 /* DigitEntryField.swift in Sources */,
|
||||||
52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */,
|
52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */,
|
||||||
D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */,
|
D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */,
|
||||||
0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */,
|
0A21DB8D235E06EF00C160A2 /* MFDigitTextField.m in Sources */,
|
||||||
94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */,
|
94AF4A4323E9D19E00676048 /* MFCaretView.m in Sources */,
|
||||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */,
|
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */,
|
||||||
|
011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */,
|
||||||
D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */,
|
D29DF2AA21E7B2F9003B2FB9 /* MVMCoreUIConstants.m in Sources */,
|
||||||
|
011D95892404249B000E3791 /* FormProtocol.swift in Sources */,
|
||||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */,
|
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */,
|
||||||
013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */,
|
013F801923FB4A8E00AD8013 /* UIContentMode+Extension.swift in Sources */,
|
||||||
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
|
D2A5146122121FBF00345BFB /* MoleculeStackTemplate.swift in Sources */,
|
||||||
@ -1950,6 +2022,7 @@
|
|||||||
D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */,
|
D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */,
|
||||||
014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */,
|
014AA72E23C5059B006F3E93 /* StackCenteredPageTemplateModel.swift in Sources */,
|
||||||
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
|
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
|
||||||
|
011D959D2404536F000E3791 /* RuleAnyModel.swift in Sources */,
|
||||||
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */,
|
D260105923D0A92900764D80 /* ContainerProtocol.swift in Sources */,
|
||||||
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */,
|
C695A69423C9909000BFB94E /* DoughnutChartModel.swift in Sources */,
|
||||||
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
|
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
|
||||||
@ -1958,6 +2031,7 @@
|
|||||||
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
|
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
|
||||||
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
|
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
|
||||||
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */,
|
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */,
|
||||||
|
011D95AB2405C553000E3791 /* FormItemProtocol.swift in Sources */,
|
||||||
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */,
|
D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */,
|
||||||
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */,
|
C6FA7D5223C77A4A00A3614A /* UnOrderedList.swift in Sources */,
|
||||||
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */,
|
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */,
|
||||||
@ -1966,6 +2040,8 @@
|
|||||||
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
||||||
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */,
|
||||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||||
|
011D959F240453A1000E3791 /* RuleValueChangeModel.swift in Sources */,
|
||||||
|
011D95AD2406BB57000E3791 /* FormHolderProtocol.swift in Sources */,
|
||||||
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
946EE1BA237B66D80036751F /* MoleculeModelHelper.swift in Sources */,
|
||||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */,
|
||||||
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
D260106523D0CEA700764D80 /* StackModel.swift in Sources */,
|
||||||
|
|||||||
@ -18,7 +18,8 @@ public enum ButtonSize: String, Codable {
|
|||||||
case tiny
|
case tiny
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormActionFieldProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "button"
|
public static var identifier: String = "button"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var title: String
|
public var title: String
|
||||||
@ -32,9 +33,15 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
public var disabledFillColor: Color?
|
public var disabledFillColor: Color?
|
||||||
public var disabledTextColor: Color?
|
public var disabledTextColor: Color?
|
||||||
public var disabledBorderColor: Color?
|
public var disabledBorderColor: Color?
|
||||||
public var required: Bool?
|
public var groupName: String?
|
||||||
public var requiredGroups: [String]?
|
|
||||||
|
public func updateEnable(_ enabled: Bool) {
|
||||||
|
self.enabled = enabled
|
||||||
|
updateUI?()
|
||||||
|
}
|
||||||
|
|
||||||
|
public var updateUI: (() -> Void)?
|
||||||
|
|
||||||
init(with title: String, action: ActionModelProtocol) {
|
init(with title: String, action: ActionModelProtocol) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.action = action
|
self.action = action
|
||||||
@ -66,8 +73,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
case disabledFillColor
|
case disabledFillColor
|
||||||
case disabledTextColor
|
case disabledTextColor
|
||||||
case disabledBorderColor
|
case disabledBorderColor
|
||||||
case required
|
case groupName
|
||||||
case requiredGroups
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
@ -76,8 +82,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
|
||||||
title = try typeContainer.decode(String.self, forKey: .title)
|
title = try typeContainer.decode(String.self, forKey: .title)
|
||||||
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
action = try typeContainer.decodeModel(codingKey: .action, typeCodingKey: ActionCodingKey.actionType)
|
||||||
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required)
|
groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName)
|
||||||
requiredGroups = try typeContainer.decodeIfPresent([String].self, forKey: .requiredGroups)
|
|
||||||
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
|
if let style = try typeContainer.decodeIfPresent(ButtonStyle.self, forKey: .style) {
|
||||||
self.style = style
|
self.style = style
|
||||||
}
|
}
|
||||||
@ -110,7 +115,6 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol {
|
|||||||
try container.encodeIfPresent(disabledFillColor, forKey: .disabledFillColor)
|
try container.encodeIfPresent(disabledFillColor, forKey: .disabledFillColor)
|
||||||
try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor)
|
try container.encodeIfPresent(disabledTextColor, forKey: .disabledTextColor)
|
||||||
try container.encodeIfPresent(disabledBorderColor, forKey: .disabledBorderColor)
|
try container.encodeIfPresent(disabledBorderColor, forKey: .disabledBorderColor)
|
||||||
try container.encodeIfPresent(required, forKey: .required)
|
try container.encodeIfPresent(groupName, forKey: .groupName)
|
||||||
try container.encodeIfPresent(requiredGroups, forKey: .requiredGroups)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class PillButton: Button, MVMCoreUIViewConstrainingProtocol, FormValidationEnableDisableProtocol {
|
open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
|
||||||
// Used to size the button.
|
// Used to size the button.
|
||||||
var size = MVMCoreUIUtility.getWidth()
|
var size = MVMCoreUIUtility.getWidth()
|
||||||
|
|
||||||
@ -125,11 +125,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol, FormValidation
|
|||||||
|
|
||||||
guard let model = model as? ButtonModel else { return }
|
guard let model = model as? ButtonModel else { return }
|
||||||
setTitle(model.title, for: .normal)
|
setTitle(model.title, for: .normal)
|
||||||
|
|
||||||
if let required = model.required,
|
model.updateUI = { [weak self] in
|
||||||
required {
|
self?.enableField(model.enabled)
|
||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
}
|
}
|
||||||
|
|
||||||
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
|
||||||
@ -163,17 +164,8 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol, FormValidation
|
|||||||
open func horizontalAlignment() -> UIStackView.Alignment {
|
open func horizontalAlignment() -> UIStackView.Alignment {
|
||||||
return .center
|
return .center
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - FormValidationEnableDisableProtocol
|
|
||||||
public func isValidationRequired() -> Bool {
|
|
||||||
return buttonModel?.required ?? false
|
|
||||||
}
|
|
||||||
|
|
||||||
public func requiredGroups() -> [String]? {
|
|
||||||
return buttonModel?.requiredGroups
|
|
||||||
}
|
|
||||||
|
|
||||||
public func enableField(_ enable: Bool) {
|
public func enableField(_ enable: Bool) {
|
||||||
isEnabled = isValidationRequired() ? enable : true
|
isEnabled = enable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,13 +16,10 @@ extension PrimaryButton: ModelMoleculeViewProtocol {
|
|||||||
setTitle(model.title, for: .normal)
|
setTitle(model.title, for: .normal)
|
||||||
backgroundColor = model.backgroundColor?.uiColor
|
backgroundColor = model.backgroundColor?.uiColor
|
||||||
|
|
||||||
self.validationRequired = model.required ?? false
|
// if self.validationRequired,
|
||||||
self.requiredGroupsList = model.requiredGroups
|
// let selfForm = self as? FormValidationEnableDisableProtocol {
|
||||||
|
// FormValidator.setupValidation(molecule: selfForm, delegate: delegateObject?.formValidationProtocol)
|
||||||
if self.validationRequired,
|
// }
|
||||||
let selfForm = self as? FormValidationEnableDisableProtocol {
|
|
||||||
FormValidator.setupValidation(molecule: selfForm, delegate: delegateObject?.formValidationProtocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let style = model.style {
|
if let style = model.style {
|
||||||
switch style {
|
switch style {
|
||||||
|
|||||||
@ -9,7 +9,8 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
@objcMembers public class EntryFieldModel: MoleculeModelProtocol {
|
@objcMembers public class EntryFieldModel: MoleculeModelProtocol, FormFieldProtocol, ValidProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -26,8 +27,18 @@ import Foundation
|
|||||||
public var isLocked: Bool?
|
public var isLocked: Bool?
|
||||||
public var isSelected: Bool?
|
public var isSelected: Bool?
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
public var isValid: Bool?
|
|
||||||
public var isRequired: Bool?
|
public var isRequired: Bool?
|
||||||
|
public var text: String?
|
||||||
|
|
||||||
|
public var isValid: Bool? {
|
||||||
|
didSet {
|
||||||
|
updateUI?()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public var updateUI: (() -> Void)?
|
||||||
|
public func setValidity(_ isValid: Bool) {
|
||||||
|
self.isValid = isValid
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
@ -45,6 +56,11 @@ import Foundation
|
|||||||
case fieldKey
|
case fieldKey
|
||||||
case isValid
|
case isValid
|
||||||
case isRequired = "required"
|
case isRequired = "required"
|
||||||
|
case text
|
||||||
|
}
|
||||||
|
|
||||||
|
public func formFieldValue() -> Any? {
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -62,6 +78,7 @@ import Foundation
|
|||||||
isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected)
|
isSelected = try typeContainer.decodeIfPresent(Bool.self, forKey: .isSelected)
|
||||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||||
isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid)
|
isValid = try typeContainer.decodeIfPresent(Bool.self, forKey: .isValid)
|
||||||
|
text = try typeContainer.decodeIfPresent(String.self, forKey: .text)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -76,5 +93,6 @@ import Foundation
|
|||||||
try container.encode(isSelected, forKey: .isSelected)
|
try container.encode(isSelected, forKey: .isSelected)
|
||||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||||
try container.encodeIfPresent(isValid, forKey: .isValid)
|
try container.encodeIfPresent(isValid, forKey: .isValid)
|
||||||
|
try container.encodeIfPresent(text, forKey: .text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,64 +16,64 @@ enum TextType: String {
|
|||||||
}
|
}
|
||||||
extension MFTextField: ModelMoleculeViewProtocol {
|
extension MFTextField: ModelMoleculeViewProtocol {
|
||||||
//
|
//
|
||||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public func setWithModel(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
//TODO: Need to create setWithModel in ViewConstraining View
|
// //TODO: Need to create setWithModel in ViewConstraining View
|
||||||
#warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
|
// #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.
|
// //TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
|
||||||
setUpDefaultWithModel(model, delegateObject, additionalData)
|
// setUpDefaultWithModel(model, delegateObject, additionalData)
|
||||||
|
//
|
||||||
guard let textFieldModel = model as? TextFieldModel,
|
// guard let textFieldModel = model as? TextFieldModel,
|
||||||
let delegateObject = delegateObject else {
|
// let delegateObject = delegateObject else {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if let delegate = delegateObject.formValidationProtocol {
|
// if let delegate = delegateObject.formValidationProtocol {
|
||||||
let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
|
// let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
|
||||||
mfTextFieldDelegate = formValidator
|
// mfTextFieldDelegate = formValidator
|
||||||
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
|
// uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
|
||||||
if let textField = textField {
|
// if let textField = textField {
|
||||||
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
// MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
formText = textFieldModel.label as NSString?
|
// formText = textFieldModel.label as NSString?
|
||||||
text = textFieldModel.value as NSString?
|
// text = textFieldModel.value as NSString?
|
||||||
if let disabled = textFieldModel.disabled {
|
// if let disabled = textFieldModel.disabled {
|
||||||
enable(disabled)
|
// enable(disabled)
|
||||||
}
|
// }
|
||||||
errMessage = textFieldModel.errorMsg
|
// errMessage = textFieldModel.errorMsg
|
||||||
fieldKey = textFieldModel.fieldKey
|
// fieldKey = textFieldModel.fieldKey
|
||||||
groupName = textFieldModel.groupName
|
// groupName = textFieldModel.groupName
|
||||||
|
//
|
||||||
|
//
|
||||||
switch textFieldModel.type {
|
// switch textFieldModel.type {
|
||||||
case TextType.dropDown.rawValue:
|
// case TextType.dropDown.rawValue:
|
||||||
dropDownCarrotLabel?.isHidden = true
|
// dropDownCarrotLabel?.isHidden = true
|
||||||
hasDropDown = true
|
// hasDropDown = true
|
||||||
break
|
// break
|
||||||
case TextType.password.rawValue:
|
// case TextType.password.rawValue:
|
||||||
textField?.isSecureTextEntry = true
|
// textField?.isSecureTextEntry = true
|
||||||
break
|
// break
|
||||||
case TextType.number.rawValue:
|
// case TextType.number.rawValue:
|
||||||
textField?.keyboardType = .numberPad
|
// textField?.keyboardType = .numberPad
|
||||||
break
|
// break
|
||||||
case TextType.email.rawValue:
|
// case TextType.email.rawValue:
|
||||||
textField?.keyboardType = .emailAddress
|
// textField?.keyboardType = .emailAddress
|
||||||
break
|
// break
|
||||||
default:
|
// default:
|
||||||
print("default")
|
// print("default")
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if let regex = textFieldModel.regex {
|
// if let regex = textFieldModel.regex {
|
||||||
validationBlock = {(enteredValue: String?) -> Bool in
|
// validationBlock = {(enteredValue: String?) -> Bool in
|
||||||
if let enteredValue = enteredValue {
|
// if let enteredValue = enteredValue {
|
||||||
return MVMCoreUIUtility.validate(enteredValue, withRegularExpression: regex)
|
// return MVMCoreUIUtility.validate(enteredValue, withRegularExpression: regex)
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
setDefaultValidationBlock()
|
// setDefaultValidationBlock()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,25 +97,25 @@ import MVMCore
|
|||||||
return MVMCoreUIUtility.validateInternationalMDNString(MDN)
|
return MVMCoreUIUtility.validateInternationalMDNString(MDN)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public override func validateTextField() -> Bool {
|
@objc public override func validateTextField() {
|
||||||
|
|
||||||
guard !shouldValidateMDN, let MDN = mdn, !MDN.isEmpty else {
|
// guard !shouldValidateMDN, let MDN = mdn, !MDN.isEmpty else {
|
||||||
isValid = true
|
// isValid = true
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
let isValid = hasValidMDN()
|
// let isValid = hasValidMDN()
|
||||||
|
//
|
||||||
if isValid {
|
// if isValid {
|
||||||
showError = false
|
// showError = false
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
errorMessage = errorMessage ?? MVMCoreUIUtility.hardcodedString(withKey: "textfield_phone_format_error_message")
|
// errorMessage = errorMessage ?? MVMCoreUIUtility.hardcodedString(withKey: "textfield_phone_format_error_message")
|
||||||
showError = true
|
// showError = true
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: textField)
|
// UIAccessibility.post(notification: .layoutChanged, argument: textField)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return isValid
|
// return isValid
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func getContacts(_ sender: Any?) {
|
@objc public func getContacts(_ sender: Any?) {
|
||||||
@ -186,9 +186,9 @@ import MVMCore
|
|||||||
|
|
||||||
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
||||||
|
|
||||||
if validateTextField() && isNationalMDN {
|
// if validateTextField() && isNationalMDN {
|
||||||
textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
// textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
|
@objc public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ import UIKit
|
|||||||
|
|
||||||
/// Validate when user resigns editing. Default: true
|
/// Validate when user resigns editing. Default: true
|
||||||
public var validateWhenDoneEditing: Bool = true
|
public var validateWhenDoneEditing: Bool = true
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -218,34 +218,33 @@ import UIKit
|
|||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
@objc override open func resignFirstResponder() -> Bool {
|
@objc override open func resignFirstResponder() -> Bool {
|
||||||
|
|
||||||
if validateWhenDoneEditing {
|
if validateWhenDoneEditing {
|
||||||
validateTextField()
|
validateTextField()
|
||||||
}
|
}
|
||||||
|
|
||||||
textField.resignFirstResponder()
|
textField.resignFirstResponder()
|
||||||
isSelected = false
|
isSelected = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates the text of the entry field.
|
/// Validates the text of the entry field.
|
||||||
@discardableResult
|
@objc public func validateTextField() {
|
||||||
@objc public func validateTextField() -> Bool {
|
text = textField.text
|
||||||
|
FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
isValid = validationBlock?(text) ?? true
|
}
|
||||||
|
|
||||||
|
@objc public func updateValidation(_ isValid: Bool) {
|
||||||
|
self.isValid = isValid
|
||||||
if isValid {
|
if isValid {
|
||||||
showError = false
|
showError = false
|
||||||
observingTextFieldDelegate?.isValid?(textfield: self)
|
observingTextFieldDelegate?.isValid?(textfield: self)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showError = true
|
showError = true
|
||||||
observingTextFieldDelegate?.isInvalid?(textfield: self)
|
observingTextFieldDelegate?.isInvalid?(textfield: self)
|
||||||
}
|
}
|
||||||
|
|
||||||
return isValid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Executes on UITextField.textDidBeginEditingNotification
|
/// Executes on UITextField.textDidBeginEditingNotification
|
||||||
@objc func startEditing() {
|
@objc func startEditing() {
|
||||||
|
|
||||||
@ -263,17 +262,14 @@ import UIKit
|
|||||||
|
|
||||||
/// Executes on UITextField.textDidEndEditingNotification
|
/// Executes on UITextField.textDidEndEditingNotification
|
||||||
@objc func endInputing() {
|
@objc func endInputing() {
|
||||||
|
resignFirstResponder()
|
||||||
if isValid {
|
if isValid {
|
||||||
showError = false
|
showError = false
|
||||||
entryFieldContainer.bottomBar?.backgroundColor = UIColor.black.cgColor
|
entryFieldContainer.bottomBar?.backgroundColor = UIColor.black.cgColor
|
||||||
}
|
}
|
||||||
|
|
||||||
resignFirstResponder()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func dismissFieldInput(_ sender: Any?) {
|
@objc func dismissFieldInput(_ sender: Any?) {
|
||||||
|
|
||||||
resignFirstResponder()
|
resignFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,9 +277,14 @@ import UIKit
|
|||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
guard let model = model as? TextEntryFieldModel else { return }
|
guard let model = model as? TextEntryFieldModel else { return }
|
||||||
|
|
||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
model.updateUI = { [weak self] in
|
||||||
|
if self?.isSelected ?? false {
|
||||||
|
self?.updateValidation(model.isValid ?? true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.delegateObject = delegateObject
|
||||||
|
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
textColor.enabled = model.enabledTextColor?.uiColor
|
textColor.enabled = model.enabledTextColor?.uiColor
|
||||||
textColor.disabled = model.disabledTextColor?.uiColor
|
textColor.disabled = model.disabledTextColor?.uiColor
|
||||||
text = model.text
|
text = model.text
|
||||||
@ -312,11 +313,9 @@ import UIKit
|
|||||||
defaultValidationBlock()
|
defaultValidationBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if let formValidationProtocol = delegateObject?.formValidationProtocol {
|
// observingTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: delegateObject?.formHolderDelegate)
|
||||||
observingTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: formValidationProtocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
|
uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate
|
||||||
|
observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate
|
||||||
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,9 +329,7 @@ extension TextEntryField {
|
|||||||
guard let delegateObject = delegateObject,
|
guard let delegateObject = delegateObject,
|
||||||
let dictionary = json
|
let dictionary = json
|
||||||
else { return }
|
else { return }
|
||||||
|
|
||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
|
|
||||||
|
|
||||||
if let enabledTextColorHex = dictionary["enabledTextColor"] as? String {
|
if let enabledTextColorHex = dictionary["enabledTextColor"] as? String {
|
||||||
textColor.enabled = UIColor.mfGet(forHex: enabledTextColorHex)
|
textColor.enabled = UIColor.mfGet(forHex: enabledTextColorHex)
|
||||||
}
|
}
|
||||||
@ -374,11 +371,9 @@ extension TextEntryField {
|
|||||||
defaultValidationBlock()
|
defaultValidationBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if let formValidationProtocol = delegateObject.formValidationProtocol {
|
|
||||||
observingTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: formValidationProtocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
|
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
|
||||||
|
observingTextFieldDelegate = delegateObject.observingTextFieldDelegate
|
||||||
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
return "textField"
|
return "textField"
|
||||||
}
|
}
|
||||||
|
|
||||||
public var text: String?
|
|
||||||
public var placeholder: String?
|
public var placeholder: String?
|
||||||
public var enabledTextColor: Color?
|
public var enabledTextColor: Color?
|
||||||
public var disabledTextColor: Color?
|
public var disabledTextColor: Color?
|
||||||
|
|||||||
@ -127,9 +127,10 @@ import MVMCore
|
|||||||
didSet {
|
didSet {
|
||||||
if !updateSelectionOnly {
|
if !updateSelectionOnly {
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
|
(model as? CheckboxModel)?.isChecked = isSelected
|
||||||
shapeLayer?.removeAllAnimations()
|
shapeLayer?.removeAllAnimations()
|
||||||
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
|
updateCheckboxUI(isSelected: isSelected, isAnimated: isAnimated)
|
||||||
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
|
FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
updateAccessibilityLabel()
|
updateAccessibilityLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,76 +398,12 @@ import MVMCore
|
|||||||
|
|
||||||
//layoutIfNeeded()
|
//layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
|
||||||
|
|
||||||
groupName = dictionary.optionalStringForKey("groupName")
|
|
||||||
fieldValue = dictionary.optionalStringForKey("value")
|
|
||||||
if let fieldKey = dictionary[KeyFieldKey] as? String {
|
|
||||||
self.fieldKey = fieldKey
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isRequired = dictionary[KeyRequired] as? Bool {
|
|
||||||
self.isRequired = isRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
if let borderColorHex = dictionary["borderColor"] as? String {
|
|
||||||
layer.borderColor = UIColor.mfGet(forHex: borderColorHex).cgColor
|
|
||||||
}
|
|
||||||
|
|
||||||
if let borderWidth = dictionary["borderWidth"] as? CGFloat {
|
|
||||||
layer.borderWidth = borderWidth
|
|
||||||
}
|
|
||||||
|
|
||||||
if let checkColorHex = dictionary["checkColor"] as? String {
|
|
||||||
checkColor = UIColor.mfGet(forHex: checkColorHex)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isChecked = dictionary["isChecked"] as? Bool, isChecked {
|
|
||||||
checkAndBypassAnimations(selected: isChecked)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let unCheckedBackgroundColorHex = dictionary["unCheckedBackgroundColor"] as? String {
|
|
||||||
unCheckedBackgroundColor = UIColor.mfGet(forHex: unCheckedBackgroundColorHex)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let checkedBackgroundColorHex = dictionary["checkedBackgroundColor"] as? String {
|
|
||||||
checkedBackgroundColor = UIColor.mfGet(forHex: checkedBackgroundColorHex)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isAnimated = dictionary["isAnimated"] as? Bool {
|
|
||||||
self.isAnimated = isAnimated
|
|
||||||
}
|
|
||||||
|
|
||||||
if let isRound = dictionary["isRound"] as? Bool {
|
|
||||||
self.isRound = isRound
|
|
||||||
}
|
|
||||||
|
|
||||||
if let enabled = dictionary["isEnabled"] as? Bool {
|
|
||||||
isEnabled = enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
if let actionMap = dictionary.optionalDictionaryForKey("action") {
|
|
||||||
actionBlock = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
super.set(with: model, delegateObject, additionalData)
|
super.set(with: model, delegateObject, additionalData)
|
||||||
|
|
||||||
guard let model = model as? CheckboxModel else { return }
|
guard let model = model as? CheckboxModel else { return }
|
||||||
|
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
|
|
||||||
groupName = model.groupName
|
|
||||||
fieldValue = model.value
|
|
||||||
isRequired = model.required
|
|
||||||
|
|
||||||
if let fieldKey = model.fieldKey {
|
if let fieldKey = model.fieldKey {
|
||||||
self.fieldKey = fieldKey
|
self.fieldKey = fieldKey
|
||||||
@ -500,23 +437,3 @@ import MVMCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK:- FormValidationProtocol
|
|
||||||
extension Checkbox: FormValidationFormFieldProtocol {
|
|
||||||
|
|
||||||
public func formFieldGroupName() -> String? {
|
|
||||||
return groupName
|
|
||||||
}
|
|
||||||
|
|
||||||
public func isValidField() -> Bool {
|
|
||||||
return isRequired ? isSelected : true
|
|
||||||
}
|
|
||||||
|
|
||||||
public func formFieldName() -> String? {
|
|
||||||
return fieldKey
|
|
||||||
}
|
|
||||||
|
|
||||||
public func formFieldValue() -> Any? {
|
|
||||||
return isSelected ? fieldValue : nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class CheckboxModel: MoleculeModelProtocol {
|
@objcMembers public class CheckboxModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -16,10 +17,6 @@ import Foundation
|
|||||||
public static var identifier: String = "checkbox"
|
public static var identifier: String = "checkbox"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
public var groupName: String?
|
|
||||||
public var value: String?
|
|
||||||
public var fieldKey: String?
|
|
||||||
public var required: Bool = false
|
|
||||||
public var borderColor: Color = Color(uiColor: .black)
|
public var borderColor: Color = Color(uiColor: .black)
|
||||||
public var borderWidth: CGFloat = 1
|
public var borderWidth: CGFloat = 1
|
||||||
public var isChecked: Bool = false
|
public var isChecked: Bool = false
|
||||||
@ -33,17 +30,16 @@ import Foundation
|
|||||||
public var disabledBackgroundColor: Color = Color(uiColor: .clear)
|
public var disabledBackgroundColor: Color = Color(uiColor: .clear)
|
||||||
public var disabledBorderColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var disabledBorderColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
public var disabledCheckColor: Color = Color(uiColor: .mvmCoolGray3)
|
public var disabledCheckColor: Color = Color(uiColor: .mvmCoolGray3)
|
||||||
|
|
||||||
|
public var fieldKey: String?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Keys
|
// MARK: - Keys
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
case groupName
|
|
||||||
case value
|
|
||||||
case fieldKey
|
case fieldKey
|
||||||
case required
|
|
||||||
case borderColor
|
case borderColor
|
||||||
case borderWidth
|
case borderWidth
|
||||||
case isChecked
|
case isChecked
|
||||||
@ -61,16 +57,17 @@ import Foundation
|
|||||||
|
|
||||||
init(isChecked: Bool = false) {}
|
init(isChecked: Bool = false) {}
|
||||||
|
|
||||||
|
public func formFieldValue() -> Any? {
|
||||||
|
return isChecked
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Codec
|
// MARK: - Codec
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName)
|
|
||||||
value = try typeContainer.decodeIfPresent(String.self, forKey: .value)
|
|
||||||
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
fieldKey = try typeContainer.decodeIfPresent(String.self, forKey: .fieldKey)
|
||||||
required = try typeContainer.decodeIfPresent(Bool.self, forKey: .required) ?? false
|
|
||||||
borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) ?? 1
|
borderWidth = try typeContainer.decodeIfPresent(CGFloat.self, forKey: .borderWidth) ?? 1
|
||||||
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) ?? Color(uiColor: .black)
|
borderColor = try typeContainer.decodeIfPresent(Color.self, forKey: .borderColor) ?? Color(uiColor: .black)
|
||||||
checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) ?? Color(uiColor: .black)
|
checkColor = try typeContainer.decodeIfPresent(Color.self, forKey: .checkColor) ?? Color(uiColor: .black)
|
||||||
@ -89,10 +86,7 @@ import Foundation
|
|||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(groupName, forKey: .groupName)
|
|
||||||
try container.encodeIfPresent(value, forKey: .value)
|
|
||||||
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
try container.encodeIfPresent(fieldKey, forKey: .fieldKey)
|
||||||
try container.encodeIfPresent(required, forKey: .required)
|
|
||||||
try container.encodeIfPresent(borderColor, forKey: .borderColor)
|
try container.encodeIfPresent(borderColor, forKey: .borderColor)
|
||||||
try container.encode(borderWidth, forKey: .borderWidth)
|
try container.encode(borderWidth, forKey: .borderWidth)
|
||||||
try container.encode(isChecked, forKey: .isChecked)
|
try container.encode(isChecked, forKey: .isChecked)
|
||||||
|
|||||||
@ -18,7 +18,7 @@ extension MFView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension ModelMoleculeViewProtocol where Self: MFView {
|
extension ModelMoleculeViewProtocol where Self: MFView {
|
||||||
func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
setUpDefaultWithModel(model, delegateObject, additionalData)
|
setUpDefaultWithModel(model, delegateObject, additionalData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,7 @@ extension MVMCoreUISwitch: ModelMoleculeViewProtocol {
|
|||||||
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
|
||||||
guard let model = model as? ToggleModel else { return }
|
guard let model = model as? ToggleModel else { return }
|
||||||
|
|
||||||
if let castSelf = self as? FormValidationProtocol {
|
FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate)
|
||||||
FormValidator.setupValidation(molecule: castSelf, delegate: delegateObject?.formValidationProtocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(model.state, animated: false)
|
setState(model.state, animated: false)
|
||||||
|
|
||||||
guard let action = model.action else { return }
|
guard let action = model.action else { return }
|
||||||
|
|||||||
@ -8,13 +8,14 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers public class RadioButton: Control, FormValidationFormFieldProtocol {
|
@objcMembers public class RadioButton: Control {
|
||||||
|
|
||||||
var diameter: CGFloat = 30 {
|
var diameter: CGFloat = 30 {
|
||||||
didSet {
|
didSet {
|
||||||
widthConstraint?.constant = diameter
|
widthConstraint?.constant = diameter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var enabledColor = UIColor.black
|
var enabledColor = UIColor.black
|
||||||
var disabledColor = UIColor.mfSilver()
|
var disabledColor = UIColor.mfSilver()
|
||||||
|
|
||||||
@ -27,15 +28,18 @@ import UIKit
|
|||||||
var widthConstraint: NSLayoutConstraint?
|
var widthConstraint: NSLayoutConstraint?
|
||||||
var heightConstraint: NSLayoutConstraint?
|
var heightConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
var radioModel: RadioButtonModel? {
|
||||||
|
return model as? RadioButtonModel
|
||||||
|
}
|
||||||
|
|
||||||
lazy var radioGroupName: String? = {
|
lazy var radioGroupName: String? = {
|
||||||
[unowned self] in
|
[unowned self] in return radioModel?.radioGroupName ?? radioModel?.fieldKey
|
||||||
return json?.optionalStringForKey("radioGroupName") ?? json?.optionalStringForKey("fieldKey")
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
lazy var radioButtonModel: RadioButtonSelectionHelper? = {
|
lazy var radioButtonSelectionHelper: RadioButtonSelectionHelper? = {
|
||||||
[unowned self] in
|
[unowned self] in
|
||||||
if let radioGroupName = radioGroupName,
|
if let radioGroupName = radioGroupName,
|
||||||
let radioButtonModel = delegateObject?.formValidationProtocol?.formValidatorModel?()?.radioButtonsModelByGroup[radioGroupName] {
|
let radioButtonModel = delegateObject?.formHolderDelegate?.formValidator?.radioButtonsModelByGroup[radioGroupName] {
|
||||||
return radioButtonModel
|
return radioButtonModel
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
@ -58,12 +62,12 @@ import UIKit
|
|||||||
|
|
||||||
/// The action performed when tapped.
|
/// The action performed when tapped.
|
||||||
func tapAction() {
|
func tapAction() {
|
||||||
if let radioButtonModel = radioButtonModel {
|
if let radioButtonModel = radioButtonSelectionHelper {
|
||||||
radioButtonModel.selected(self)
|
radioButtonModel.selected(self)
|
||||||
} else {
|
} else {
|
||||||
isSelected = !isSelected
|
isSelected = !isSelected
|
||||||
}
|
}
|
||||||
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
|
FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,15 +76,15 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func formFieldName() -> String? {
|
public func formFieldName() -> String? {
|
||||||
return json?.optionalStringForKey("fieldKey")
|
return radioModel?.fieldKey
|
||||||
}
|
}
|
||||||
|
|
||||||
public func formFieldGroupName() -> String? {
|
public func formFieldGroupName() -> String? {
|
||||||
return json?.optionalStringForKey("groupName")
|
return radioModel?.radioGroupName
|
||||||
}
|
}
|
||||||
|
|
||||||
public func formFieldValue() -> Any? {
|
public func formFieldValue() -> String? {
|
||||||
return isSelected
|
return radioModel?.fieldValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - MVMViewProtocol
|
// MARK: - MVMViewProtocol
|
||||||
@ -104,40 +108,14 @@ import UIKit
|
|||||||
guard let model = model as? RadioButtonModel else {
|
guard let model = model as? RadioButtonModel else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - MVMCoreUIViewConstrainingProtocol
|
|
||||||
extension RadioButton: MVMCoreUIViewConstrainingProtocol {
|
|
||||||
public func needsToBeConstrained() -> Bool {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
|
||||||
extension RadioButton {
|
|
||||||
|
|
||||||
@objc open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
|
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
|
|
||||||
// Configure class properties with JSON values
|
|
||||||
guard let jsonDictionary = json else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fieldKey = jsonDictionary.optionalStringForKey("fieldKey")
|
|
||||||
isRequired = jsonDictionary.boolForKey("required")
|
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
|
let radioButtonModel = RadioButtonSelectionHelper.setupForRadioButtonGroup(model,
|
||||||
let radioButtonModel = RadioButtonSelectionHelper.setupForRadioButtonGroup(radioButton: self,
|
formValidator: delegateObject?.formHolderDelegate?.formValidator)
|
||||||
formValidator: delegateObject?.formValidationProtocol?.formValidatorModel?())
|
FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formHolderDelegate)
|
||||||
FormValidator.setupValidation(molecule: radioButtonModel, delegate: delegateObject?.formValidationProtocol)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,9 +9,20 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
public class RadioButtonModel: MoleculeModelProtocol {
|
public class RadioButtonModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "radioButton"
|
public static var identifier: String = "radioButton"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var state: Bool = false
|
public var state: Bool? = false
|
||||||
|
public var radioGroupName: String?
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
|
public var fieldValue: String
|
||||||
|
public func formFieldValue() -> Any? {
|
||||||
|
return fieldValue
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ fieldKey: String, _ fieldValue: String) {
|
||||||
|
self.fieldKey = fieldKey
|
||||||
|
self.fieldValue = fieldValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,7 +101,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
|
|||||||
self.constrainKnob()
|
self.constrainKnob()
|
||||||
}
|
}
|
||||||
|
|
||||||
FormValidator.enableByValidationWith(delegate: delegateObject?.formValidationProtocol)
|
FormValidator.validate(delegate: delegateObject?.formHolderDelegate)
|
||||||
accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff")
|
accessibilityValue = isOn ? MVMCoreUIUtility.hardcodedString(withKey: "AccOn") : MVMCoreUIUtility.hardcodedString(withKey: "AccOff")
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
@ -379,7 +379,7 @@ extension Toggle {
|
|||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
|
|
||||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
// FormValidator.setupValidation(molecule: self, delegate: delegateObject?.formValidationProtocol)
|
||||||
|
|
||||||
guard let dictionary = json else { return }
|
guard let dictionary = json else { return }
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
public class ToggleModel: MoleculeModelProtocol {
|
public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol {
|
||||||
|
|
||||||
public static var identifier: String = "toggle"
|
public static var identifier: String = "toggle"
|
||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var state: Bool = true
|
public var state: Bool = true
|
||||||
@ -27,6 +28,10 @@ public class ToggleModel: MoleculeModelProtocol {
|
|||||||
case alternateAction
|
case alternateAction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func formFieldValue() -> Any? {
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
public init(_ state: Bool) {
|
public init(_ state: Bool) {
|
||||||
self.state = state
|
self.state = state
|
||||||
}
|
}
|
||||||
|
|||||||
22
MVMCoreUI/BaseControllers/MFViewController+Form.swift
Normal file
22
MVMCoreUI/BaseControllers/MFViewController+Form.swift
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// MFViewController+Form.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 3/3/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension MFViewController: ObservingTextFieldDelegate {
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension MFViewController {
|
||||||
|
@objc func startValidation() {
|
||||||
|
(self as? FormHolderProtocol)?.formValidator?.validate()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
||||||
|
(self as? FormHolderProtocol)?.formValidator?.addFormParams(requestParameters: requestParameters)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -52,19 +52,10 @@
|
|||||||
// title view for navigation bar, used for custom navigation titles
|
// title view for navigation bar, used for custom navigation titles
|
||||||
@property (weak, nonatomic) UILabel *titleLabel;
|
@property (weak, nonatomic) UILabel *titleLabel;
|
||||||
|
|
||||||
@property (strong, nonatomic) FormValidator *formValidator;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MFViewController
|
@implementation MFViewController
|
||||||
|
|
||||||
- (FormValidator *)formValidatorModel {
|
|
||||||
if (self.formValidator == nil) {
|
|
||||||
self.formValidator = [FormValidator new];
|
|
||||||
}
|
|
||||||
return self.formValidator;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)dismiss {
|
- (void)dismiss {
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
if (self.presentingViewController) {
|
if (self.presentingViewController) {
|
||||||
@ -487,12 +478,13 @@
|
|||||||
if (!self.disableAnimations) {
|
if (!self.disableAnimations) {
|
||||||
[self setupIntroAnimations];
|
[self setupIntroAnimations];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[self startValidation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)newDataBuildAndUpdate {
|
- (void)newDataBuildAndUpdate {
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
[self newDataBuildScreen];
|
[self newDataBuildScreen];
|
||||||
[self.formValidator enableByValidation];
|
|
||||||
self.needToUpdateUI = YES;
|
self.needToUpdateUI = YES;
|
||||||
[self.view setNeedsLayout];
|
[self.view setNeedsLayout];
|
||||||
}];
|
}];
|
||||||
@ -690,9 +682,8 @@
|
|||||||
[[MVMCoreUISession sharedGlobal].splitViewController.rightPanel willOpenWithActionInformation:actionInformation];
|
[[MVMCoreUISession sharedGlobal].splitViewController.rightPanel willOpenWithActionInformation:actionInformation];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.formValidator addFormParamsWithRequestParameters:requestParameters];
|
[self addFormParamsWithRequestParameters:requestParameters];
|
||||||
requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"];
|
requestParameters.parentPageType = [self.loadObject.pageJSON stringForKey:@"parentPageType"];
|
||||||
|
|
||||||
[[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]];
|
[[MVMCoreLoadHandler sharedGlobal] loadRequest:requestParameters dataForPage:additionalData delegateObject:[self delegateObject]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,21 +8,3 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objc public extension FormValidator {
|
|
||||||
@objc func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
|
||||||
requestParameters.add(self.getFormParams())
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func getFormParams() -> [String: Any] {
|
|
||||||
var extraParam: [String: Any] = [:]
|
|
||||||
MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
|
|
||||||
for molecule in self.fieldMolecules {
|
|
||||||
if let formFieldName = molecule.formFieldName(),
|
|
||||||
let formFieldValue = molecule.formFieldValue() {
|
|
||||||
extraParam[formFieldName] = formFieldValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return extraParam
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -8,63 +8,62 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objc extension FormValidator: MFTextFieldDelegate {
|
//@objc extension FormValidator: MFTextFieldDelegate {
|
||||||
|
//
|
||||||
public func dismissFieldInput(_ sender: Any?) {
|
// public func dismissFieldInput(_ sender: Any?) {
|
||||||
|
//
|
||||||
if let delegate = delegate as? MFTextFieldDelegate {
|
// if let delegate = delegate as? MFTextFieldDelegate {
|
||||||
delegate.dismissFieldInput?(sender)
|
// delegate.dismissFieldInput?(sender)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public func entryIsValid(_ textfield: MFTextField?) {
|
// public func entryIsValid(_ textfield: MFTextField?) {
|
||||||
|
//
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
// MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
self.enableByValidation()
|
// self.enableByValidation()
|
||||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
// if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||||
delegate.entryIsValid?(textfield)
|
// delegate.entryIsValid?(textfield)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public func entryIsInvalid(_ textfield: MFTextField?) {
|
// public func entryIsInvalid(_ textfield: MFTextField?) {
|
||||||
|
//
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
// MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
self.enableByValidation()
|
// self.enableByValidation()
|
||||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
// if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||||
delegate.entryIsInvalid?(textfield)
|
// delegate.entryIsInvalid?(textfield)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
// Temporary: Looking to either combine or separate entirely with MFTextFieldDelegate.
|
// Temporary: Looking to either combine or separate entirely with MFTextFieldDelegate.
|
||||||
extension FormValidator: ObservingTextFieldDelegate {
|
//extension FormValidator: ObservingTextFieldDelegate {
|
||||||
|
//
|
||||||
public func dismissField(_ sender: Any?) {
|
// public func dismissField(_ sender: Any?) {
|
||||||
|
// if let delegate = delegate as? MFTextFieldDelegate {
|
||||||
if let delegate = delegate as? MFTextFieldDelegate {
|
// delegate.dismissFieldInput?(sender)
|
||||||
delegate.dismissFieldInput?(sender)
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//
|
||||||
|
// @nonobjc public func isValid(_ textfield: MFTextField?) {
|
||||||
@nonobjc public func isValid(_ textfield: MFTextField?) {
|
//
|
||||||
|
// MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
// self.enableByValidation()
|
||||||
self.enableByValidation()
|
// if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
// delegate.entryIsValid?(textfield)
|
||||||
delegate.entryIsValid?(textfield)
|
// }
|
||||||
}
|
// })
|
||||||
})
|
// }
|
||||||
}
|
//
|
||||||
|
// public func isInvalid(_ textfield: MFTextField?) {
|
||||||
public func isInvalid(_ textfield: MFTextField?) {
|
//
|
||||||
|
// MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
// self.enableByValidation()
|
||||||
self.enableByValidation()
|
// if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
// delegate.entryIsInvalid?(textfield)
|
||||||
delegate.entryIsInvalid?(textfield)
|
// }
|
||||||
}
|
// })
|
||||||
})
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|||||||
@ -13,73 +13,81 @@ import MVMCore
|
|||||||
|
|
||||||
var extraValidationBlock: (() -> Bool)?
|
var extraValidationBlock: (() -> Bool)?
|
||||||
var dummyGroupName = "dummyGroupName"
|
var dummyGroupName = "dummyGroupName"
|
||||||
weak var delegate: FormValidationProtocol?
|
|
||||||
var fieldMolecules: [FormValidationFormFieldProtocol] = []
|
var formRules: [FormGroupRule]
|
||||||
var enableDisableMolecules: [FormValidationEnableDisableProtocol] = []
|
var delegate: FormHolderProtocol?
|
||||||
|
var fieldMolecules: [FormFieldProtocol] = []
|
||||||
|
var formActionMolecules: [FormActionFieldProtocol] = []
|
||||||
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
var radioButtonsModelByGroup: [String: RadioButtonSelectionHelper] = [:]
|
||||||
|
|
||||||
public func insertMolecule(_ molecule: FormValidationProtocol) {
|
public init(_ formRules: [FormGroupRule]) {
|
||||||
if let molecule = molecule as? FormValidationFormFieldProtocol {
|
self.formRules = formRules
|
||||||
fieldMolecules.append(molecule)
|
|
||||||
}
|
|
||||||
if let moleculeT = molecule as? FormValidationEnableDisableProtocol,
|
|
||||||
moleculeT.isValidationRequired() {
|
|
||||||
enableDisableMolecules.append(moleculeT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func enableByValidationWith(delegate: FormValidationProtocol?) {
|
public func insertMolecule(_ molecule: FormItemProtocol) {
|
||||||
if let delegate = delegate {
|
if let molecule = molecule as? FormFieldProtocol {
|
||||||
let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
|
fieldMolecules.append(molecule)
|
||||||
formValidator?.enableByValidation()
|
}
|
||||||
|
if let molecule = molecule as? FormActionFieldProtocol {
|
||||||
|
formActionMolecules.append(molecule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? {
|
public static func setupValidation(molecule: FormItemProtocol, delegate: FormHolderProtocol?) {
|
||||||
return delegate.formValidatorModel?()
|
if let validator = delegate?.formValidator {
|
||||||
}
|
|
||||||
|
|
||||||
public static func setupValidation(molecule: FormValidationProtocol, delegate: FormValidationProtocol?) {
|
|
||||||
if let validator = delegate?.formValidatorModel?() {
|
|
||||||
validator.delegate = delegate
|
validator.delegate = delegate
|
||||||
validator.insertMolecule(molecule)
|
validator.insertMolecule(molecule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enableByValidation() {
|
public static func getFormValidatorFor(delegate: FormHolderProtocol?) -> FormValidator? {
|
||||||
for molecule in enableDisableMolecules {
|
return delegate?.formValidator
|
||||||
var requiredGroups = molecule.requiredGroups?() ?? [dummyGroupName]
|
|
||||||
if requiredGroups.count == 0 {
|
|
||||||
requiredGroups = [dummyGroupName]
|
|
||||||
}
|
|
||||||
enableWithGroups(requiredGroups, molecule)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enableWithGroups(_ requiredGroupList: [String], _ enableDisableMolecule: FormValidationEnableDisableProtocol) {
|
public static func validate(delegate: FormHolderProtocol?) {
|
||||||
let requiredGroupSet = Set(requiredGroupList)
|
delegate?.formValidator?.validate()
|
||||||
var valid = true
|
}
|
||||||
for molecule in fieldMolecules {
|
|
||||||
let groupName = molecule.formFieldGroupName() ?? dummyGroupName
|
public func validate() {
|
||||||
if requiredGroupSet.contains(groupName) {
|
formActionMolecules.forEach { (actionModel) in
|
||||||
valid = valid && molecule.isValidField()
|
if let groupName = actionModel.groupName, let formRule = formRules.first(where: { $0.groupName == groupName }) {
|
||||||
if valid == false {
|
validate(groupName, actionModel, formRule.rules)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enableDisableMolecule.enableField?(valid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func enableIgnoreGroupName(_ enableDisableMolecules: FormValidationEnableDisableProtocol) {
|
public func validate(_ groupName: String, _ actionModel: FormActionFieldProtocol, _ rules: [RulesProtocol]) {
|
||||||
var valid = true
|
var valid = true
|
||||||
for molecule in fieldMolecules {
|
for rule in rules {
|
||||||
valid = valid && molecule.isValidField()
|
valid = valid && rule.isValid(self)
|
||||||
if (!valid) {
|
if !valid {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let enableField = valid && (extraValidationBlock?() ?? true)
|
actionModel.updateEnable(valid)
|
||||||
enableDisableMolecules.enableField?(enableField)
|
}
|
||||||
|
|
||||||
|
public func formField(for fieldKey: String) -> FormFieldProtocol? {
|
||||||
|
return fieldMolecules.first(where: { $0.fieldKey == fieldKey })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark Form params
|
||||||
|
@objc public extension FormValidator {
|
||||||
|
@objc func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
||||||
|
requestParameters.add(self.getFormParams())
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func getFormParams() -> [String: Any] {
|
||||||
|
var extraParam: [String: Any] = [:]
|
||||||
|
MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
|
||||||
|
for molecule in self.fieldMolecules {
|
||||||
|
if let formFieldName = molecule.fieldKey,
|
||||||
|
let formFieldValue = molecule.formFieldValue() {
|
||||||
|
extraParam[formFieldName] = formFieldValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return extraParam
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
MVMCoreUI/FormUIHelpers/New/FormActionFieldProtocol.swift
Normal file
15
MVMCoreUI/FormUIHelpers/New/FormActionFieldProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// FormActionFieldProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 1/31/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol FormActionFieldProtocol: EnableableModelProtocol, FormItemProtocol {
|
||||||
|
var groupName: String? { get set }
|
||||||
|
func updateEnable(_ enabled: Bool)
|
||||||
|
var updateUI: (() -> Void)? { get set }
|
||||||
|
}
|
||||||
15
MVMCoreUI/FormUIHelpers/New/FormFieldProtocol.swift
Normal file
15
MVMCoreUI/FormUIHelpers/New/FormFieldProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// FormFieldProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 1/31/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public protocol FormFieldProtocol: FormItemProtocol {
|
||||||
|
var fieldKey: String? { get set }
|
||||||
|
func formFieldValue() -> Any?
|
||||||
|
}
|
||||||
17
MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift
Normal file
17
MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// FormHolderProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/26/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
//Protocol for Validation
|
||||||
|
public protocol FormHolderProtocol: NSObjectProtocol {
|
||||||
|
var formValidator: FormValidator? { get set }
|
||||||
|
/// Should call formValidator's validate method
|
||||||
|
func validate()
|
||||||
|
}
|
||||||
13
MVMCoreUI/FormUIHelpers/New/FormItemProtocol.swift
Normal file
13
MVMCoreUI/FormUIHelpers/New/FormItemProtocol.swift
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// FormItemProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/25/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol FormItemProtocol {
|
||||||
|
|
||||||
|
}
|
||||||
15
MVMCoreUI/FormUIHelpers/New/FormProtocol.swift
Normal file
15
MVMCoreUI/FormUIHelpers/New/FormProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// Validatable.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/5/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
//Protocol for Validation
|
||||||
|
public protocol FormProtocol: class {
|
||||||
|
var formRules: [FormGroupRule]? { get set }
|
||||||
|
var formValidator: FormValidator? { get set }
|
||||||
|
}
|
||||||
49
MVMCoreUI/FormUIHelpers/New/Rules/FormGroupRule.swift
Normal file
49
MVMCoreUI/FormUIHelpers/New/Rules/FormGroupRule.swift
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
//
|
||||||
|
// FormRule.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension KeyedDecodingContainer where Key: CodingKey {
|
||||||
|
/// Decodes the list of molecule models with the given coding key based on moleculeName
|
||||||
|
public func decodeFormRules(codingKey: KeyedDecodingContainer<K>.Key) throws -> [RulesProtocol] {
|
||||||
|
guard let models = try decodeModels(codingKey: codingKey, typeCodingKey: RulesCodingKey.ruleType) as? [RulesProtocol] else {
|
||||||
|
throw ModelRegistry.Error.decoderError
|
||||||
|
}
|
||||||
|
return models
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
open class FormGroupRule: Codable {
|
||||||
|
// public static var identifier: String = "formRule"
|
||||||
|
var groupName: String
|
||||||
|
var rules: [RulesProtocol]
|
||||||
|
|
||||||
|
init(_ groupName: String, _ rules: [RulesProtocol]) {
|
||||||
|
self.groupName = groupName
|
||||||
|
self.rules = rules
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case groupName
|
||||||
|
case rules
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.groupName = try typeContainer.decode(String.self, forKey: .groupName)
|
||||||
|
self.rules = try typeContainer.decodeFormRules(codingKey: .rules)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(groupName, forKey: .groupName)
|
||||||
|
try container.encodeModels(rules, forKey: .rules)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyModel.swift
Normal file
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleAnyModel.swift
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// RuleAnyModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class RuleAnyModel: RulesProtocol {
|
||||||
|
|
||||||
|
public static var identifier: String = "any"
|
||||||
|
public var ruleType: String = RuleAnyModel.identifier
|
||||||
|
public var fields: [String]
|
||||||
|
|
||||||
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleEqualsModel.swift
Normal file
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleEqualsModel.swift
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// RuleEqualsModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public class RuleEqualsModel: RulesProtocol {
|
||||||
|
public static var identifier: String = "equals"
|
||||||
|
public var ruleType: String = RuleEqualsModel.identifier
|
||||||
|
public var fields: [String]
|
||||||
|
|
||||||
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
19
MVMCoreUI/FormUIHelpers/New/Rules/RuleRegexModel.swift
Normal file
19
MVMCoreUI/FormUIHelpers/New/Rules/RuleRegexModel.swift
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// RuleRegexModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class RuleRegexModel: RulesProtocol {
|
||||||
|
public static var identifier: String = "regex"
|
||||||
|
public var ruleType: String = RuleRegexModel.identifier
|
||||||
|
public var fields: [String]
|
||||||
|
|
||||||
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
30
MVMCoreUI/FormUIHelpers/New/Rules/RuleRequiredModel.swift
Normal file
30
MVMCoreUI/FormUIHelpers/New/Rules/RuleRequiredModel.swift
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// FormFieldRuleRequiredModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public class RuleRequiredModel: RulesProtocol {
|
||||||
|
|
||||||
|
public static var identifier: String = "required"
|
||||||
|
public var ruleType: String = RuleRequiredModel.identifier
|
||||||
|
public var fields: [String]
|
||||||
|
|
||||||
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
|
guard let value = formField.formFieldValue() else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var valid = true
|
||||||
|
if let valueString = value as? String {
|
||||||
|
valid = valueString.count > 3
|
||||||
|
} else if let valueBool = value as? Bool {
|
||||||
|
valid = valueBool
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
|
}
|
||||||
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleValueChangeModel.swift
Normal file
20
MVMCoreUI/FormUIHelpers/New/Rules/RuleValueChangeModel.swift
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// RuleValueChangeModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 2/24/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public class RuleValueChangeModel: RulesProtocol {
|
||||||
|
|
||||||
|
public static var identifier: String = "valueChanged"
|
||||||
|
public var ruleType: String = RuleAnyModel.identifier
|
||||||
|
public var fields: [String]
|
||||||
|
|
||||||
|
public func isValid(_ formField: FormFieldProtocol) -> Bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
61
MVMCoreUI/FormUIHelpers/New/Rules/RulesProtocol.swift
Normal file
61
MVMCoreUI/FormUIHelpers/New/Rules/RulesProtocol.swift
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
//
|
||||||
|
// FormBaseRulesProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 1/31/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public enum RulesCodingKey: String, CodingKey {
|
||||||
|
case ruleType
|
||||||
|
}
|
||||||
|
|
||||||
|
public protocol RulesProtocol: ModelProtocol {
|
||||||
|
var ruleType: String { get set }
|
||||||
|
var fields: [String] { get set }
|
||||||
|
func isValid(_ formValidator: FormValidator) -> Bool
|
||||||
|
func isValid(_ formField: FormFieldProtocol) -> Bool
|
||||||
|
func setValid(_ formField: FormFieldProtocol, _ isValid: Bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
public extension RulesProtocol {
|
||||||
|
|
||||||
|
var ruleType: String? {
|
||||||
|
get { return Self.identifier }
|
||||||
|
}
|
||||||
|
|
||||||
|
static var categoryCodingKey: String {
|
||||||
|
return "ruleType"
|
||||||
|
}
|
||||||
|
|
||||||
|
static var categoryName: String {
|
||||||
|
return "\(RulesProtocol.self)"
|
||||||
|
}
|
||||||
|
|
||||||
|
func isValid(_ formValidator: FormValidator) -> Bool {
|
||||||
|
var valid = true
|
||||||
|
for formKey in fields {
|
||||||
|
guard let formField = formValidator.formField(for: formKey) else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
valid = valid && isValid(formField)
|
||||||
|
if !valid {
|
||||||
|
setValid(formField, valid)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
setValid(formField, valid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
|
|
||||||
|
func setValid(_ formField: FormFieldProtocol, _ isValid: Bool) {
|
||||||
|
guard let formFieldValid = formField as? ValidProtocol else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formFieldValid.setValidity(isValid)
|
||||||
|
}
|
||||||
|
}
|
||||||
15
MVMCoreUI/FormUIHelpers/New/ValidProtocol.swift
Normal file
15
MVMCoreUI/FormUIHelpers/New/ValidProtocol.swift
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//
|
||||||
|
// ValidProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 3/2/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
public protocol ValidProtocol {
|
||||||
|
var isValid: Bool? { get set }
|
||||||
|
func setValidity(_ isValid: Bool)
|
||||||
|
var updateUI: (() -> Void)? { get set }
|
||||||
|
}
|
||||||
@ -560,11 +560,11 @@
|
|||||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||||
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
[super setWithJSON:json delegateObject:delegateObject additionalData:additionalData];
|
||||||
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
|
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
|
||||||
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
// [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
||||||
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:delegateObject.formValidationProtocol];
|
// FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:delegateObject.formValidationProtocol];
|
||||||
|
|
||||||
[self setWithMap:json];
|
[self setWithMap:json];
|
||||||
self.mfTextFieldDelegate = formValidator;
|
// self.mfTextFieldDelegate = formValidator;
|
||||||
self.uiTextFieldDelegate = delegateObject.uiTextFieldDelegate;
|
self.uiTextFieldDelegate = delegateObject.uiTextFieldDelegate;
|
||||||
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:self.uiTextFieldDelegate];
|
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:self.uiTextFieldDelegate];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
|||||||
|
|
||||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||||
|
|
||||||
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
// [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
||||||
|
|
||||||
self.delegateObject = delegateObject;
|
self.delegateObject = delegateObject;
|
||||||
self.fieldKey = [json stringForKey:KeyFieldKey];
|
self.fieldKey = [json stringForKey:KeyFieldKey];
|
||||||
@ -350,7 +350,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
|
|||||||
[self.checkMark updateCheckSelected:NO animated:animated];
|
[self.checkMark updateCheckSelected:NO animated:animated];
|
||||||
}
|
}
|
||||||
|
|
||||||
[FormValidator enableByValidationWithDelegate:self.delegateObject.formValidationProtocol];
|
// [FormValidator enableByValidationWithDelegate:self.delegateObject.formValidationProtocol];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {
|
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {
|
||||||
|
|||||||
@ -147,7 +147,7 @@ const CGFloat SwitchShakeIntensity = 2;
|
|||||||
self.json = json;
|
self.json = json;
|
||||||
self.delegate = delegateObject;
|
self.delegate = delegateObject;
|
||||||
|
|
||||||
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
// [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
||||||
|
|
||||||
NSString *color = [json string:@"onTintColor"];
|
NSString *color = [json string:@"onTintColor"];
|
||||||
if (color) {
|
if (color) {
|
||||||
@ -339,12 +339,11 @@ const CGFloat SwitchShakeIntensity = 2;
|
|||||||
[self setState:state withoutBlockAnimated:animated];
|
[self setState:state withoutBlockAnimated:animated];
|
||||||
if (self.valueChangedBlock) {
|
if (self.valueChangedBlock) {
|
||||||
self.valueChangedBlock();
|
self.valueChangedBlock();
|
||||||
}
|
}
|
||||||
|
// if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) {
|
||||||
if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) {
|
// FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)];
|
||||||
FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)];
|
// [formValidator enableByValidation];
|
||||||
[formValidator enableByValidation];
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setState:(BOOL)state withoutBlockAnimated:(BOOL)animated {
|
- (void)setState:(BOOL)state withoutBlockAnimated:(BOOL)animated {
|
||||||
|
|||||||
@ -671,7 +671,7 @@
|
|||||||
|
|
||||||
self.validationRequired = [json boolForKey:@"required"];
|
self.validationRequired = [json boolForKey:@"required"];
|
||||||
self.requiredGroupsList = [json array:@"requiredGroups"];
|
self.requiredGroupsList = [json array:@"requiredGroups"];
|
||||||
[FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
// [FormValidator setupValidationWithMolecule:self delegate:delegateObject.formValidationProtocol];
|
||||||
|
|
||||||
self.primaryButtonType = PrimaryButtonTypeCustom;
|
self.primaryButtonType = PrimaryButtonTypeCustom;
|
||||||
NSString *style = [json string:@"style"];
|
NSString *style = [json string:@"style"];
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol {
|
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, FormProtocol {
|
||||||
var template: String { get }
|
var template: String { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers public class RadioButtonLabel: ViewConstrainingView {
|
@objcMembers public class RadioButtonLabel: View {
|
||||||
|
|
||||||
public let radioButton = RadioButton()
|
public let radioButton = RadioButton()
|
||||||
var delegateObject: MVMCoreUIDelegateObject?
|
var delegateObject: MVMCoreUIDelegateObject?
|
||||||
@ -65,26 +65,12 @@ import UIKit
|
|||||||
let rightView = ViewConstrainingView(constrainingView: label)
|
let rightView = ViewConstrainingView(constrainingView: label)
|
||||||
return rightView
|
return rightView
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
guard let radioButtonLabelModel = model as? RadioButtonLabelModel else { return }
|
||||||
extension RadioButtonLabel {
|
|
||||||
@objc open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
radioButton.set(with: radioButtonLabelModel.radioButton, delegateObject, additionalData)
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
label.set(with: radioButtonLabelModel.label, delegateObject, additionalData)
|
||||||
self.delegateObject = delegateObject
|
}
|
||||||
radioButton.setWithJSON(json?.optionalDictionaryForKey("radioButton"), delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
label.setWithJSON(json?.optionalDictionaryForKey(KeyLabel),
|
|
||||||
delegateObject: delegateObject,
|
|
||||||
additionalData: additionalData)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override func reset() {
|
|
||||||
super.reset()
|
|
||||||
radioButton.reset()
|
|
||||||
label.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
|
||||||
return 45
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
17
MVMCoreUI/Molecules/RadioButtonLabelModel.swift
Normal file
17
MVMCoreUI/Molecules/RadioButtonLabelModel.swift
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// RadioButtonLabelModel.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 3/3/20.
|
||||||
|
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objcMembers public class RadioButtonLabelModel: MoleculeModelProtocol {
|
||||||
|
public static var identifier: String = "radioButtonLabel"
|
||||||
|
public var backgroundColor: Color?
|
||||||
|
|
||||||
|
public var radioButton: RadioButtonModel
|
||||||
|
public var label: LabelModel
|
||||||
|
}
|
||||||
@ -9,21 +9,25 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers public class RadioButtonSelectionHelper: NSObject {
|
@objcMembers public class RadioButtonSelectionHelper: FormFieldProtocol {
|
||||||
|
public var fieldKey: String?
|
||||||
private var selectedRadioButton: RadioButton?
|
private var selectedRadioButton: RadioButton?
|
||||||
private var fieldGroupName: String?
|
private var fieldGroupName: String?
|
||||||
|
|
||||||
|
init(_ fieldKey: String?) {
|
||||||
|
self.fieldKey = fieldKey
|
||||||
|
}
|
||||||
|
|
||||||
public static func setupForRadioButtonGroup(radioButton: RadioButton, formValidator: FormValidator?) -> RadioButtonSelectionHelper {
|
public static func setupForRadioButtonGroup(_ radioButtonModel: RadioButtonModel, formValidator: FormValidator?) -> RadioButtonSelectionHelper {
|
||||||
guard let groupName = radioButton.radioGroupName,
|
guard let groupName = radioButtonModel.radioGroupName ?? radioButtonModel.fieldKey,
|
||||||
let formValidator = formValidator else {
|
let formValidator = formValidator else {
|
||||||
return RadioButtonSelectionHelper()
|
return RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
let radioButtonModel = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper()
|
let radioButtonSelectionHelper = formValidator.radioButtonsModelByGroup[groupName] ?? RadioButtonSelectionHelper(radioButtonModel.fieldKey)
|
||||||
radioButtonModel.fieldGroupName = radioButton.formFieldGroupName()
|
radioButtonSelectionHelper.fieldGroupName = radioButtonModel.radioGroupName
|
||||||
formValidator.radioButtonsModelByGroup[groupName] = radioButtonModel
|
formValidator.radioButtonsModelByGroup[groupName] = radioButtonSelectionHelper
|
||||||
return radioButtonModel
|
return radioButtonSelectionHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
public func selected(_ radioButton: RadioButton) {
|
public func selected(_ radioButton: RadioButton) {
|
||||||
@ -34,21 +38,12 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - FormValidationFormFieldProtocol
|
// MARK: - FormValidationFormFieldProtocol
|
||||||
extension RadioButtonSelectionHelper: FormValidationFormFieldProtocol {
|
extension RadioButtonSelectionHelper {
|
||||||
public func formFieldGroupName() -> String? {
|
public func formFieldGroupName() -> String? {
|
||||||
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
return selectedRadioButton?.formFieldGroupName() ?? self.fieldGroupName
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to check the validity of the field, to enable/disable the primary button.
|
public func formFieldValue() -> Any? {
|
||||||
@objc public func isValidField() -> Bool {
|
return selectedRadioButton?.formFieldValue()
|
||||||
return selectedRadioButton != nil ? true : false
|
|
||||||
}
|
|
||||||
// Name of the field to send to server
|
|
||||||
@objc public func formFieldName() -> String? {
|
|
||||||
return selectedRadioButton?.fieldKey
|
|
||||||
}
|
|
||||||
// The field value key value pair for sending to server
|
|
||||||
@objc public func formFieldValue() -> Any? {
|
|
||||||
return selectedRadioButton != nil ? true : false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,16 +9,18 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class MVMCoreUIDelegateObject: DelegateObject {
|
open class MVMCoreUIDelegateObject: DelegateObject {
|
||||||
public weak var formValidationProtocol: FormValidationProtocol?
|
public weak var formHolderDelegate: FormHolderProtocol?
|
||||||
public weak var buttonDelegate: ButtonDelegateProtocol?
|
public weak var buttonDelegate: ButtonDelegateProtocol?
|
||||||
public weak var uiTextFieldDelegate: UITextFieldDelegate?
|
public weak var uiTextFieldDelegate: UITextFieldDelegate?
|
||||||
|
public weak var observingTextFieldDelegate: ObservingTextFieldDelegate?
|
||||||
public var moleculeDelegate: MoleculeDelegateProtocol?
|
public var moleculeDelegate: MoleculeDelegateProtocol?
|
||||||
|
|
||||||
open override func setAll(withDelegate delegate: Any) {
|
open override func setAll(withDelegate delegate: Any) {
|
||||||
super.setAll(withDelegate: delegate)
|
super.setAll(withDelegate: delegate)
|
||||||
formValidationProtocol = delegate as? FormValidationProtocol
|
formHolderDelegate = delegate as? FormHolderProtocol
|
||||||
buttonDelegate = delegate as? ButtonDelegateProtocol
|
buttonDelegate = delegate as? ButtonDelegateProtocol
|
||||||
uiTextFieldDelegate = delegate as? UITextFieldDelegate
|
uiTextFieldDelegate = delegate as? UITextFieldDelegate
|
||||||
|
observingTextFieldDelegate = delegate as? ObservingTextFieldDelegate
|
||||||
moleculeDelegate = delegate as? MoleculeDelegateProtocol
|
moleculeDelegate = delegate as? MoleculeDelegateProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,9 @@ import Foundation
|
|||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Toggle.self, viewModelClass: ToggleModel.self)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Checkbox.self, viewModelClass: CheckboxModel.self)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: CheckboxLabel.self, viewModelClass: CheckboxLabelModel.self)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self)
|
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: Arrow.self, viewModelClass: ArrowModel.self)
|
||||||
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButton.self, viewModelClass: RadioButtonModel.self)
|
||||||
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: RadioButtonLabel.self, viewModelClass: RadioButtonLabelModel.self)
|
||||||
|
|
||||||
// Horizontal Combination Molecules
|
// Horizontal Combination Molecules
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
|
MVMCoreUIMoleculeMappingObject.shared()?.register(viewClass: StringAndMoleculeView.self, viewModelClass: StringAndMoleculeModel.self)
|
||||||
@ -113,10 +114,16 @@ import Foundation
|
|||||||
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DateDropdownEntryField.self, forKey: "dateDropdownEntryField" as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(DateDropdownEntryField.self, forKey: "dateDropdownEntryField" as NSString)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(Checkbox.self, forKey: "checkbox" as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(Checkbox.self, forKey: "checkbox" as NSString)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(CheckboxLabel.self, forKey: "checkboxLabel" as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(CheckboxLabel.self, forKey: "checkboxLabel" as NSString)
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(RadioButtonLabel.self, forKey: "radioButtonLabel" as NSString)
|
|
||||||
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString)
|
MVMCoreUIMoleculeMappingObject.shared()?.moleculeMapping.setObject(MVMCoreUIPageControl.self, forKey: "barsPager" as NSString)
|
||||||
|
|
||||||
// TODO: Need View
|
// TODO: Need View
|
||||||
try? ModelRegistry.register(TabsModel.self)
|
try? ModelRegistry.register(TabsModel.self)
|
||||||
|
|
||||||
|
// Helper models
|
||||||
|
try? ModelRegistry.register(RuleRequiredModel.self)
|
||||||
|
try? ModelRegistry.register(RuleAnyModel.self)
|
||||||
|
try? ModelRegistry.register(RuleValueChangeModel.self)
|
||||||
|
try? ModelRegistry.register(RuleEqualsModel.self)
|
||||||
|
try? ModelRegistry.register(RuleRegexModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class ListPageTemplateModel: TemplateModelProtocol {
|
@objcMembers public class ListPageTemplateModel: TemplateModelProtocol {
|
||||||
|
|
||||||
|
public var formRules: [FormGroupRule]?
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -47,6 +51,7 @@ import Foundation
|
|||||||
case footer
|
case footer
|
||||||
case line
|
case line
|
||||||
case isAtomicTabs
|
case isAtomicTabs
|
||||||
|
case formRules
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -62,6 +67,7 @@ import Foundation
|
|||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
||||||
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
line = try typeContainer.decodeIfPresent(LineModel.self, forKey: .line)
|
||||||
|
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -73,6 +79,7 @@ import Foundation
|
|||||||
try container.encodeModelIfPresent(header, forKey: .header)
|
try container.encodeModelIfPresent(header, forKey: .header)
|
||||||
try container.encodeModelIfPresent(footer, forKey: .footer)
|
try container.encodeModelIfPresent(footer, forKey: .footer)
|
||||||
try container.encode(line, forKey: .line)
|
try container.encode(line, forKey: .line)
|
||||||
|
try container.encodeIfPresent(formRules, forKey: .formRules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,12 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Stored Properties
|
// MARK: - Stored Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
public func validate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]?
|
public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]?
|
||||||
|
|
||||||
var observer: NSKeyValueObservation?
|
var observer: NSKeyValueObservation?
|
||||||
|
|||||||
@ -9,6 +9,11 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||||
|
public func validate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
var observer: NSKeyValueObservation?
|
var observer: NSKeyValueObservation?
|
||||||
public var templateModel: StackPageTemplateModel?
|
public var templateModel: StackPageTemplateModel?
|
||||||
|
|||||||
@ -10,8 +10,35 @@ import Foundation
|
|||||||
|
|
||||||
@objcMembers public class StackCenteredPageTemplateModel: TemplateModelProtocol {
|
@objcMembers public class StackCenteredPageTemplateModel: TemplateModelProtocol {
|
||||||
|
|
||||||
|
public var formRules: [FormGroupRule]?
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
public static var identifier: String = "stackCenterTemplate"
|
public static var identifier: String = "stackCenterTemplate"
|
||||||
public var pageType: String
|
public var pageType: String
|
||||||
public var screenHeading: String?
|
public var screenHeading: String?
|
||||||
public var isAtomicTabs: Bool?
|
public var isAtomicTabs: Bool?
|
||||||
|
|
||||||
|
public init(pageType: String) {
|
||||||
|
self.pageType = pageType
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case pageType
|
||||||
|
case screenHeading
|
||||||
|
case isAtomicTabs
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
pageType = try typeContainer.decode(String.self, forKey: .pageType)
|
||||||
|
screenHeading = try typeContainer.decodeIfPresent(String.self, forKey: .screenHeading)
|
||||||
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(pageType, forKey: .pageType)
|
||||||
|
try container.encodeIfPresent(screenHeading, forKey: .screenHeading)
|
||||||
|
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,9 @@ import Foundation
|
|||||||
|
|
||||||
|
|
||||||
@objcMembers public class StackPageTemplateModel: TemplateModelProtocol {
|
@objcMembers public class StackPageTemplateModel: TemplateModelProtocol {
|
||||||
|
public var formRules: [FormGroupRule]?
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
public static var identifier: String = "stack"
|
public static var identifier: String = "stack"
|
||||||
|
|
||||||
public var pageType: String
|
public var pageType: String
|
||||||
@ -32,6 +35,7 @@ import Foundation
|
|||||||
case footer
|
case footer
|
||||||
case stack
|
case stack
|
||||||
case isAtomicTabs
|
case isAtomicTabs
|
||||||
|
case formRules
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(from decoder: Decoder) throws {
|
required public init(from decoder: Decoder) throws {
|
||||||
@ -42,6 +46,7 @@ import Foundation
|
|||||||
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
isAtomicTabs = try typeContainer.decodeIfPresent(Bool.self, forKey: .isAtomicTabs)
|
||||||
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
header = try typeContainer.decodeMoleculeIfPresent(codingKey: .header)
|
||||||
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
footer = try typeContainer.decodeMoleculeIfPresent(codingKey: .footer)
|
||||||
|
formRules = try typeContainer.decodeIfPresent([FormGroupRule].self, forKey: .formRules)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
@ -52,5 +57,6 @@ import Foundation
|
|||||||
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
try container.encodeIfPresent(isAtomicTabs, forKey: .isAtomicTabs)
|
||||||
try container.encodeModelIfPresent(header, forKey: .header)
|
try container.encodeModelIfPresent(header, forKey: .header)
|
||||||
try container.encodeModelIfPresent(footer, forKey: .footer)
|
try container.encodeModelIfPresent(footer, forKey: .footer)
|
||||||
|
try container.encodeIfPresent(formRules, forKey: .formRules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,18 +8,22 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public protocol TemplateProtocol: class {
|
|
||||||
|
public protocol TemplateProtocol: FormHolderProtocol {
|
||||||
associatedtype TemplateModel: TemplateModelProtocol
|
associatedtype TemplateModel: TemplateModelProtocol
|
||||||
var templateModel: TemplateModel? { get set }
|
var templateModel: TemplateModel? { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension TemplateProtocol where Self: MFViewController {
|
public extension TemplateProtocol where Self: MFViewController {
|
||||||
|
|
||||||
func parseTemplateJSON() throws {
|
func parseTemplateJSON() throws {
|
||||||
guard let pageJSON = self.loadObject?.pageJSON else { return }
|
guard let pageJSON = self.loadObject?.pageJSON else { return }
|
||||||
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
let data = try JSONSerialization.data(withJSONObject: pageJSON)
|
||||||
let decoder = JSONDecoder()
|
let decoder = JSONDecoder()
|
||||||
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
let templateModel = try decoder.decode(TemplateModel.self, from: data)
|
||||||
|
|
||||||
|
if self.formValidator == nil, let rules = templateModel.formRules {
|
||||||
|
self.formValidator = FormValidator(rules)
|
||||||
|
}
|
||||||
self.templateModel = templateModel
|
self.templateModel = templateModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class ThreeLayerPageTemplateModel: TemplateModelProtocol {
|
@objcMembers public class ThreeLayerPageTemplateModel: TemplateModelProtocol {
|
||||||
|
|
||||||
|
public var formRules: [FormGroupRule]?
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
public static var identifier: String = "threeLayer"
|
public static var identifier: String = "threeLayer"
|
||||||
|
|
||||||
public var pageType: String
|
public var pageType: String
|
||||||
|
|||||||
@ -9,6 +9,11 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
@objcMembers open class ThreeLayerTemplate: ThreeLayerViewController, TemplateProtocol {
|
||||||
|
public func validate() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public var formValidator: FormValidator?
|
||||||
|
|
||||||
public var templateModel: ThreeLayerPageTemplateModel?
|
public var templateModel: ThreeLayerPageTemplateModel?
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user