From 335ec160b506f33d81550a128956485a5c23b2da Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Fri, 13 Mar 2020 10:04:47 -0400 Subject: [PATCH] swift --- MVMCoreUI.xcodeproj/project.pbxproj | 52 ++-- .../Atoms/TextFields/TextEntryField.swift | 2 +- .../ProgrammaticScrollViewController.swift | 56 ++++ .../ProgrammaticTableViewController.swift | 81 +++++ .../ScrollingViewController.swift | 109 +++++++ .../ThreeLayerTableViewController.swift | 27 +- .../ThreeLayerViewController.swift | 27 +- .../BaseControllers/ViewController.swift | 286 +++++++++++++++++- ...MVMCoreUITabBarPageControlViewController.m | 2 +- .../New/FormHolderProtocol.swift | 2 - .../MFProgrammaticScrollViewController.h} | 4 +- .../MFProgrammaticScrollViewController.m} | 8 +- .../MFProgrammaticTableViewController.h | 0 .../MFProgrammaticTableViewController.m | 0 .../Controllers}/MFScrollingViewController.h | 0 .../Controllers}/MFScrollingViewController.m | 0 .../Controllers}/MFViewController+Form.swift | 0 .../Controllers}/MFViewController+Model.swift | 0 .../Controllers}/MFViewController.h | 0 .../Controllers}/MFViewController.m | 0 .../MVMCoreUIStackableViewController.h | 4 +- .../MVMCoreUIStackableViewController.m | 0 MVMCoreUI/MVMCoreUI.h | 2 +- .../ModelProtocols/PageModelProtocol.swift | 1 + .../Items/DropDownFilterTableViewCell.swift | 7 +- .../NavigationItemModelProtocol.swift | 17 ++ .../OtherHandlers/MVMCoreUILoggingHandler.h | 6 +- .../OtherHandlers/MVMCoreUILoggingHandler.m | 6 +- .../Templates/ListPageTemplateModel.swift | 1 + .../Templates/ModalMoleculeListTemplate.swift | 8 +- .../ModalMoleculeStackTemplate.swift | 8 +- .../Templates/MoleculeListTemplate.swift | 51 +--- .../Templates/MoleculeStackTemplate.swift | 27 +- .../StackCenteredPageTemplateModel.swift | 1 + .../Templates/StackPageTemplateModel.swift | 1 + MVMCoreUI/Templates/TemplateProtocol.swift | 2 +- .../ThreeLayerPageTemplateModel.swift | 1 + MVMCoreUI/Templates/ThreeLayerTemplate.swift | 15 +- 38 files changed, 639 insertions(+), 175 deletions(-) create mode 100644 MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift create mode 100644 MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift create mode 100644 MVMCoreUI/BaseControllers/ScrollingViewController.swift rename MVMCoreUI/{BaseControllers/ProgrammaticScrollViewController.h => Legacy/Controllers/MFProgrammaticScrollViewController.h} (61%) rename MVMCoreUI/{BaseControllers/ProgrammaticScrollViewController.m => Legacy/Controllers/MFProgrammaticScrollViewController.m} (92%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFProgrammaticTableViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFProgrammaticTableViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFScrollingViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFScrollingViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController+Form.swift (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController+Model.swift (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController.h (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MFViewController.m (100%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MVMCoreUIStackableViewController.h (95%) rename MVMCoreUI/{BaseControllers => Legacy/Controllers}/MVMCoreUIStackableViewController.m (100%) create mode 100644 MVMCoreUI/Molecules/NavigationItemModelProtocol.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index b5985e36..7aa2b2dd 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -178,6 +178,7 @@ C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012023E8303200396FBD /* ListRVWheel.swift */; }; C7F8012323E846C300396FBD /* ListRVWheelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F8012223E846C300396FBD /* ListRVWheelModel.swift */; }; D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; }; + D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */; }; D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; }; D21EE53C23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */; }; D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelToggle.swift */; }; @@ -285,11 +286,11 @@ D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28B21E7AC2B003B2FB9 /* ViewConstrainingView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */; }; - D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */; }; + D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m */; }; D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */; }; D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */; }; - D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D29DF29921E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF29A21E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */; }; @@ -342,6 +343,9 @@ D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A638FC22CA98280052ED1F /* HeadlineBody.swift */; }; D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390022CBB1820052ED1F /* Carousel.swift */; }; D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */; }; + D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */; }; + D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */; }; + D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */; }; D2B18B7F2360913400A9AEDC /* Control.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B7E2360913400A9AEDC /* Control.swift */; }; D2B18B812360945C00A9AEDC /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B802360945C00A9AEDC /* View.swift */; }; D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */; }; @@ -539,6 +543,7 @@ C7F8012023E8303200396FBD /* ListRVWheel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListRVWheel.swift; sourceTree = ""; }; C7F8012223E846C300396FBD /* ListRVWheelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRVWheelModel.swift; sourceTree = ""; }; D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = ""; }; + D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationItemModelProtocol.swift; sourceTree = ""; }; D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = ""; }; D21EE53B23AD3AD4003D1A30 /* NSLayoutConstraintAxis+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraintAxis+Extension.swift"; sourceTree = ""; }; D22479892314445E003FCCF9 /* LabelToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelToggle.swift; sourceTree = ""; }; @@ -666,11 +671,11 @@ D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = ""; }; D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewConstrainingView.h; sourceTree = ""; }; D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewConstrainingView.m; sourceTree = ""; }; - D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProgrammaticScrollViewController.m; sourceTree = ""; }; + D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFProgrammaticScrollViewController.m; sourceTree = ""; }; D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StackableViewController.m; sourceTree = ""; }; D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFScrollingViewController.h; sourceTree = ""; }; D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFScrollingViewController.m; sourceTree = ""; }; - D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgrammaticScrollViewController.h; sourceTree = ""; }; + D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFProgrammaticScrollViewController.h; sourceTree = ""; }; D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFProgrammaticTableViewController.h; sourceTree = ""; }; D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackableViewController.h; sourceTree = ""; }; D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFProgrammaticTableViewController.m; sourceTree = ""; }; @@ -717,6 +722,9 @@ D2A638FC22CA98280052ED1F /* HeadlineBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBody.swift; sourceTree = ""; }; D2A6390022CBB1820052ED1F /* Carousel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Carousel.swift; sourceTree = ""; }; D2A6390422CBCE160052ED1F /* MoleculeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeCollectionViewCell.swift; sourceTree = ""; }; + D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollingViewController.swift; sourceTree = ""; }; + D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticScrollViewController.swift; sourceTree = ""; }; + D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgrammaticTableViewController.swift; sourceTree = ""; }; D2B18B7E2360913400A9AEDC /* Control.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Control.swift; sourceTree = ""; }; D2B18B802360945C00A9AEDC /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = ""; }; D2B18B912361E65A00A9AEDC /* CoreUIObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreUIObject.swift; sourceTree = ""; }; @@ -927,8 +935,20 @@ D213347423842FE3008E41B3 /* Controllers */ = { isa = PBXGroup; children = ( + D29DF16021E69996003B2FB9 /* MFViewController.h */, + D29DF15F21E69996003B2FB9 /* MFViewController.m */, + 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, + 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */, + D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, + D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, + D29DF29121E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h */, + D29DF28D21E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m */, D29DF29321E7ADB8003B2FB9 /* StackableViewController.h */, D29DF28E21E7ADB8003B2FB9 /* StackableViewController.m */, + D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */, + D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */, + D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */, + D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */, D29770F021F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h */, D29770F121F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m */, D29770EF21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.h */, @@ -1269,6 +1289,7 @@ 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */, 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */, D260105723CF9CC500764D80 /* Doughnut */, + D20FB164241A5D75004AFC3A /* NavigationItemModelProtocol.swift */, ); path = Molecules; sourceTree = ""; @@ -1276,23 +1297,14 @@ D29DF10F21E67A7D003B2FB9 /* BaseControllers */ = { isa = PBXGroup; children = ( - D29DF16021E69996003B2FB9 /* MFViewController.h */, - D29DF15F21E69996003B2FB9 /* MFViewController.m */, - 017BEB3B2361EA1D0024EF95 /* MFViewController+Model.swift */, - 011D9627240EFA1E000E3791 /* MFViewController+Form.swift */, - D29DF28F21E7ADB8003B2FB9 /* MFScrollingViewController.h */, - D29DF29021E7ADB8003B2FB9 /* MFScrollingViewController.m */, - D29DF29121E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h */, - D29DF28D21E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m */, - D29DF29221E7ADB8003B2FB9 /* MFProgrammaticTableViewController.h */, - D29DF29421E7ADB8003B2FB9 /* MFProgrammaticTableViewController.m */, - D22D1F542204CE5D0077CEC0 /* MVMCoreUIStackableViewController.h */, - D22D1F552204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m */, D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */, D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */, D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */, D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */, D2C521A823EDE79E00CA2634 /* ViewController.swift */, + D2A92881241AAB67004E01C6 /* ScrollingViewController.swift */, + D2A92883241ACB25004E01C6 /* ProgrammaticScrollViewController.swift */, + D2A92885241ACD99004E01C6 /* ProgrammaticTableViewController.swift */, ); path = BaseControllers; sourceTree = ""; @@ -1618,7 +1630,7 @@ D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */, 0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */, D22D1F1A220341F60077CEC0 /* MVMCoreUICheckBox.h in Headers */, - D29DF29921E7ADB8003B2FB9 /* ProgrammaticScrollViewController.h in Headers */, + D29DF29921E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.h in Headers */, D29DF11C21E684A9003B2FB9 /* MVMCoreUISplitViewController.h in Headers */, D29DF29B21E7ADB9003B2FB9 /* StackableViewController.h in Headers */, D29770F421F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.h in Headers */, @@ -1821,6 +1833,7 @@ D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */, D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */, 01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */, + D2A92884241ACB25004E01C6 /* ProgrammaticScrollViewController.swift in Sources */, 0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */, D2E2A99F23E07F8A000B42E6 /* PillButton.swift in Sources */, D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */, @@ -1874,6 +1887,7 @@ D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, + D2A92886241ACD99004E01C6 /* ProgrammaticTableViewController.swift in Sources */, 01509D952327ED1900EF99AA /* HeadlineBodyLinkToggle.swift in Sources */, 31BE15CB23D8924D00452370 /* CheckboxLabelModel.swift in Sources */, D260105523CEA7DC00764D80 /* MVMCoreUISwitch+Model.swift in Sources */, @@ -1946,7 +1960,7 @@ D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, - D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */, + D29DF29521E7ADB8003B2FB9 /* MFProgrammaticScrollViewController.m in Sources */, D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */, D2A638FD22CA98280052ED1F /* HeadlineBody.swift in Sources */, D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */, @@ -1956,9 +1970,11 @@ D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, 0AE98BB323FF0934004C5109 /* ExternalLinkModel.swift in Sources */, + D20FB165241A5D75004AFC3A /* NavigationItemModelProtocol.swift in Sources */, DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */, 0A21DB89235E06EF00C160A2 /* MFMdnTextField.m in Sources */, D224798A2314445E003FCCF9 /* LabelToggle.swift in Sources */, + D2A92882241AAB67004E01C6 /* ScrollingViewController.swift in Sources */, D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */, C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */, 0AE98BB523FF18D2004C5109 /* Arrow.swift in Sources */, diff --git a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift index 993aed59..c3aa19c6 100644 --- a/MVMCoreUI/Atoms/TextFields/TextEntryField.swift +++ b/MVMCoreUI/Atoms/TextFields/TextEntryField.swift @@ -311,7 +311,7 @@ import UIKit uiTextFieldDelegate = delegateObject?.uiTextFieldDelegate observingTextFieldDelegate = delegateObject?.observingTextFieldDelegate - MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) + //MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate) } } diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift new file mode 100644 index 00000000..10583b14 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.swift @@ -0,0 +1,56 @@ +// +// ProgrammaticScrollViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ProgrammaticScrollViewController: ScrollingViewController { + public var topConstraint: NSLayoutConstraint? + public var bottomConstraint: NSLayoutConstraint? + + public override init(with scrollView: UIScrollView) { + super.init(with: scrollView) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + open override func loadView() { + + let view = UIView() + view.backgroundColor = .white + + let scrollView = UIScrollView() + scrollView.backgroundColor = .clear + scrollView.translatesAutoresizingMaskIntoConstraints = true + view.addSubview(scrollView) + + // Sets the constraints for the scroll view + let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: scrollView) + topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint + bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + + let contentView = MVMCoreUICommonViewsUtility.commonView() + scrollView.addSubview(contentView) + + // Sets the constraints for the content view + NSLayoutConstraint.constraintPinSubview(toSuperview: contentView) + + // Super will set later. + contentWidthConstraint = contentView.widthAnchor.constraint(equalToConstant: 320.0) + contentWidthConstraint?.isActive = true + + self.contentView = contentView + self.scrollView = scrollView + self.view = view + } +} diff --git a/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift new file mode 100644 index 00000000..4e262398 --- /dev/null +++ b/MVMCoreUI/BaseControllers/ProgrammaticTableViewController.swift @@ -0,0 +1,81 @@ +// +// ProgrammaticTableViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ProgrammaticTableViewController: ProgrammaticScrollViewController, UITableViewDelegate, UITableViewDataSource { + @IBOutlet public var tableView: UITableView! + + public init(with tableView: UITableView) { + self.tableView = tableView + super.init(with: tableView) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + open override func loadView() { + let view = UIView() + view.backgroundColor = .white + + let tableView = createTableView() + tableView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(tableView) + + // Sets the constraints for the scroll view + let constraints = NSLayoutConstraint.constraintPinSubview(toSuperview: tableView) + topConstraint = constraints?[ConstraintTop] as? NSLayoutConstraint + bottomConstraint = constraints?[ConstraintBot] as? NSLayoutConstraint + + self.tableView = tableView + scrollView = tableView + self.view = view + } + + /// This class should create the table view that will be used here. Subclass this for different table styles. + open func createTableView() -> UITableView { + let tableView = UITableView(frame: .zero, style: .grouped) + tableView.backgroundColor = .clear + tableView.separatorStyle = UITableViewCell.SeparatorStyle.none + tableView.delegate = self + tableView.dataSource = self + tableView.insetsContentViewsToSafeArea = false + return tableView + } + + // Registers classes and nibs. Can subclass for different nibs. Can call super and then add new ones after as well. + open func registerWithTable() {} + + /// Sets the table to have no section headers or footers. + open func setNoSectionHeadersFooters() { + tableView.sectionHeaderHeight = CGFloat.leastNormalMagnitude + tableView.sectionFooterHeight = CGFloat.leastNormalMagnitude + } + + /// For subclassing, returns the number of sections for table. This function calls numberOfSectionsForTableview aftre ensuring the table is setup properly. + open func getNumberOfSections() -> Int { + return 1 + } + + open func numberOfSections(in tableView: UITableView) -> Int { + return tableView.bounds.width > 1 ? getNumberOfSections() : 0 + } + + open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 0 + } + + open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return UITableViewCell() + } +} diff --git a/MVMCoreUI/BaseControllers/ScrollingViewController.swift b/MVMCoreUI/BaseControllers/ScrollingViewController.swift new file mode 100644 index 00000000..2e4eceef --- /dev/null +++ b/MVMCoreUI/BaseControllers/ScrollingViewController.swift @@ -0,0 +1,109 @@ +// +// ScrollingViewController.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +open class ScrollingViewController: ViewController { + public var dismissKeyboardTapGesture: UITapGestureRecognizer? + @IBOutlet public var scrollView: UIScrollView! + public var contentView: UIView? + public var contentWidthConstraint: NSLayoutConstraint? + + private var keyboardNotificationsAdded = false + private var keyboardIsShowing = false + private var preKeyboardContentInset: UIEdgeInsets? + + public init(with scrollView: UIScrollView) { + self.scrollView = scrollView + super.init(nibName: nil, bundle: nil) + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + } + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + // MARK: - View Life Cycle + open override func viewDidLoad() { + super.viewDidLoad() + + // Adds the tap gesture to dismiss the keyboard. + dismissKeyboardTapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissFieldInput(sender:))) + view.addGestureRecognizer(dismissKeyboardTapGesture!) + dismissKeyboardTapGesture?.isEnabled = false + scrollView.alwaysBounceVertical = false + scrollView.delegate = self + } + + open override func updateViewConstraints() { + super.updateViewConstraints() + // Sets the width of the content to the width of the screen. + contentWidthConstraint?.constant = view.bounds.width - scrollView.contentInset.left - scrollView.contentInset.right + } + + open override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() + view.setNeedsUpdateConstraints() + view.layoutSubviews() + } + + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + registerForKeyboardNotifications() + } + + // MARK: - Keyboard Handling + open func registerForKeyboardNotifications() { + if !keyboardNotificationsAdded { + keyboardNotificationsAdded = true + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillBeHidden(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) + } + } + + open func unregisterForKeyboardNotifications() { + if keyboardNotificationsAdded { + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) + keyboardNotificationsAdded = false + } + } + + @objc open func keyboardWillShow(notification: Notification) { + // Stores the current scroll insets if the keyboard was hidden. + if !keyboardIsShowing { + preKeyboardContentInset = scrollView.contentInset + } + keyboardIsShowing = true + + // Enables the tap gesture. + dismissKeyboardTapGesture?.isEnabled = true + + MVMCoreUIUtility.setScrollViewInsetForKeyboardShow(notification, scrollView: scrollView, viewController: self) { [weak self] () -> CGRect in + return self?.rectToScrollToWhenKeyboardPopsUp() ?? .zero + } + } + + @objc open func keyboardWillBeHidden(notification: Notification) { + keyboardIsShowing = false + + // Disables the tap gesture. + dismissKeyboardTapGesture?.isEnabled = false + + MVMCoreUIUtility.setScrollViewInsetForKeyboardHide(notification, scrollView: scrollView, viewController: self, contentInset: preKeyboardContentInset ?? scrollView.contentInset) + } + + open func rectToScrollToWhenKeyboardPopsUp() -> CGRect? { + guard let field = selectedField, + let parent = selectedField?.superview else { return nil } + return scrollView.convert(field.frame, from: parent) + } +} diff --git a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift index ae3d2fac..2fba0e07 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerTableViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMAnimationFramework -open class ThreeLayerTableViewController: MFProgrammaticTableViewController { +open class ThreeLayerTableViewController: ProgrammaticTableViewController { // The three main views private var topView: UIView? private var bottomView: UIView? @@ -36,17 +36,17 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController { self.tableView?.reloadData() } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { createViewForTableHeader() createViewForTableFooter() tableView?.reloadData() + super.handleNewData() } override open func viewDidLoad() { super.viewDidLoad() - setToHaveNoSectionHeadersFooters() // Do any additional setup after loading the view. + setNoSectionHeadersFooters() } //MARK: - Spacing @@ -227,26 +227,7 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController { return view } - //MARK: - Scrollview - open override func scrollViewDidScroll(_ scrollView: UIScrollView) { - // To stop handscroll animation if animating after scroll - stopHandScrollAnimation(true) - } - deinit { tableView?.delegate = nil } - - //MARK: - Animation - open override func setupIntroAnimations() { - if let topView = topView, topView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: topView)) - } - if let tableView = tableView { - introAnimationManager?.addAnimation(animation: MVMAnimations.animateTableViewFadeInCells(tableView: tableView)) - } - if let bottomView = bottomView, bottomView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: bottomView)) - } - } } diff --git a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift index ea6923c5..bf557814 100644 --- a/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift +++ b/MVMCoreUI/BaseControllers/ThreeLayerViewController.swift @@ -61,21 +61,25 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController { } } - open override func newDataBuildScreen() { - super.newDataBuildScreen() - + open override func handleNewData() { // Removes the views topView?.removeFromSuperview() middleView?.removeFromSuperview() bottomView?.removeFromSuperview() safeAreaView?.removeFromSuperview() - MVMCoreUIStackableViewController.remove(contentView?.subviews) + if let subViews = contentView?.subviews { + for view in subViews { + view.removeFromSuperview() + } + } // Reset constraints bottomConstraint?.isActive = true heightConstraint?.isActive = false setupLayers() + + super.handleNewData() } //MARK:-Functions to subclass @@ -241,18 +245,3 @@ extension ThreeLayerViewController { } } } - -//MARK:-Animation -extension ThreeLayerViewController { - open override func setupIntroAnimations() { - if let topView = topView, topView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: topView)) - } - if let middleView = middleView, middleView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: middleView)) - } - if let bottomView = bottomView, bottomView.subviews.count > 0 { - introAnimationManager?.addAnimation(animation: MVMAnimations.fadeUpAnimation(view: bottomView)) - } - } -} diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 1bb06324..96b56ce4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -8,19 +8,110 @@ import UIKit -@objcMembers open class ViewController: UIViewController, MVMCoreViewControllerProtocol { +open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, UITextFieldDelegate, UITextViewDelegate { public var pageType: String? public var loadObject: MVMCoreLoadObject? public var pageModel: PageModelProtocol? + + /// Set if this page is containted in a manager. + public var manager: (UIViewController & MVMCoreViewManagerProtocol)? + + public var selfDelegateObject: MVMCoreUIDelegateObject? + public func delegateObject() -> DelegateObject? { + if selfDelegateObject == nil { + selfDelegateObject = MVMCoreUIDelegateObject.create(withDelegateForAll: self) + } + return selfDelegateObject + } + + public var formValidator: FormValidator? + + public var needsUpdateUI = true + private var observingForResponses = false + private var initialLoadFinished = false + private var previousScreenSize = CGSize.zero + + public var selectedField: UIView? - // MARK: Response handling - public func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { + /// Checks if the screen width has changed + open func screenSizeChanged() -> Bool { + return MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1) + } + + // MARK: - Response handling + open func observeForResponseJSONUpdates() { + guard !observingForResponses, + (pagesToListenFor()?.count ?? 0 > 0 || modulesToListenFor()?.count ?? 0 > 0) else { return } + observingForResponses = true + NotificationCenter.default.addObserver(self, selector: #selector(responseJSONUpdated(notification:)), name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil) + } + + open func stopObservingForResponseJSONUpdates() { + guard observingForResponses else { return } + NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NotificationResponseLoaded), object: nil) + observingForResponses = false + } + + open func pagesToListenFor() -> [String]? { + guard let pageType = loadObject?.pageType else { return nil } + return [pageType] + } + + open func modulesToListenFor() -> [String]? { + return loadObject?.requestParameters?.modules as? [String] + } + + @objc open func responseJSONUpdated(notification: Notification) { + // Checks for a page we are listening for. + var newData = false + if let pagesLoaded = notification.userInfo?.optionalDictionaryForKey(KeyPageMap), + let pageType = pagesToListenFor()?.first(where: { (pageTypeListened) -> Bool in + guard let page = pagesLoaded.optionalDictionaryForKey(pageTypeListened), + let pageType = page.optionalStringForKey(KeyPageType), + pageType == pageTypeListened else { return false } + return true + }) { + newData = true + loadObject?.pageJSON = pagesLoaded.optionalDictionaryForKey(pageType) + } + + // Checks for modules we are listening for. + if let modulesLoaded = notification.userInfo?.optionalDictionaryForKey(KeyModuleMap), + let modulesListened = modulesToListenFor() { + for moduleName in modulesListened { + if let module = modulesLoaded.optionalDictionaryForKey(moduleName) { + newData = true + var currentModules = loadObject?.modulesJSON ?? [:] + currentModules.updateValue(module, forKey: moduleName) + loadObject?.modulesJSON = currentModules + } + } + } + + guard newData else { return } + do { + try parsePageJSON() + MVMCoreDispatchUtility.performBlock(onMainThread: { + self.handleNewDataAndUpdateUI() + }) + } catch { + if let coreError = MVMCoreErrorObject.createErrorObject(for: error, location: "updateJSON for pageType: \(String(describing: pageType))") { + MVMCoreLoggingHandler.shared()?.addError(toLog: coreError) + } + } + } + + open func shouldFinishProcessingLoad(_ loadObject: MVMCoreLoadObject, error: AutoreleasingUnsafeMutablePointer) -> Bool { pageType = loadObject.pageType self.loadObject = loadObject + // Verifies all modules needed are loaded. + guard MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) else { return false } + // Parse the model for the page. do { try parsePageJSON() + return true } catch let parsingError { // Log all parsing errors and fail load. if let errorObject = MVMCoreErrorObject.createErrorObject(for: parsingError, location: MVMCoreLoadHandler.sharedGlobal()?.errorLocation(forRequest: loadObject)) { @@ -29,15 +120,12 @@ import UIKit } return false } - - // Verifies all modules needed are loaded. - return MFViewController.verifyRequiredModulesLoaded(for: loadObject, error: error) } - @objc func parsePageJSON() throws { + open func parsePageJSON() throws { } - public class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { + open class func verifyRequiredModulesLoaded(for loadObject: MVMCoreLoadObject?, error: inout MVMCoreErrorObject?) -> Bool { guard let pageType = loadObject?.pageType, var modulesRequired = MVMCoreUIViewControllerMappingObject.shared()?.modulesRequired(forPageType: pageType) else { return true } guard let loadedModules = loadObject?.modulesJSON else { return false } @@ -58,17 +146,28 @@ import UIKit return true } - open func setNavigationItem() { + open func set(navigationItem: UINavigationItem) { navigationItem.title = pageModel?.screenHeading navigationItem.accessibilityLabel = pageModel?.screenHeading } - - open func newDataBuildScreen() { - // TODO atomize the navigation item - setNavigationItem() + + /// Calls processNewData and then sets the ui to update with updateView + open func handleNewDataAndUpdateUI() { + handleNewData() + self.needsUpdateUI = true + self.view.setNeedsLayout() } + /// Processes any new data. Called after the page is loaded the first time and on response updates for this page, + open func handleNewData() { + // TODO atomize the navigation item + set(navigationItem: navigationItem) + formValidator?.validate() + } + + // MARK: - View lifecycle open func initialLoad() { + observeForResponseJSONUpdates() } open func updateViews() { @@ -78,5 +177,166 @@ import UIKit super.viewDidLoad() // Do any additional setup after loading the view. + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "View Controller Loaded : \(self)") + + viewRespectsSystemMinimumLayoutMargins = false + + // Presents from the bottom. + modalPresentationStyle = MVMCoreGetterUtility.isOnIPad() ? UIModalPresentationStyle.formSheet : UIModalPresentationStyle.overCurrentContext + + // Do some initial loading. + if !initialLoadFinished { + initialLoadFinished = true + initialLoad() + } + + // Handle data on load + handleNewData() + + view.setNeedsLayout() + } + + open override func viewDidLayoutSubviews() { + // Add to fix a constraint bug where the width is zero and things get messed up. + guard isViewLoaded, + view.bounds.width > 1 else { + super.viewDidLayoutSubviews() + return + } + if needsUpdateUI || screenSizeChanged() { + updateViews() + needsUpdateUI = false + } + super.viewDidLayoutSubviews() + } + + open override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + // Update the navigation bar ui when view is appearing unless in a manager. The manager is expected to handle. + if manager == nil { + set(navigationItem: navigationItem) + } + } + + open override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if manager == nil { + MVMCoreUISession.sharedGlobal()?.currentPageType = pageType + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + } + } + + deinit { + stopObservingForResponseJSONUpdates() + MVMCoreLoggingHandler.logDebugMessage(withDelegate: "View Controller Deallocated : \(self)") + } + + open override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + return MVMCoreGetterUtility.isOnIPad() ? UIInterfaceOrientationMask.all : UIInterfaceOrientationMask.portrait + } + + open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + + // Updates the detail view width + coordinator.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) in + }) { (UIViewControllerTransitionCoordinatorContext) in + self.view.setNeedsLayout() + } + } + + // MARK: - MVMCoreViewManagerViewControllerProtocol + open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) { + if initialLoadFinished { + set(navigationItem: manager.navigationItem) + } + MVMCoreUISession.sharedGlobal()?.currentPageType = pageType + MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self) + } + + // MARK: - MVMCoreActionDelegateProtocol + open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { + formValidator?.addFormParams(requestParameters: requestParameters) + requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") + MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, additionalData: additionalData, delegateObject: selfDelegateObject) + } + + // MARK: - MoleculeDelegateProtocol + open func getModuleWithName(_ name: String?) -> [AnyHashable : Any]? { + guard let name = name else { return nil } + return loadObject?.modulesJSON?.optionalDictionaryForKey(name) + } + + open func getModuleWithName(_ moleculeName: String) -> MoleculeModelProtocol? { + guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName), + let moleculeName = moduleJSON.optionalStringForKey("moleculeName"), + let modelType = ModelRegistry.getType(for: moleculeName, with: MoleculeModelProtocol.self) + else { return nil } + do { + return try modelType.decode(jsonDict: moduleJSON) as? MoleculeModelProtocol + } catch { + MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)") + } + + return nil + } + + // Test to see if needed. + open func moleculeLayoutUpdated(_ molecule: UIView & MVMCoreUIMoleculeViewProtocol) { + + } + open func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + } + open func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + + } + + // MARK: - UITextFieldDelegate (Check if this is still needed) + // To Remove TextFields Bug: Keyboard is not dismissing after reaching textfield max length limit + open func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + return true + } + + open func textFieldDidBeginEditing(_ textField: UITextField) { + selectedField = textField + + // TODO: Make this into a protocol + if UIAccessibility.isVoiceOverRunning { + if let toolBar = textField.inputAccessoryView as? UIToolbar, let _ = toolBar.items?.last, let pickerView = textField.inputView as? UIPickerView { + view.accessibilityElements = [pickerView, toolBar] + } + DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { + UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: textField.inputView) + } + } + } + + open func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) { + if textField === selectedField { + if UIAccessibility.isVoiceOverRunning { + view.accessibilityElements = nil + UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: textField) + } + selectedField = nil + } + } + + @objc open func dismissFieldInput(sender: Any?) { + selectedField?.resignFirstResponder() + } + + // MARK: - UITextViewDelegate (Check if this is still needed) + open func textViewDidBeginEditing(_ textView: UITextView) { + selectedField = textView + } + + open func textViewDidEndEditing(_ textView: UITextView) { + if textView === selectedField { + selectedField = nil + } } } diff --git a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m index cb48eb54..d700e57f 100644 --- a/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m +++ b/MVMCoreUI/Containers/TabBarController/MVMCoreUITabBarPageControlViewController.m @@ -227,7 +227,7 @@ self.selectedIndex = i; [tabbar selectIndex:self.selectedIndex animated:NO]; - if ([self.viewController respondsToSelector:@selector(shouldCacheInManager)] && [((UIViewController *)self.viewController) shouldCacheInManager]) { + if (![self.viewController respondsToSelector:@selector(shouldCacheInManager)] || [((UIViewController *)self.viewController) shouldCacheInManager]) { [viewControllers addObject:self.viewController]; } else { [viewControllers addObject:[NSNull null]]; diff --git a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift index 57c41a21..1e2f5522 100644 --- a/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/New/FormHolderProtocol.swift @@ -12,6 +12,4 @@ import Foundation //Protocol for Validation public protocol FormHolderProtocol: NSObjectProtocol { var formValidator: FormValidator? { get set } - /// Should call formValidator's validate method - func validate() } diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h similarity index 61% rename from MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h index 9e486066..f152b932 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.h +++ b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.h @@ -1,5 +1,5 @@ // -// ProgrammaticScrollViewController.h +// MFProgrammaticScrollViewController.h // myverizon // // Created by Scott Pfeil on 1/26/16. @@ -8,7 +8,7 @@ #import -@interface ProgrammaticScrollViewController : MFScrollingViewController +@interface MFProgrammaticScrollViewController : MFScrollingViewController @end diff --git a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m similarity index 92% rename from MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m index 2bfeb35d..5152ec79 100644 --- a/MVMCoreUI/BaseControllers/ProgrammaticScrollViewController.m +++ b/MVMCoreUI/Legacy/Controllers/MFProgrammaticScrollViewController.m @@ -1,21 +1,21 @@ // -// ProgrammaticScrollViewController.m +// MFProgrammaticScrollViewController.m // myverizon // // Created by Scott Pfeil on 1/26/16. // Copyright © 2016 Verizon Wireless. All rights reserved. // -#import "ProgrammaticScrollViewController.h" +#import "MFProgrammaticScrollViewController.h" @import MVMCore.NSDictionary_MFConvenience; #import "NSLayoutConstraint+MFConvenience.h" #import "MVMCoreUICommonViewsUtility.h" -@interface ProgrammaticScrollViewController () +@interface MFProgrammaticScrollViewController () @end -@implementation ProgrammaticScrollViewController +@implementation MFProgrammaticScrollViewController - (void)loadView { diff --git a/MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.h b/MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.h rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.h diff --git a/MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.m b/MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.m rename to MVMCoreUI/Legacy/Controllers/MFProgrammaticTableViewController.m diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.h b/MVMCoreUI/Legacy/Controllers/MFScrollingViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFScrollingViewController.h rename to MVMCoreUI/Legacy/Controllers/MFScrollingViewController.h diff --git a/MVMCoreUI/BaseControllers/MFScrollingViewController.m b/MVMCoreUI/Legacy/Controllers/MFScrollingViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFScrollingViewController.m rename to MVMCoreUI/Legacy/Controllers/MFScrollingViewController.m diff --git a/MVMCoreUI/BaseControllers/MFViewController+Form.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController+Form.swift rename to MVMCoreUI/Legacy/Controllers/MFViewController+Form.swift diff --git a/MVMCoreUI/BaseControllers/MFViewController+Model.swift b/MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController+Model.swift rename to MVMCoreUI/Legacy/Controllers/MFViewController+Model.swift diff --git a/MVMCoreUI/BaseControllers/MFViewController.h b/MVMCoreUI/Legacy/Controllers/MFViewController.h similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController.h rename to MVMCoreUI/Legacy/Controllers/MFViewController.h diff --git a/MVMCoreUI/BaseControllers/MFViewController.m b/MVMCoreUI/Legacy/Controllers/MFViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MFViewController.m rename to MVMCoreUI/Legacy/Controllers/MFViewController.m diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h similarity index 95% rename from MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h rename to MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h index 0c702925..12d02f43 100644 --- a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.h +++ b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.h @@ -6,9 +6,9 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -#import +#import -@interface MVMCoreUIStackableViewController : ProgrammaticScrollViewController +@interface MVMCoreUIStackableViewController : MFProgrammaticScrollViewController // An array of ui elements that will be spaced out on the screen top to bottom from index 0 to formUIArray.count. @property (nullable, strong, nonatomic) NSArray *formUIArray; diff --git a/MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m b/MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.m similarity index 100% rename from MVMCoreUI/BaseControllers/MVMCoreUIStackableViewController.m rename to MVMCoreUI/Legacy/Controllers/MVMCoreUIStackableViewController.m diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 5e8c92cc..22707550 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -48,7 +48,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #pragma mark - BaseControllers #import #import -#import +#import #import #import #import diff --git a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift index 34b58818..7f50873e 100644 --- a/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/PageModelProtocol.swift @@ -13,4 +13,5 @@ public protocol PageModelProtocol { var pageType: String { get set } var screenHeading: String? { get set } var isAtomicTabs: Bool? { get set } + var navigationItem: NavigationItemModelProtocol? { get set } } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index f9b9d976..0661e3ed 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,15 +29,14 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), - let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]] + let molecules2D = (self.listItemModel as? DropDownListItemModel)?.molecules else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(molecules2D[self.previousIndex], sender: self, animation: .fade) } - self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.addMolecules(molecules2D[index], sender: self, animation: .fade) self.previousIndex = index } } diff --git a/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift new file mode 100644 index 00000000..acddb931 --- /dev/null +++ b/MVMCoreUI/Molecules/NavigationItemModelProtocol.swift @@ -0,0 +1,17 @@ +// +// NavigationItemModelProtocol.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 3/12/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public protocol NavigationItemModelProtocol: ModelProtocol { + +} + +public protocol NavigationItemButtonModelProtocol { + +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h index 003d67f8..9fec90f5 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.h @@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN @interface MVMCoreUILoggingHandler : MVMCoreLoggingHandler // Page State Logging -- (void)defaultLogPageStateForController:(nonnull MFViewController *)controller; +- (void)defaultLogPageStateForController:(nonnull id )controller; // Action Logging -- (void)defaultLogActionForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData; @end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m index 6395fbcc..0c694cce 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUILoggingHandler.m @@ -10,13 +10,13 @@ @implementation MVMCoreUILoggingHandler -- (void)defaultLogPageStateForController:(nonnull MFViewController *)controller { +- (void)defaultLogPageStateForController:(nonnull id )controller { } -- (void)defaultLogActionForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (void)defaultLogActionForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { } -- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull MFViewController *)controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { +- (nullable NSDictionary *)defaultGetActionTrackDataDictionaryForController:(nonnull id )controller actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData { return nil; } diff --git a/MVMCoreUI/Templates/ListPageTemplateModel.swift b/MVMCoreUI/Templates/ListPageTemplateModel.swift index 12c300f9..99e87809 100644 --- a/MVMCoreUI/Templates/ListPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ListPageTemplateModel.swift @@ -22,6 +22,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var molecules: [ListItemModelProtocol & MoleculeModelProtocol]? diff --git a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift index 6dae1700..303ceba1 100644 --- a/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeListTemplate.swift @@ -10,11 +10,13 @@ import UIKit open class ModalMoleculeListTemplate: MoleculeListTemplate { - override open func newDataBuildScreen() { - super.newDataBuildScreen() + override open func handleNewData() { MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in - self?.dismiss() + if let _ = self { + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } }, verticalCentered: false) + super.handleNewData() } } diff --git a/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift index 9f1ea9b9..b50400a7 100644 --- a/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/ModalMoleculeStackTemplate.swift @@ -10,10 +10,12 @@ import UIKit open class ModalMoleculeStackTemplate: MoleculeStackTemplate { - override open func newDataBuildScreen() { - super.newDataBuildScreen() + override open func handleNewData() { + super.handleNewData() MVMCoreUICommonViewsUtility.addCloseButton(to: view, action: {[weak self] _ in - self?.dismiss() + if let _ = self { + MVMCoreNavigationHandler.shared()?.removeCurrentViewController() + } }, verticalCentered: false) } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index 1ea13b4c..722e90a7 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -12,12 +12,6 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- // MARK: - Stored Properties //-------------------------------------------------- - - public var formValidator: FormValidator? - public func validate() { - // Can override - } - public var moleculesInfo: [(identifier: String, class: AnyClass, molecule: (ListItemModelProtocol & MoleculeModelProtocol))]? var observer: NSKeyValueObservation? @@ -27,13 +21,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol //-------------------------------------------------- // MARK: - Computed Properties //-------------------------------------------------- - - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + open override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { @@ -90,10 +79,10 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol return true } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { setup() registerWithTable() + super.handleNewData() } //-------------------------------------------------- @@ -109,7 +98,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - open override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { + open func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { guard let moleculeInfo = moleculesInfo?[indexPath.row], let estimatedHeight = (moleculeInfo.class as? ModelMoleculeViewProtocol.Type)?.estimatedHeight(with: moleculeInfo.molecule, delegateObject() as? MVMCoreUIDelegateObject) else { return 0 } @@ -127,47 +116,33 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol let cell = tableView.dequeueReusableCell(withIdentifier: moleculeInfo.identifier) else { return UITableViewCell() } - let delegate = delegateObject() as? MVMCoreUIDelegateObject let moleculeCell = cell as? MVMCoreUIMoleculeViewProtocol moleculeCell?.reset?() if let protocolCell = cell as? MoleculeListCellProtocol { - protocolCell.setLines(with: templateModel?.line, delegateObject: delegate, additionalData: nil, indexPath: indexPath) + protocolCell.setLines(with: templateModel?.line, delegateObject: selfDelegateObject, additionalData: nil, indexPath: indexPath) } - (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, delegate, nil) + (moleculeCell as? ModelMoleculeViewProtocol)?.set(with: moleculeInfo.molecule, selfDelegateObject, nil) moleculeCell?.updateView(tableView.bounds.width) return cell } - open override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if let protocolCell = cell as? MoleculeListCellProtocol { protocolCell.willDisplay() } } - open override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let cell = tableView.cellForRow(at: indexPath) as? MoleculeListCellProtocol { cell.didSelectCell(at: indexPath, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil) } } - //-------------------------------------------------- - // MARK: - Cache Handling - //-------------------------------------------------- - - open override func pageTypesToListenFor() -> [Any]? { - guard let pageType = self.pageType else { return super.pageTypesToListenFor() } - return [pageType] - } - - open override func modulesToListenFor() -> [Any]? { - return loadObject?.requestParameters?.modules - } - //-------------------------------------------------- // MARK: - MoleculeDelegateProtocol //-------------------------------------------------- @@ -183,7 +158,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func addMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -212,7 +187,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public override func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { + public func removeMolecules(_ molecules: [[AnyHashable: Any]], sender: UITableViewCell, animation: UITableView.RowAnimation) { var tmpMolecules = [ListItemModelProtocol & MoleculeModelProtocol]() @@ -240,7 +215,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol view.layoutIfNeeded() } - public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { // This dispatch is needed to fix a race condition that can occur if this function is called during the table setup. DispatchQueue.main.async { @@ -262,7 +237,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol } } - public func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { + open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], sender: UITableViewCell, animation: UITableView.RowAnimation) { var indexPaths: [IndexPath] = [] //TODO: cehck for molecule protocola eqality diff --git a/MVMCoreUI/Templates/MoleculeStackTemplate.swift b/MVMCoreUI/Templates/MoleculeStackTemplate.swift index 6a895120..f68cfa1a 100644 --- a/MVMCoreUI/Templates/MoleculeStackTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeStackTemplate.swift @@ -9,20 +9,11 @@ import UIKit open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { - public func validate() { - - } - - public var formValidator: FormValidator? - var observer: NSKeyValueObservation? public var templateModel: StackPageTemplateModel? - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + + open override func parsePageJSON() throws { + try parseTemplateJSON() } open override var loadObject: MVMCoreLoadObject? { @@ -73,17 +64,7 @@ open class MoleculeStackTemplate: ThreeLayerViewController, TemplateProtocol { } // MARK: - cache handling - open override func pageTypesToListenFor() -> [Any]? { - guard let pageType = self.pageType else { - return super.pageTypesToListenFor() - } - return [pageType] - } - - open override func modulesToListenFor() -> [Any]? { - return loadObject?.requestParameters?.modules - } - + /// Adds modules from requiredModules() to the MVMCoreViewControllerMapping.requiredModules map. open func updateRequiredModules() { if let requiredModules = requiredModules(), let pageType = pageType { diff --git a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift index 66cd0365..f3bde0e7 100644 --- a/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackCenteredPageTemplateModel.swift @@ -17,6 +17,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public init(pageType: String) { self.pageType = pageType diff --git a/MVMCoreUI/Templates/StackPageTemplateModel.swift b/MVMCoreUI/Templates/StackPageTemplateModel.swift index ed94e4ef..28600453 100644 --- a/MVMCoreUI/Templates/StackPageTemplateModel.swift +++ b/MVMCoreUI/Templates/StackPageTemplateModel.swift @@ -18,6 +18,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var moleculeStack: MoleculeStackModel diff --git a/MVMCoreUI/Templates/TemplateProtocol.swift b/MVMCoreUI/Templates/TemplateProtocol.swift index fcb6bde2..f4717774 100644 --- a/MVMCoreUI/Templates/TemplateProtocol.swift +++ b/MVMCoreUI/Templates/TemplateProtocol.swift @@ -14,7 +14,7 @@ public protocol TemplateProtocol: FormHolderProtocol { var templateModel: TemplateModel? { get set } } -public extension TemplateProtocol where Self: MFViewController { +public extension TemplateProtocol where Self: ViewController { func parseTemplateJSON() throws { guard let pageJSON = self.loadObject?.pageJSON else { return } let data = try JSONSerialization.data(withJSONObject: pageJSON) diff --git a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift index 5ad39c4b..fff9bdb8 100644 --- a/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift +++ b/MVMCoreUI/Templates/ThreeLayerPageTemplateModel.swift @@ -18,6 +18,7 @@ import Foundation public var pageType: String public var screenHeading: String? public var isAtomicTabs: Bool? + public var navigationItem: NavigationItemModelProtocol? public var header: MoleculeModelProtocol? public var middle: MoleculeModelProtocol? diff --git a/MVMCoreUI/Templates/ThreeLayerTemplate.swift b/MVMCoreUI/Templates/ThreeLayerTemplate.swift index 148d102d..0f400027 100644 --- a/MVMCoreUI/Templates/ThreeLayerTemplate.swift +++ b/MVMCoreUI/Templates/ThreeLayerTemplate.swift @@ -12,17 +12,10 @@ import UIKit public func validate() { } - - public var formValidator: FormValidator? - public var templateModel: ThreeLayerPageTemplateModel? - open override func parsePageJSON(_ error: NSErrorPointer) { - do { - try parseTemplateJSON() - } catch let parseError { - error?.pointee = parseError as NSError - } + open override func parsePageJSON() throws { + try parseTemplateJSON() } override open func viewDidLoad() { @@ -31,8 +24,8 @@ import UIKit // Do any additional setup after loading the view. } - open override func newDataBuildScreen() { - super.newDataBuildScreen() + open override func handleNewData() { + super.handleNewData() heightConstraint?.isActive = true }