From 320cd153921dd6b9f524380a38d72195ab1222e8 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 1 Jul 2022 15:26:09 -0400 Subject: [PATCH 01/17] Modernize actions --- MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift index f88ca5ec..01a7d0e8 100644 --- a/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift +++ b/MVMCoreUI/Legacy/Adapters/ActionModelAdapter.swift @@ -9,16 +9,7 @@ public extension Dictionary { func asActionModel() throws -> ActionModelProtocol { - guard let castedSelf = self as? [String: Any] else { - throw ModelRegistry.Error.decoderOther(message: "Dictionary is not of type [String: Any]") - } - guard let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self) else { - throw ModelRegistry.Error.decoderErrorModelNotMapped() - } - guard let actionModel = try actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else { - throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol") - } - return actionModel + return try MVMCoreActionHandler.createModel(with: self) } - + } From 16e9079b8cea0297e6fd5b164b52e4ca2bd2038e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 18 Jul 2022 18:54:11 -0400 Subject: [PATCH 02/17] Action modernization --- MVMCoreUI.xcodeproj/project.pbxproj | 32 ++++ MVMCoreUI/Alerts/MVMCoreAlertObject.m | 4 +- .../Atomic/Actions/ActionAlertHandler.swift | 26 +++ .../ActionCollapseNotificationHandler.swift | 19 ++ .../Actions/ActionOpenPanelHandler.swift | 25 +++ .../Atomic/Actions/ActionPopupHandler.swift | 31 ++++ .../Actions/ActionTopAlertHandler.swift | 31 ++++ .../ActionTopNotificationHandler.swift | 20 ++ .../MVMCoreUIActionOpenPageHandler.swift | 19 ++ .../Atomic/Atoms/Views/Label/Label.swift | 2 +- .../Items/DropDownFilterTableViewCell.swift | 24 +-- .../OtherContainers/ModuleMolecule.swift | 2 +- .../BaseControllers/ViewController.swift | 9 +- MVMCoreUI/FormUIHelpers/FormValidator.swift | 2 +- .../SubNav/SubNavManagerController.swift | 5 +- .../OtherHandlers/CoreUIModelMapping.swift | 13 +- .../MVMCoreUIActionHandler+Extension.swift | 34 ++++ .../OtherHandlers/MVMCoreUIActionHandler.h | 49 ++--- .../OtherHandlers/MVMCoreUIActionHandler.m | 174 +++++------------- .../MVMCoreUITopAlertView+Extension.swift | 6 +- 20 files changed, 337 insertions(+), 190 deletions(-) create mode 100644 MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index aac7bf51..e90dff6f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -275,6 +275,14 @@ AAE7270E24AC8B9300A3ED0E /* HeadersH2CaretLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */; }; AAE96FA225341F6A0037A989 /* ListStoreLocatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */; }; AAE96FA525341F7D0037A989 /* ListStoreLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */; }; + AF1C33652883B5A4006B1001 /* ActionTopNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */; }; + AF1C33672883B712006B1001 /* ActionPopupHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33662883B712006B1001 /* ActionPopupHandler.swift */; }; + AF1C336928859778006B1001 /* ActionAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336828859778006B1001 /* ActionAlertHandler.swift */; }; + AF1C336B28859C73006B1001 /* ActionTopAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */; }; + AF1C336D28859EE1006B1001 /* ActionOpenPanelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */; }; + AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */; }; + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */; }; + AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; @@ -865,6 +873,14 @@ AAE7270D24AC8B9300A3ED0E /* HeadersH2CaretLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadersH2CaretLink.swift; sourceTree = ""; }; AAE96FA125341F6A0037A989 /* ListStoreLocatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocatorModel.swift; sourceTree = ""; }; AAE96FA425341F7D0037A989 /* ListStoreLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListStoreLocator.swift; sourceTree = ""; }; + AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopNotificationHandler.swift; sourceTree = ""; }; + AF1C33662883B712006B1001 /* ActionPopupHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionPopupHandler.swift; sourceTree = ""; }; + AF1C336828859778006B1001 /* ActionAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionAlertHandler.swift; sourceTree = ""; }; + AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopAlertHandler.swift; sourceTree = ""; }; + AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPanelHandler.swift; sourceTree = ""; }; + AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCollapseNotificationHandler.swift; sourceTree = ""; }; + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIActionHandler+Extension.swift"; sourceTree = ""; }; + AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionOpenPageHandler.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; @@ -1475,12 +1491,19 @@ isa = PBXGroup; children = ( 94C0150924215643005811A9 /* ActionTopAlertModel.swift */, + AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */, 94C0150B2421564A005811A9 /* ActionCollapseNotificationModel.swift */, + AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */, D2C78CD124228BBD00B69FDE /* ActionOpenPanelModel.swift */, + AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */, D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */, D2ED27EA254B0CE700A1C293 /* AlertModel.swift */, + AF1C336828859778006B1001 /* ActionAlertHandler.swift */, D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */, + AF1C33662883B712006B1001 /* ActionPopupHandler.swift */, C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */, + AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */, + AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */, ); path = Actions; sourceTree = ""; @@ -2280,6 +2303,7 @@ D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */, D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */, D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */, + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */, D23A90672614B0B4007E14CE /* CoreUIModelMapping.swift */, ); path = OtherHandlers; @@ -2732,6 +2756,7 @@ AAB9C10A243496DD00151545 /* RadioSwatch.swift in Sources */, D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */, 011D9602240DA20A000E3791 /* FormRuleWatcherFieldProtocol.swift in Sources */, + AF1C33672883B712006B1001 /* ActionPopupHandler.swift in Sources */, D23A900926125FFB007E14CE /* GetContactBehavior.swift in Sources */, D264FAA1243CF66B00D98315 /* ContainerCollectionReusableView.swift in Sources */, AA617AB22453012400910B8F /* ListDeviceComplexLinkSmallModel.swift in Sources */, @@ -2796,6 +2821,7 @@ 94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift in Sources */, 943820842432382400B43AF3 /* WebView.swift in Sources */, 0103B84E23D7E33A009C315C /* HeadlineBodyToggleModel.swift in Sources */, + AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */, D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */, 0A25209624645AFD000FA9F6 /* TextViewEntryField.swift in Sources */, 014AA72623C501E2006F3E93 /* ContainerModelProtocol.swift in Sources */, @@ -2828,6 +2854,7 @@ 0A9D091D2433796500D2E6C0 /* BarsCarouselIndicatorModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */, 0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, @@ -2929,6 +2956,7 @@ D2E2A99623D8CF85000B42E6 /* HeadlineBodyLinkToggleModel.swift in Sources */, C6FA7D5323C77A4A00A3614A /* StringAndMoleculeStack.swift in Sources */, 32F8804624765C6E00C2ACB3 /* ListLeftVariableNumberedListAllTextAndLinksModel.swift in Sources */, + AF1C336B28859C73006B1001 /* ActionTopAlertHandler.swift in Sources */, 011D958524042432000E3791 /* RulesProtocol.swift in Sources */, 4457904E27ECE989002B1E1E /* UIImageRenderingMode+Extension.swift in Sources */, D23118B325124E18001C8440 /* Notification.swift in Sources */, @@ -2949,8 +2977,10 @@ 012A88B1238C880100FE3DA1 /* CarouselPagingModelProtocol.swift in Sources */, 0A9D091E2433796500D2E6C0 /* NumericCarouselIndicatorModel.swift in Sources */, D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */, + AF1C336928859778006B1001 /* ActionAlertHandler.swift in Sources */, 9445890E2385C3F800DE9FD4 /* MultiProgressModel.swift in Sources */, 011D95A5240455DC000E3791 /* FormGroupRule.swift in Sources */, + AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */, D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */, D2A6390122CBB1820052ED1F /* Carousel.swift in Sources */, C7F8012123E8303200396FBD /* ListRVWheel.swift in Sources */, @@ -3055,6 +3085,7 @@ 52B201D224081CFB00D2011E /* ListLeftVariableRadioButtonAndPaymentMethod.swift in Sources */, D26C5A6B23F4A40D007AEECE /* ListItemModel.swift in Sources */, D270E5672642F77300CDBED2 /* AddRemoveMoleculeBehavior.swift in Sources */, + AF1C33652883B5A4006B1001 /* ActionTopNotificationHandler.swift in Sources */, BB2BF0EC2452A9D5001D0FC2 /* ListDeviceComplexButtonSmallModel.swift in Sources */, 943784F6236B77BB006A1E82 /* WheelAnimationHandler.swift in Sources */, 011D95A1240453D0000E3791 /* RuleEqualsModel.swift in Sources */, @@ -3148,6 +3179,7 @@ AAB7EDEF246ADA1600E54929 /* ListProgressBarThinModel.swift in Sources */, D21B7F75243BAC8900051ABF /* CarouselItem.swift in Sources */, C695A69823C990C200BFB94E /* DoughnutChartView.swift in Sources */, + AF1C336D28859EE1006B1001 /* ActionOpenPanelHandler.swift in Sources */, 8D3BA9BD2433787000D341BA /* ListThreeColumnInternationalDataDividerModel.swift in Sources */, D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */, 011D959F240453A1000E3791 /* RuleAllValueChangedModel.swift in Sources */, diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.m b/MVMCoreUI/Alerts/MVMCoreAlertObject.m index 7c61dd08..8b1bc248 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.m @@ -151,9 +151,9 @@ + (nullable instancetype)alertObjectWithPage:(nullable NSDictionary *)page isGreedy:(BOOL)isGreedy additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject error:(MVMCoreErrorObject *_Nullable *_Nullable)error { MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; - alert.title = [page string:KeyTitle] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorTitle]; + alert.title = [page string:KeyTitle]; alert.pageJson = page; - alert.message = [page string:KeyMessage] ?: [MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess]; + alert.message = [page string:KeyMessage]; alert.isGreedy = isGreedy; alert.type = MFAlertTypePopup; alert.alertStyle = UIAlertControllerStyleAlert; diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift new file mode 100644 index 00000000..f3996ab1 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -0,0 +1,26 @@ +// +// ActionAlertHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows an alert using the model. +open class ActionAlertHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionAlertModel else { return } + let json = try MVMCoreActionHandler.convertActionToJSON(model) + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + throw MVMCoreError.errorObject(error!) + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift new file mode 100644 index 00000000..f12b2db9 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift @@ -0,0 +1,19 @@ +// +// ActionCollapseNotificationHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Collapse the current top notification. +open class ActionCollapseNotificationHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + CoreUIObject.sharedInstance()?.globalTopAlertDelegate?.getTopAlertView?().collapseNotification?() + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift new file mode 100644 index 00000000..5493f128 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift @@ -0,0 +1,25 @@ +// +// ActionOpenPanelHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows the panel. +open class ActionOpenPanelHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionOpenPanelModel else { return } + switch model.panel { + case .left, .menu: + await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) + case .right, .support: + await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift new file mode 100644 index 00000000..d0efc18e --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift @@ -0,0 +1,31 @@ +// +// ActionPopupHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/16/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows a popup alert by grabbing the content from a Page in the cache using the pageType. +open class ActionPopupHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionPopupModel else { return } + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject(page: json, isGreedy: false, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + continuation.resume(throwing: MVMCoreError.errorObject(error!)) + return + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + continuation.resume() + }) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift new file mode 100644 index 00000000..83a58273 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -0,0 +1,31 @@ +// +// ActionTopAlertHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Creates and shows an alert using the ResponseInfo of a Page found in the cache. +open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionTopAlertModel else { return } + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in + guard let responseInfo = json?.optionalDictionaryForKey(KeyResponseInfo) else { + continuation.resume(throwing: ModelRegistry.Error.decoderOther(message: "Alert Page \(model.pageType) missing ResponseInfo")) + return + } + let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)! + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + continuation.resume() + }) + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift new file mode 100644 index 00000000..89762268 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift @@ -0,0 +1,20 @@ +// +// ActionTopNotificationHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/16/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Shows a top notification/alert with the model. +open class ActionTopNotificationHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionTopNotificationModel else { return } + await MVMCoreUITopAlertView.sharedGlobal()?.showTopAlert(with: model.topNotification) + } +} diff --git a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift new file mode 100644 index 00000000..550badf5 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift @@ -0,0 +1,19 @@ +// +// MVMCoreUIActionOpenPageHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +open class MVMCoreUIActionOpenPageHandler: ActionOpenPageHandler { + public override func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). + var additionalData = additionalData + additionalData?.removeValue(forKey: KeySourceModel) + try await super.performAction(model, delegateObject: delegateObject, additionalData: additionalData) + } +} diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index c524b7b3..7641b8f6 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -227,7 +227,7 @@ public typealias ActionBlock = () -> () documentAttributes: nil) } catch { if let coreErrorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "LabelHTMLParse") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: coreErrorObject) + MVMCoreUILoggingHandler.addError(toLog: coreErrorObject) } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index b6de93d1..d157bce1 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -24,18 +24,20 @@ import UIKit addMolecule(dropDown) dropDown.observeDropdownChange = { [weak self] oldValue, newValue in - guard newValue != oldValue, - let self = self, - let model = self.listItemModel as? DropDownListItemModel - else { return } - MVMCoreDispatchUtility.performBlock(inBackground: { - if let oldValue = oldValue, - oldValue.count > 0 { - MVMCoreActionHandler.shared()?.syncHandleAction(with: RemoveMoleculesActionModel(.fade), additionalData: [KeySourceModel: model], delegateObject: self.delegateObject) - } - MVMCoreActionHandler.shared()?.syncHandleAction(with: AddMoleculesActionModel(.fade), additionalData: [KeySourceModel: model], delegateObject: self.delegateObject) - }) + let self = self, + let model = self.listItemModel as? DropDownListItemModel else { return } + + let additionData = [KeySourceModel: model] + var actions: [ActionModelProtocol] = [] + if let oldValue = oldValue, + oldValue.count > 0 { + actions.append(RemoveMoleculesActionModel(.fade)) + } + actions.append(AddMoleculesActionModel(.fade)) + let actionsModel = ActionActionsModel(actions: actions) + actionsModel.concurrent = false + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift b/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift index ce76d379..6083ac5e 100644 --- a/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift +++ b/MVMCoreUI/Atomic/Molecules/OtherContainers/ModuleMolecule.swift @@ -75,7 +75,7 @@ open class ModuleMolecule: Container { let _ = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else { if let errorObject = MVMCoreErrorObject(title: nil, message: MVMCoreGetterUtility.hardcodedString(withKey: HardcodedErrorUnableToProcess), code: CoreUIErrorCode.ErrorCodeModuleMolecule.rawValue, domain: ErrorDomainNative, location: String(describing: self)) { error?.pointee = errorObject - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 772742b4..be917ab2 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import MVMCore @objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { @@ -401,6 +402,10 @@ import UIKit //-------------------------------------------------- // MARK: - MVMCoreActionDelegateProtocol //-------------------------------------------------- + open func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionData: [AnyHashable : Any]? = nil) throws -> MVMCoreRequestParameters { + let json = try MVMCoreActionHandler.convertActionToJSON(model) + return MVMCoreRequestParameters(actionMap: json)! + } open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { addFormParams(requestParameters: requestParameters, actionInformation: actionInformation, additionalData: additionalData) @@ -412,7 +417,7 @@ import UIKit pageForwardedData.merge(dataMap) { current, _ in current } } - MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) + //MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { @@ -429,7 +434,7 @@ import UIKit } if !handled { - MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) + //MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) } } diff --git a/MVMCoreUI/FormUIHelpers/FormValidator.swift b/MVMCoreUI/FormUIHelpers/FormValidator.swift index bf2f8c2f..64e3843c 100644 --- a/MVMCoreUI/FormUIHelpers/FormValidator.swift +++ b/MVMCoreUI/FormUIHelpers/FormValidator.swift @@ -95,7 +95,7 @@ import MVMCore groupValid = try validateGroup(group) } catch { if let err = MVMCoreErrorObject.createErrorObject(for: error, location: "FormValidator"){ - MVMCoreLoggingHandler.shared()?.addError(toLog: err) + MVMCoreLoggingHandler.addError(toLog: err) fatalError(err.description) } } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index f5c4023a..8f8ced86 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -154,9 +154,8 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Logs the action for the selected tab. open func trackSelectTab() { - guard let action = tabs.tabsModel?.tabs[tabs.selectedIndex].action, - let json = MVMCoreUIActionHandler.shared()?.convertActionToJSON(action, delegateObject: delegateObjectIVar) else { return } - MVMCoreUIActionHandler.shared()?.logAction(json, additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) + guard let action = tabs.tabsModel?.tabs[tabs.selectedIndex].action else { return } + MVMCoreUIActionHandler.shared()?.logAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) } /// Allow override of additioonal data for tab press action diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index ef051b88..04d10423 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -228,12 +228,13 @@ open class CoreUIModelMapping: ModelMapping { open override class func registerActions() { super.registerActions() - ModelRegistry.register(ActionPopupModel.self) - ModelRegistry.register(ActionAlertModel.self) - ModelRegistry.register(ActionTopAlertModel.self) - ModelRegistry.register(ActionCollapseNotificationModel.self) - ModelRegistry.register(ActionOpenPanelModel.self) - ModelRegistry.register(ActionTopNotificationModel.self) + ModelRegistry.register(handler: ActionPopupHandler.self, for: ActionPopupModel.self) + ModelRegistry.register(handler: ActionAlertHandler.self, for: ActionAlertModel.self) + ModelRegistry.register(handler: ActionTopAlertHandler.self, for: ActionTopAlertModel.self) + ModelRegistry.register(handler: ActionCollapseNotificationHandler.self, for: ActionCollapseNotificationModel.self) + ModelRegistry.register(handler: ActionOpenPanelHandler.self, for: ActionOpenPanelModel.self) + ModelRegistry.register(handler: ActionTopNotificationHandler.self, for: ActionTopNotificationModel.self) + ModelRegistry.register(handler: MVMCoreUIActionOpenPageHandler.self, for: ActionOpenPageModel.self, allowsReplace: true) } open class func registerRules() { diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift new file mode 100644 index 00000000..00682f88 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift @@ -0,0 +1,34 @@ +// +// MVMCoreUIActionHandler+Extension.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/18/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore +import SafariServices + +@objc open class MVMCoreUIActionHandler: MVMCoreActionHandler { + + /// Logs the error and shows a popup if the error is not silent. + open override func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable : Any]?) { + super.defaultHandleActionError(error, additionalData: additionalData) + guard !error.silentError else { return } + Task { + // TODO: Verify if necessary. + await MainActor.run { + // Show alert + let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)! + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } + } + } + + @objc(openURLInSafariWebView:) + @MainActor open func openURL(inSafariWebView url: URL) { + let safariViewController = SFSafariViewController(url: url) + MVMCoreNavigationHandler.shared()?.present(safariViewController, animated: true) + } +} diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h index 60a24646..b78088bc 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -1,35 +1,20 @@ +//// +//// MVMCoreUIActionHandler.h +//// MVMCoreUI +//// +//// Created by Scott Pfeil on 10/28/20. +//// Copyright © 2020 Verizon Wireless. All rights reserved. +//// // -// MVMCoreUIActionHandler.h -// MVMCoreUI +//@import MVMCore.MVMCoreActionHandler; // -// Created by Scott Pfeil on 10/28/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. +//NS_ASSUME_NONNULL_BEGIN // - -@import MVMCore.MVMCoreActionHandler; - -NS_ASSUME_NONNULL_BEGIN - -@interface MVMCoreUIActionHandler : MVMCoreActionHandler - -// Shows a popup alert by grabbing the content from the page map. -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows popup alert from the alert object in the action map. The actionType of the action is 'alert' -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows a top alert -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Collapses the current top notification -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -// Shows a topnotification new molecular -- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject; - -/// Legacy in app safari webview load -- (void)openURLInSafariWebView:(nonnull NSURL *)url; - -@end - -NS_ASSUME_NONNULL_END +//@interface MVMCoreUIActionHandler : MVMCoreActionHandler +// +///// Legacy in app safari webview load +//- (void)openURLInSafariWebView:(nonnull NSURL *)url; +// +//@end +// +//NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m index 9425547c..8f01a766 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -1,131 +1,49 @@ +//// +//// MVMCoreUIActionHandler.m +//// MVMCoreUI +//// +//// Created by Scott Pfeil on 10/28/20. +//// Copyright © 2020 Verizon Wireless. All rights reserved. +//// // -// MVMCoreUIActionHandler.m -// MVMCoreUI +//#import "MVMCoreUIActionHandler.h" +//#import "MVMCoreUIConstants.h" +//#import "MVMCoreAlertObject.h" +//#import +//#import +//@import MVMCore.MVMCoreActionHandler; +//@import MVMCore.NSDictionary_MFConvenience; +//@import MVMCore.MVMCoreJSONConstants; +//@import MVMCore.MVMCoreCache; +//@import SafariServices; // -// Created by Scott Pfeil on 10/28/20. -// Copyright © 2020 Verizon Wireless. All rights reserved. +//@implementation MVMCoreUIActionHandler // - -#import "MVMCoreUIActionHandler.h" -#import "MVMCoreUIConstants.h" -#import "MVMCoreAlertObject.h" -#import -#import -@import MVMCore.MVMCoreActionHandler; -@import MVMCore.NSDictionary_MFConvenience; -@import MVMCore.MVMCoreJSONConstants; -@import MVMCore.MVMCoreCache; -@import SafariServices; - -@implementation MVMCoreUIActionHandler - -- (BOOL)handleOtherActions:(NSString *)actionType actionInformation:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { - if ([actionType isEqualToString:KeyActionTypePopup]) { - [self popupAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { - [self topAlertAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { - [self collapseNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeAlert]) { - [self showAlert:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } else if ([actionType isEqualToString:KeyActionTypeTopNotification]) { - [self topNotificationAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; - return YES; - } - return [super handleOtherActions:actionType actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; -} - -- (void)openPageAction:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { - // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). - if (additionalData[KeySourceModel]) { - NSMutableDictionary *cleanedData = [additionalData mutableCopy]; - [cleanedData removeObjectForKey:KeySourceModel]; - additionalData = cleanedData; - } - [super openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; -} - -- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a popup. - NSString *pageTypeForPopup = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForPopup queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithPage:jsonDictionary isGreedy:NO additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowPopupWithAlertObject:alertObject alertJson:jsonDictionary]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject ]; - } - }]; -} - -- (void)showAlert:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - - MVMCoreErrorObject *error = nil; - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectWithAction:actionInformation additionalData:additionalData delegateObject:delegateObject error:&error]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowPopupWithAlertObject:alertObject alertJson:actionInformation]; - } - - if (alertObject) { - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - } else { - [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegateObject:delegateObject]; - } -} - -- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Perform a top alert. - NSString *pageTypeForTopAlert = [actionInformation stringForKey:KeyPageType]; - [[MVMCoreCache sharedCache] fetchJSONForPageType:pageTypeForTopAlert queue:nil waitUntilFinished:YES completionHandler:^(NSDictionary * _Nullable jsonDictionary) { - - NSDictionary *responseInfo = [jsonDictionary dict:KeyResponseInfo]; - if (responseInfo) { - MVMCoreAlertObject *alertObject = [MVMCoreAlertObject alertObjectForPageType:pageTypeForTopAlert responseInfo:responseInfo additionalData:additionalData delegateObject:delegateObject]; - if ([delegateObject.actionDelegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { - [((id )delegateObject.actionDelegate) willShowTopAlertWithAlertObject:alertObject alertJson:actionInformation]; - } - [alertObject showAlert]; - } - }]; -} - -- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - // Collapse the current notification. - if ([[CoreUIObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - [[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification]; - } -} - -- (void)topNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { - //Handle molecular topnotification - [[MVMCoreUITopAlertView sharedGlobal] showTopAlertWith:[actionInformation dict:@"topNotification"] ?: @{}]; -} - -- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { - [super defaultHandleActionError:error additionalData:additionalData]; - if (!error.silentError) { - - // Show alert - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; - [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; - }]; - } -} - -- (void)openURLInSafariWebView:(nonnull NSURL *)url { - SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; - [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; -} - -@end +//- (void)openPageAction:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { +// // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). +// if (additionalData[KeySourceModel]) { +// NSMutableDictionary *cleanedData = [additionalData mutableCopy]; +// [cleanedData removeObjectForKey:KeySourceModel]; +// additionalData = cleanedData; +// } +// //[super openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; +//} +// +//- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { +// [super defaultHandleActionError:error additionalData:additionalData]; +// if (!error.silentError) { +// +// // Show alert +// [MVMCoreDispatchUtility performBlockOnMainThread:^{ +// MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; +// [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; +// }]; +// } +//} +// +//- (void)openURLInSafariWebView:(nonnull NSURL *)url { +// SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; +// [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; +//} +// +//@end diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 46765385..d7747383 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -47,7 +47,7 @@ public extension MVMCoreUITopAlertView { return try TopNotificationModel.decode(json: json, delegateObject: delegateObject) } catch { if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "\(self)") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil } @@ -96,7 +96,7 @@ public extension MVMCoreUITopAlertView { let molecule = currentAlert as? MoleculeViewProtocol else { // Log that we couldn't update. if let errorObject = MVMCoreErrorObject(title: nil, message: nil, messageToLog: nil, code: ErrorCode.parsingJSON.rawValue, domain: ErrorDomainNative, location: "TopNotification update \(String(describing: topAlertObject.type))") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return } @@ -132,7 +132,7 @@ public extension MVMCoreUITopAlertView { return molecule } catch { if let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: "\(self)") { - MVMCoreUILoggingHandler.shared()?.addError(toLog: errorObject) + MVMCoreUILoggingHandler.addError(toLog: errorObject) } return nil } From 768aa578d230cacc462adb792f3f548be258edf5 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 19 Jul 2022 14:33:34 -0400 Subject: [PATCH 03/17] More Migrations. Delegate subclass --- MVMCoreUI.xcodeproj/project.pbxproj | 16 ++---- .../BaseDropdownEntryField.swift | 2 +- .../Atomic/Atoms/Selectors/Checkbox.swift | 2 +- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 +- .../Atomic/Atoms/Views/Label/Label.swift | 2 +- .../HorizontalCombinationViews/Tabs.swift | 2 +- .../AccordionMoleculeTableViewCell.swift | 6 +-- .../Molecules/Items/TabsTableViewCell.swift | 6 +-- .../Templates/ModalMoleculeListTemplate.swift | 2 +- .../ModalMoleculeStackTemplate.swift | 2 +- .../Templates/ModalSectionListTemplate.swift | 2 +- .../BaseControllers/ViewController.swift | 26 ++++------ .../Behaviors/AddRemoveMoleculeBehavior.swift | 28 +++++------ .../Protocols/PageBehaviorProtocol.swift | 5 +- .../SubNav/SubNavManagerController.swift | 21 ++++---- .../OtherHandlers/MVMCoreUIActionHandler.h | 20 -------- .../OtherHandlers/MVMCoreUIActionHandler.m | 49 ------------------- ...ion.swift => MVMCoreUIActionHandler.swift} | 2 +- 18 files changed, 55 insertions(+), 142 deletions(-) delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h delete mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m rename MVMCoreUI/OtherHandlers/{MVMCoreUIActionHandler+Extension.swift => MVMCoreUIActionHandler.swift} (96%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index a0e87b6f..cc0ba543 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -283,7 +283,7 @@ AF1C336B28859C73006B1001 /* ActionTopAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */; }; AF1C336D28859EE1006B1001 /* ActionOpenPanelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */; }; AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */; }; - AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */; }; + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler.swift */; }; AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; @@ -575,8 +575,6 @@ D2ED2812254B0EB800A1C293 /* MVMCoreTopAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED280B254B0EB800A1C293 /* MVMCoreTopAlertObject.m */; }; D2ED2815254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2814254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED2818254B115400A1C293 /* MVMCoreUIActionDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D2ED281D254B119D00A1C293 /* MVMCoreUIActionHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D2ED281E254B119D00A1C293 /* MVMCoreUIActionHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */; }; D2FA83D22513EA6900564112 /* NotificationXButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FA83D12513EA6900564112 /* NotificationXButton.swift */; }; D2FA83D42514F80C00564112 /* CollapsableNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FA83D32514F80C00564112 /* CollapsableNotification.swift */; }; D2FA83D62515021F00564112 /* CollapsableNotificationTopView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FA83D52515021F00564112 /* CollapsableNotificationTopView.swift */; }; @@ -883,7 +881,7 @@ AF1C336A28859C73006B1001 /* ActionTopAlertHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionTopAlertHandler.swift; sourceTree = ""; }; AF1C336C28859EE1006B1001 /* ActionOpenPanelHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPanelHandler.swift; sourceTree = ""; }; AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCollapseNotificationHandler.swift; sourceTree = ""; }; - AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIActionHandler+Extension.swift"; sourceTree = ""; }; + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionHandler.swift; sourceTree = ""; }; AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionOpenPageHandler.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; @@ -1176,8 +1174,6 @@ D2ED280B254B0EB800A1C293 /* MVMCoreTopAlertObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreTopAlertObject.m; sourceTree = ""; }; D2ED2814254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGlobalTopAlertDelegateProtocol.h; sourceTree = ""; }; D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIActionDelegateProtocol.h; sourceTree = ""; }; - D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIActionHandler.h; sourceTree = ""; }; - D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIActionHandler.m; sourceTree = ""; }; D2FA83D12513EA6900564112 /* NotificationXButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationXButton.swift; sourceTree = ""; }; D2FA83D32514F80C00564112 /* CollapsableNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsableNotification.swift; sourceTree = ""; }; D2FA83D52515021F00564112 /* CollapsableNotificationTopView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollapsableNotificationTopView.swift; sourceTree = ""; }; @@ -2306,9 +2302,7 @@ D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */, - D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */, - D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */, - AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift */, + AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler.swift */, D23A90672614B0B4007E14CE /* CoreUIModelMapping.swift */, ); path = OtherHandlers; @@ -2575,7 +2569,6 @@ D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */, D29DF12921E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h in Headers */, - D2ED281D254B119D00A1C293 /* MVMCoreUIActionHandler.h in Headers */, D29DF12C21E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2860,7 +2853,7 @@ 0A9D091D2433796500D2E6C0 /* BarsCarouselIndicatorModel.swift in Sources */, DBEFFA04225A829700230692 /* Label.swift in Sources */, D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */, - AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler+Extension.swift in Sources */, + AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler.swift in Sources */, 0A7ECC5D243CE85300C828E8 /* DoughnutChartItemModel.swift in Sources */, 0A7EF85F23D8ABC500B2AAD1 /* MdnEntryFieldModel.swift in Sources */, 011D959B240451E3000E3791 /* RuleRequiredModel.swift in Sources */, @@ -3015,7 +3008,6 @@ BB2FB3BD247E7EF200DF73CD /* Tags.swift in Sources */, AA104ADC244734EA004D2810 /* HeadersH1LandingPageHeaderModel.swift in Sources */, BBAA4F03243D8E3B005AAD5F /* RadioBoxes.swift in Sources */, - D2ED281E254B119D00A1C293 /* MVMCoreUIActionHandler.m in Sources */, 323AC96A24C837F000F8E4C4 /* ListThreeColumnBillChangesModel.swift in Sources */, D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */, 525019E72406853600EED91C /* ListFourColumnDataUsageDivider.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index 6e8be5f1..037cf2ef 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -100,6 +100,6 @@ import UIKit else { return } let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index 4bd64c7c..01ef9b04 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -391,7 +391,7 @@ import MVMCore private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { var additionalDataToUpdate = additionalData ?? [:] additionalDataToUpdate[KeySourceModel] = checkboxModel - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 04c34da2..b8ad4577 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -396,11 +396,11 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let self = self else { return } if self.isOn { if let action = model.action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } else { if let action = model.alternateAction ?? model.action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 91bf44b8..d18d62e0 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -387,7 +387,7 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) } addActionAttributes(range: range, string: attributedString) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 4e424549..653566b7 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -256,7 +256,7 @@ extension Tabs: UICollectionViewDelegateFlowLayout { if let delegate = delegate { delegate.didSelectItem(indexPath, tabs: self) } else if let action = tabsModel.tabs[selectedIndex].action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift index 6975f8cb..ff87ef2b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -46,9 +46,9 @@ model.selected = accordionButton.isSelected if accordionButton.isSelected { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } else { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { @@ -56,7 +56,7 @@ } if let actionModel = accordionButton.isSelected ? accordionListItemModel?.expandAction : accordionListItemModel?.collapseAction { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index d3b91b11..0fc353e4 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -57,7 +57,7 @@ extension TabsTableViewCell: TabsDelegate { public func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool { guard indexPath.row != tabs.selectedIndex else { return false } if let model = tabsListItemModel { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } previousTabIndex = tabs.selectedIndex return true @@ -68,9 +68,9 @@ extension TabsTableViewCell: TabsDelegate { guard let model = tabsListItemModel, index < model.molecules.count else { return } if let action = model.tabs.tabs[index].action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) } - MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift index 71c23c16..f14ebcd8 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift @@ -32,7 +32,7 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalListPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift index 1c76b467..9f050f3f 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift @@ -28,7 +28,7 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift index 3e4f3fc2..7ff515f8 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift @@ -27,7 +27,7 @@ open class ModalSectionListTemplate: SectionListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index c40548b3..9ba0971a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore -@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { //-------------------------------------------------- // MARK: - Properties @@ -418,7 +418,7 @@ import MVMCore } /// Override this method to avoid adding form params. - open func addFormParams(requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { + open func addFormParams(requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, additionalData: [AnyHashable: Any]?) { formValidator?.addFormParams(requestParameters: requestParameters, model: additionalData?[KeySourceModel] as? MoleculeModelProtocol & FormItemProtocol) } @@ -439,13 +439,10 @@ import MVMCore //-------------------------------------------------- // MARK: - MVMCoreActionDelegateProtocol //-------------------------------------------------- - open func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionData: [AnyHashable : Any]? = nil) throws -> MVMCoreRequestParameters { + open func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable : Any]? = nil) throws -> (MVMCoreRequestParameters,[AnyHashable : Any]?) { let json = try MVMCoreActionHandler.convertActionToJSON(model) - return MVMCoreRequestParameters(actionMap: json)! - } - - open func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { - addFormParams(requestParameters: requestParameters, actionInformation: actionInformation, additionalData: additionalData) + let requestParameters = MVMCoreRequestParameters(actionMap: json)! + addFormParams(requestParameters: requestParameters, model: model, additionalData: additionalData) requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") var pageForwardedData = additionalData ?? [:] @@ -453,26 +450,21 @@ import MVMCore let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) pageForwardedData.merge(dataMap) { current, _ in current } } - - //MVMCoreActionHandler.defaultHandleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: pageForwardedData, delegateObject: delegateObject()) + return (requestParameters,pageForwardedData) } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: self, actionInformation: actionInformation, additionalData: additionalData) } - open func handleUnknownActionType(_ actionType: String?, actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { + public func handlesUnknownAction(for model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> Bool { var handled = false - executeBehaviors { (behavior: PageCustomActionHandlerBehavior) in if !handled { - handled = behavior.handleAction(type: actionType, information: actionInformation, additionalData: additionalData) + handled = behavior.handleAction(with: model, additionalData: additionalData) } } - - if !handled { - //MVMCoreUIActionHandler.defaultHandleUnknownActionType(actionType, actionInformation: actionInformation, additionalData: additionalData, delegateObject: delegateObjectIVar) - } + return handled } //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index a3be96f5..acd3527a 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -85,24 +85,24 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo } } - public func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool { - if actionType == AddMoleculesActionModel.identifier { - guard let list = delegate?.moleculeListDelegate, - let model = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), - let moleculesToAdd = model.getRecursiveMoleculesToAdd(), - let indexPath = list.getAdjustedIndexPath(for: model, position: moleculesToAdd.1), - let animation = information?["animation"] as? Int else { return true } + public func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool { + if model.actionType == AddMoleculesActionModel.identifier { + guard let model = model as? AddMoleculesActionModel, + let list = delegate?.moleculeListDelegate, + let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), + let moleculesToAdd = sourceModel.getRecursiveMoleculesToAdd(), + let indexPath = list.getAdjustedIndexPath(for: sourceModel, position: moleculesToAdd.1) else { return true } DispatchQueue.main.async { - list.addMolecules(moleculesToAdd.0, indexPath: indexPath, animation: UITableView.RowAnimation(rawValue: animation)) + list.addMolecules(moleculesToAdd.0, indexPath: indexPath, animation: model.animation) } return true - } else if actionType == RemoveMoleculesActionModel.identifier { - guard let list = delegate?.moleculeListDelegate, - let model = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & RemoveMolecules), - let moleculesToRemove = model.getRecursiveMoleculesToRemove(), - let animation = information?["animation"] as? Int else { return true } + } else if model.actionType == RemoveMoleculesActionModel.identifier { + guard let model = model as? RemoveMoleculesActionModel, + let list = delegate?.moleculeListDelegate, + let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & RemoveMolecules), + let moleculesToRemove = sourceModel.getRecursiveMoleculesToRemove() else { return true } DispatchQueue.main.async { - list.removeMolecules(moleculesToRemove, animation: UITableView.RowAnimation(rawValue: animation)) + list.removeMolecules(moleculesToRemove, animation: model.animation) } return true } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 453041c2..0245fd7c 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -67,11 +67,10 @@ public protocol PageLocalDataShareBehavior: PageBehaviorProtocol { public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol { /// - Parameters: - /// - actionType: The action type of the passed action model. - /// - information: information of the passed action model. + /// - model: The action model. /// - additionalData: Additional information of the /// - Returns: Boolean determines if the action has been handled. - func handleAction(type actionType: String?, information: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> Bool + func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool } public extension MVMCoreUIDelegateObject { diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 8f8ced86..042f3235 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -164,26 +164,25 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } /// Allows modification of requestParameters object for openPage request - open func getRequestParametersForNewTabLoad(requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) -> MVMCoreRequestParameters { + open func getRequestParametersForNewTabLoad(requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, additionalData: [AnyHashable : Any]?) -> MVMCoreRequestParameters { requestParameters.navigationController = subNavigationController requestParameters.loadStyle = .replaceCurrent requestParameters.tabWasPressed = true return requestParameters } - open override func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) { - var requestParameters = requestParameters + open override func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable : Any]? = nil) throws -> (MVMCoreRequestParameters, [AnyHashable : Any]?) { + let value = try super.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) + var requestParameters = value.0 + let additionalData = value.1 guard let additionalData = additionalData, additionalData.boolForKey("tabBarPressed") else { // Pass to delegate - if (viewController as? MVMCoreActionDelegateProtocol)?.handleOpenPage?(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData) == nil { - super.handleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData) - } - return - } + return try (viewController as? ActionDelegateProtocol)?.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) ?? value + } // Allow opportunity to modify parameters. - requestParameters = getRequestParametersForNewTabLoad(requestParameters: requestParameters, actionInformation: actionInformation, additionalData: additionalData) - super.handleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData) + requestParameters = getRequestParametersForNewTabLoad(requestParameters: requestParameters, model: model, additionalData: additionalData) + return (requestParameters, additionalData) } // MARK: - MVMCorePresentationDelegateProtocol @@ -278,7 +277,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { // Perform the tab action - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) + _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) } return false } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h deleted file mode 100644 index b78088bc..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h +++ /dev/null @@ -1,20 +0,0 @@ -//// -//// MVMCoreUIActionHandler.h -//// MVMCoreUI -//// -//// Created by Scott Pfeil on 10/28/20. -//// Copyright © 2020 Verizon Wireless. All rights reserved. -//// -// -//@import MVMCore.MVMCoreActionHandler; -// -//NS_ASSUME_NONNULL_BEGIN -// -//@interface MVMCoreUIActionHandler : MVMCoreActionHandler -// -///// Legacy in app safari webview load -//- (void)openURLInSafariWebView:(nonnull NSURL *)url; -// -//@end -// -//NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m deleted file mode 100644 index 8f01a766..00000000 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m +++ /dev/null @@ -1,49 +0,0 @@ -//// -//// MVMCoreUIActionHandler.m -//// MVMCoreUI -//// -//// Created by Scott Pfeil on 10/28/20. -//// Copyright © 2020 Verizon Wireless. All rights reserved. -//// -// -//#import "MVMCoreUIActionHandler.h" -//#import "MVMCoreUIConstants.h" -//#import "MVMCoreAlertObject.h" -//#import -//#import -//@import MVMCore.MVMCoreActionHandler; -//@import MVMCore.NSDictionary_MFConvenience; -//@import MVMCore.MVMCoreJSONConstants; -//@import MVMCore.MVMCoreCache; -//@import SafariServices; -// -//@implementation MVMCoreUIActionHandler -// -//- (void)openPageAction:(NSDictionary *)actionInformation additionalData:(NSDictionary *)additionalData delegateObject:(DelegateObject *)delegateObject { -// // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). -// if (additionalData[KeySourceModel]) { -// NSMutableDictionary *cleanedData = [additionalData mutableCopy]; -// [cleanedData removeObjectForKey:KeySourceModel]; -// additionalData = cleanedData; -// } -// //[super openPageAction:actionInformation additionalData:additionalData delegateObject:delegateObject]; -//} -// -//- (void)defaultHandleActionError:(nonnull MVMCoreErrorObject *)error additionalData:(nullable NSDictionary *)additionalData { -// [super defaultHandleActionError:error additionalData:additionalData]; -// if (!error.silentError) { -// -// // Show alert -// [MVMCoreDispatchUtility performBlockOnMainThread:^{ -// MVMCoreAlertObject *alertObject = [[MVMCoreAlertObject alloc] initPopupAlertWithError:error isGreedy:NO]; -// [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; -// }]; -// } -//} -// -//- (void)openURLInSafariWebView:(nonnull NSURL *)url { -// SFSafariViewController *safariViewController = [[SFSafariViewController alloc] initWithURL:url]; -// [[MVMCoreNavigationHandler sharedNavigationHandler] presentViewController:safariViewController animated:YES]; -//} -// -//@end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift similarity index 96% rename from MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift rename to MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift index 00682f88..852b041a 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler+Extension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift @@ -1,5 +1,5 @@ // -// MVMCoreUIActionHandler+Extension.swift +// MVMCoreUIActionHandler.swift // MVMCoreUI // // Created by Scott Pfeil on 7/18/22. From 9ea9894e800b9ded2ae744cd67add6e6b48a29fb Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 21 Jul 2022 12:39:44 -0400 Subject: [PATCH 04/17] Modernization migrations and json passing --- MVMCoreUI/Alerts/MVMCoreAlertObject.m | 3 +-- MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift | 13 +++++++------ .../Atomic/Actions/ActionOpenPanelHandler.swift | 14 +++++++++----- .../Atomic/Actions/ActionTopAlertHandler.swift | 2 +- MVMCoreUI/MVMCoreUI.h | 1 - MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m | 3 +-- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 1 - 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.m b/MVMCoreUI/Alerts/MVMCoreAlertObject.m index 4dfa560c..b99a5870 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.m @@ -17,7 +17,6 @@ @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreHardcodedStringsConstants; @import MVMCore.MVMCoreJSONConstants; -@import MVMCore.MVMCoreActionHandler; @import MVMCore.Swift; #import @@ -162,7 +161,7 @@ NSMutableArray *actionsForAlert = [NSMutableArray array]; for (NSDictionary *actionMap in actions) { [actionsForAlert addObject:[UIAlertAction actionWithTitle:[actionMap stringForKey:KeyTitle] style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject]; + [[MVMCoreUIActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:delegateObject]; }]]; } alert.actions = actionsForAlert; diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift index f3996ab1..aa3ccc67 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -15,12 +15,13 @@ open class ActionAlertHandler: MVMCoreActionHandlerProtocol { open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionAlertModel else { return } - let json = try MVMCoreActionHandler.convertActionToJSON(model) - var error: MVMCoreErrorObject? = nil - guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { - throw MVMCoreError.errorObject(error!) + try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + throw MVMCoreError.errorObject(error!) + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json) + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) } - (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json) - MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) } } diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift index 5493f128..87060a4b 100644 --- a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift @@ -15,11 +15,15 @@ open class ActionOpenPanelHandler: MVMCoreActionHandlerProtocol { open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionOpenPanelModel else { return } - switch model.panel { - case .left, .menu: - await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) - case .right, .support: - await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) + try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in + switch model.panel { + case .left, .menu: + await MVMCoreUISplitViewController.main()?.leftPanel?.willOpen?(withActionInformation: json, additionalData: additionalData) + await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) + case .right, .support: + await MVMCoreUISplitViewController.main()?.rightPanel?.willOpen?(withActionInformation: json, additionalData: additionalData) + await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) + } } } } diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift index 83a58273..54302237 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -22,7 +22,7 @@ open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { return } let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)! - (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowTopAlert(with: alertObject, alertJson: json!) MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) continuation.resume() }) diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index ce663709..37083fd0 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -21,7 +21,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import -#import // Alert Handling #import diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m index 174b1bfb..19570ca2 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m @@ -7,7 +7,6 @@ // #import "MVMCoreUITopAlertBaseView.h" -@import MVMCore.MVMCoreActionHandler; #import "MVMCoreUISplitViewController.h" @import MVMCore.MVMCoreLoadObject; @import MVMCore.MVMCoreRequestParameters; @@ -33,7 +32,7 @@ } if (performAction) { - [[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]]; + [[MVMCoreUIActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:additionalData delegateObject:[MVMCoreUIDelegateObject createWithDelegateForAll:[MVMCoreUISession sharedGlobal].topAlertView]]; } }]; } diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index c0835541..108d7a84 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -22,7 +22,6 @@ @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreBlockOperation; #import -@import MVMCore.MVMCoreActionHandler; #import @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreRequestParameters; From 6c08179b2ab7a207ec3074fec94e2adf7b3eed45 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 22 Jul 2022 15:17:46 -0400 Subject: [PATCH 05/17] ActionHandler to Swift --- MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift index 54302237..db37c3b1 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -23,7 +23,7 @@ open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { } let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)! (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowTopAlert(with: alertObject, alertJson: json!) - MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + alertObject.showAlert() continuation.resume() }) } From f2d5352cc3baf29fb27365af0c97a4eafc67e140 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Jul 2022 18:25:56 -0400 Subject: [PATCH 06/17] modernization. Adding json protocol to continue to support legacy (unfortunately) --- .../Atomic/Actions/ActionAlertHandler.swift | 22 +++++++++------- .../Atomic/Actions/ActionAlertModel.swift | 2 +- .../ActionCollapseNotificationModel.swift | 3 ++- .../Actions/ActionOpenPanelHandler.swift | 26 +++++++++++-------- .../Atomic/Actions/ActionOpenPanelModel.swift | 3 ++- .../Atomic/Actions/ActionPopupHandler.swift | 8 ++++-- .../Atomic/Actions/ActionPopupModel.swift | 3 ++- .../Actions/ActionTopAlertHandler.swift | 10 ++++--- .../Atomic/Actions/ActionTopAlertModel.swift | 2 +- .../Actions/ActionTopNotificationModel.swift | 3 ++- .../MVMCoreUIActionOpenPageHandler.swift | 4 +-- .../BaseControllers/ViewController.swift | 6 ++--- .../SubNav/SubNavManagerController.swift | 2 +- .../MVMCoreUIActionHandler.swift | 3 +-- 14 files changed, 58 insertions(+), 39 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift index aa3ccc67..cc40b20b 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -10,18 +10,22 @@ import Foundation import MVMCore /// Shows an alert using the model. -open class ActionAlertHandler: MVMCoreActionHandlerProtocol { +open class ActionAlertHandler: MVMCoreJSONActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { - guard let model = model as? ActionAlertModel else { return } - try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in - var error: MVMCoreErrorObject? = nil - guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: json, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { - throw MVMCoreError.errorObject(error!) - } - (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json) + open func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + var error: MVMCoreErrorObject? = nil + guard let alertObject = MVMCoreAlertObject.alertObjectWith(action: JSON, additionalData: additionalData, delegateObject: delegateObject, error: &error) else { + throw MVMCoreError.errorObject(error!) + } + (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: JSON) + _ = await MainActor.run { MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) } } + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + let json = try MVMCoreActionHandler.convertActionToJSON(model) + try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData) + } } diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift index 67748a4d..f657304b 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertModel.swift @@ -7,7 +7,7 @@ // import MVMCore -@objcMembers public class ActionAlertModel: ActionModelProtocol { +public struct ActionAlertModel: ActionModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationModel.swift index 4663d539..94e84744 100644 --- a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationModel.swift @@ -7,8 +7,9 @@ // import UIKit +import MVMCore -@objcMembers public class ActionCollapseNotificationModel: ActionModelProtocol { +public struct ActionCollapseNotificationModel: ActionModelProtocol { public static var identifier: String = "collapseNotification" public var actionType: String = ActionCollapseNotificationModel.identifier diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift index 87060a4b..20853583 100644 --- a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift @@ -10,20 +10,24 @@ import Foundation import MVMCore /// Shows the panel. -open class ActionOpenPanelHandler: MVMCoreActionHandlerProtocol { +open class ActionOpenPanelHandler: MVMCoreJSONActionHandlerProtocol { required public init() {} + open func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + guard let model = model as? ActionOpenPanelModel else { return } + switch model.panel { + case .left, .menu: + await MVMCoreUISplitViewController.main()?.leftPanel?.willOpen?(withActionInformation: JSON, additionalData: additionalData) + await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) + case .right, .support: + await MVMCoreUISplitViewController.main()?.rightPanel?.willOpen?(withActionInformation: JSON, additionalData: additionalData) + await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) + } + } + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionOpenPanelModel else { return } - try await MVMCoreActionHandler.getOriginalJSON(with: model, additionalData: additionalData) { json, additionalData in - switch model.panel { - case .left, .menu: - await MVMCoreUISplitViewController.main()?.leftPanel?.willOpen?(withActionInformation: json, additionalData: additionalData) - await MVMCoreUISplitViewController.main()?.showLeftPanel(animated: true) - case .right, .support: - await MVMCoreUISplitViewController.main()?.rightPanel?.willOpen?(withActionInformation: json, additionalData: additionalData) - await MVMCoreUISplitViewController.main()?.showRightPanel(animated: true) - } - } + let json = try MVMCoreActionHandler.convertActionToJSON(model) + try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelModel.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelModel.swift index eaad4746..ec526e10 100644 --- a/MVMCoreUI/Atomic/Actions/ActionOpenPanelModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelModel.swift @@ -7,8 +7,9 @@ // import Foundation +import MVMCore -public class ActionOpenPanelModel: ActionModelProtocol { +public struct ActionOpenPanelModel: ActionModelProtocol { public enum Panel: String, Codable { case left diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift index d0efc18e..2bafd60b 100644 --- a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift @@ -23,8 +23,12 @@ open class ActionPopupHandler: MVMCoreActionHandlerProtocol { return } (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) - MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) - continuation.resume() + Task { + _ = await MainActor.run { + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) + } + continuation.resume() + } }) } } diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupModel.swift b/MVMCoreUI/Atomic/Actions/ActionPopupModel.swift index 8cdbd83c..cbade308 100644 --- a/MVMCoreUI/Atomic/Actions/ActionPopupModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionPopupModel.swift @@ -6,8 +6,9 @@ // Copyright © 2019 myverizon. All rights reserved. // +import MVMCore -@objcMembers public class ActionPopupModel: ActionModelProtocol { +public struct ActionPopupModel: ActionModelProtocol { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift index db37c3b1..b7d3d5eb 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -21,9 +21,13 @@ open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { continuation.resume(throwing: ModelRegistry.Error.decoderOther(message: "Alert Page \(model.pageType) missing ResponseInfo")) return } - let alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject)! - (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowTopAlert(with: alertObject, alertJson: json!) - alertObject.showAlert() + + var alertObject = MVMCoreAlertObject(forPageType: model.pageType, responseInfo: responseInfo, additionalData: additionalData, delegateObject: delegateObject) + if let object = alertObject, + let closure = (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowTopAlert { + alertObject = closure(object, json!) + } + alertObject?.showAlert() continuation.resume() }) } diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift index 62e496c2..440e318c 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertModel.swift @@ -8,7 +8,7 @@ import Foundation -@objcMembers public class ActionTopAlertModel: ActionModelProtocol { +public struct ActionTopAlertModel: ActionModelProtocol { public static var identifier: String = "topAlert" public var actionType: String = ActionTopAlertModel.identifier diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift index 7ca1d6aa..9850e8d0 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationModel.swift @@ -7,8 +7,9 @@ // import UIKit +import MVMCore -@objcMembers public class ActionTopNotificationModel: ActionModelProtocol { +public struct ActionTopNotificationModel: ActionModelProtocol { public static var identifier: String = "topNotification" public var actionType: String = ActionTopNotificationModel.identifier diff --git a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift index 550badf5..5de3ed27 100644 --- a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift +++ b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift @@ -10,10 +10,10 @@ import Foundation import MVMCore open class MVMCoreUIActionOpenPageHandler: ActionOpenPageHandler { - public override func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open override func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). var additionalData = additionalData additionalData?.removeValue(forKey: KeySourceModel) - try await super.performAction(model, delegateObject: delegateObject, additionalData: additionalData) + try await super.performAction(with: JSON, model: model, delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 9ba0971a..d04c7335 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore -@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionOpenPageDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { //-------------------------------------------------- // MARK: - Properties @@ -27,7 +27,7 @@ import MVMCore public weak var manager: (UIViewController & MVMCoreViewManagerProtocol)? /// A temporary iVar backer for delegateObject() until we change the protocol - public lazy var delegateObjectIVar: MVMCoreUIDelegateObject = { + open lazy var delegateObjectIVar: MVMCoreUIDelegateObject = { MVMCoreUIDelegateObject.create(withDelegateForAll: self) }() @@ -450,7 +450,7 @@ import MVMCore let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) pageForwardedData.merge(dataMap) { current, _ in current } } - return (requestParameters,pageForwardedData) + return (requestParameters, pageForwardedData) } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 042f3235..a4d4e54f 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -178,7 +178,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, guard let additionalData = additionalData, additionalData.boolForKey("tabBarPressed") else { // Pass to delegate - return try (viewController as? ActionDelegateProtocol)?.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) ?? value + return try (viewController as? ActionOpenPageDelegateProtocol)?.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) ?? value } // Allow opportunity to modify parameters. requestParameters = getRequestParametersForNewTabLoad(requestParameters: requestParameters, model: model, additionalData: additionalData) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift index 852b041a..6b30353f 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift @@ -16,8 +16,7 @@ import SafariServices open override func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable : Any]?) { super.defaultHandleActionError(error, additionalData: additionalData) guard !error.silentError else { return } - Task { - // TODO: Verify if necessary. + Task(priority: .userInitiated) { await MainActor.run { // Show alert let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)! From b816afba1cc91ff46261f0bdcc6e8af6a0972d9a Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 28 Jul 2022 18:30:01 -0400 Subject: [PATCH 07/17] Fix for top notification dismiss bug --- MVMCoreUI.xcodeproj/project.pbxproj | 8 +++++ .../ActionDismissNotificationHandler.swift | 23 +++++++++++++ .../ActionDismissNotificationModel.swift | 23 +++++++++++++ .../TopNotification/NotificationModel.swift | 26 +++++--------- .../TopNotification/NotificationXButton.swift | 7 ++-- .../OtherHandlers/CoreUIModelMapping.swift | 1 + ...MVMCoreTopAlertAnimationDelegateProtocol.h | 7 ++-- MVMCoreUI/TopAlert/MVMCoreTopAlertOperation.m | 34 +++++++++++-------- .../TopAlert/MVMCoreUITopAlertBaseView.m | 6 +--- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 2 ++ 10 files changed, 93 insertions(+), 44 deletions(-) create mode 100644 MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift create mode 100644 MVMCoreUI/Atomic/Actions/ActionDismissNotificationModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index cc0ba543..7b1bfd19 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -285,6 +285,8 @@ AF1C336F2885A16A006B1001 /* ActionCollapseNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */; }; AF1C33712885AE76006B1001 /* MVMCoreUIActionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler.swift */; }; AF1C33732885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */; }; + AF60A7F62892D2E300919EEB /* ActionDismissNotificationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF60A7F52892D2E300919EEB /* ActionDismissNotificationModel.swift */; }; + AF60A7F82892D34D00919EEB /* ActionDismissNotificationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */; }; AFE4A1D127DFB5EE00C458D0 /* VDSColorTokens.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */; }; AFE4A1D627DFBB6F00C458D0 /* UINavigationController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */; }; BB105859248DEFF70069D008 /* UICollectionViewLeftAlignedLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */; }; @@ -883,6 +885,8 @@ AF1C336E2885A16A006B1001 /* ActionCollapseNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionCollapseNotificationHandler.swift; sourceTree = ""; }; AF1C33702885AE76006B1001 /* MVMCoreUIActionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionHandler.swift; sourceTree = ""; }; AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIActionOpenPageHandler.swift; sourceTree = ""; }; + AF60A7F52892D2E300919EEB /* ActionDismissNotificationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionDismissNotificationModel.swift; sourceTree = ""; }; + AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionDismissNotificationHandler.swift; sourceTree = ""; }; AFE4A1D027DFB5EE00C458D0 /* VDSColorTokens.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = VDSColorTokens.xcframework; path = ../SharedFrameworks/VDSColorTokens.xcframework; sourceTree = ""; }; AFE4A1D527DFBB6F00C458D0 /* UINavigationController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extension.swift"; sourceTree = ""; }; BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICollectionViewLeftAlignedLayout.swift; sourceTree = ""; }; @@ -1505,6 +1509,8 @@ C6687440259D92D400F32D13 /* ActionTopNotificationModel.swift */, AF1C33642883B5A4006B1001 /* ActionTopNotificationHandler.swift */, AF1C33722885D481006B1001 /* MVMCoreUIActionOpenPageHandler.swift */, + AF60A7F52892D2E300919EEB /* ActionDismissNotificationModel.swift */, + AF60A7F72892D34D00919EEB /* ActionDismissNotificationHandler.swift */, ); path = Actions; sourceTree = ""; @@ -2999,6 +3005,7 @@ 522679C223FE886900906CBA /* ListLeftVariableCheckboxAllTextAndLinksModel.swift in Sources */, AA7F32AB246C0F7900C965BA /* ListLeftVariableRadioButtonAllTextAndLinksModel.swift in Sources */, 8D084AD02410BF4800951227 /* ListOneColumnFullWidthTextBodyTextModel.swift in Sources */, + AF60A7F82892D34D00919EEB /* ActionDismissNotificationHandler.swift in Sources */, D253BB9E2458751F002DE544 /* BGImageMoleculeModel.swift in Sources */, AA104AC924472DC7004D2810 /* HeadersH1ButtonModel.swift in Sources */, 0ABD1371237DB0450081388D /* ItemDropdownEntryField.swift in Sources */, @@ -3041,6 +3048,7 @@ D23A8FD9260CE004007E14CE /* MFStyler+PaddingExtension.swift in Sources */, 1D6D258926899B0C00DEBB08 /* ImageButton.swift in Sources */, C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */, + AF60A7F62892D2E300919EEB /* ActionDismissNotificationModel.swift in Sources */, 01EB3684236097C0006832FA /* MoleculeModelProtocol.swift in Sources */, D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */, AAB7EDF1246ADA2A00E54929 /* ListProgressBarThin.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift new file mode 100644 index 00000000..65db5455 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift @@ -0,0 +1,23 @@ +// +// ActionDismissNotificationHandler.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/28/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +/// Collapse the current top notification. +open class ActionDismissNotificationHandler: MVMCoreActionHandlerProtocol { + required public init() {} + + open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + await withCheckedContinuation { continuation in + CoreUIObject.sharedInstance()?.globalTopAlertDelegate?.getTopAlertView?().hideAlertView?(true, completionHandler: { finished in + continuation.resume() + }) ?? continuation.resume() + } + } +} diff --git a/MVMCoreUI/Atomic/Actions/ActionDismissNotificationModel.swift b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationModel.swift new file mode 100644 index 00000000..13816f37 --- /dev/null +++ b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationModel.swift @@ -0,0 +1,23 @@ +// +// ActionDismissNotificationModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 7/28/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation +import MVMCore + +public struct ActionDismissNotificationModel: ActionModelProtocol { + + public static var identifier: String = "dismissNotification" + public var actionType: String = ActionDismissNotificationModel.identifier + public var extraParameters: JSONValueDictionary? + public var analyticsData: JSONValueDictionary? + + public init(_ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) { + self.extraParameters = extraParameters + self.analyticsData = analyticsData + } +} diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift index bd84b7fd..fe40a022 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationModel.swift @@ -85,24 +85,14 @@ open class NotificationModel: ContainerModel, MoleculeModelProtocol { } button?.size = .tiny - if button?.enabledTextColor == nil { - switch style { - case .error, .warning: - button?.enabledTextColor = Color(uiColor: .mvmBlack) - default: - button?.enabledTextColor = Color(uiColor: .mvmWhite) - } - } - if button?.enabledBorderColor == nil { - switch style { - case .error, .warning: - button?.enabledBorderColor = Color(uiColor: .mvmBlack) - default: - button?.enabledBorderColor = Color(uiColor: .mvmWhite) - } - } - if button?.style == nil { - button?.style = .secondary + button?.style = .secondary + switch style { + case .error, .warning: + button?.enabledTextColor = Color(uiColor: .mvmBlack) + button?.enabledBorderColor = Color(uiColor: .mvmBlack) + default: + button?.enabledTextColor = Color(uiColor: .mvmWhite) + button?.enabledBorderColor = Color(uiColor: .mvmWhite) } if closeButton?.color == nil { diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index 204785cb..2bce8658 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -7,15 +7,12 @@ // import Foundation +import MVMCore @objcMembers open class NotificationXButton: Button { open func closeTopAlert() { - if let delegate = MVMCoreUITopAlertView.sharedGlobal()?.animationDelegate { - delegate.topAlertCloseButtonPressed() - } else { - MVMCoreUISession.sharedGlobal()?.topAlertView?.hideAlertView(true, completionHandler: nil) - } + _ = MVMCoreUIActionHandler.shared()?.asyncHandleAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) } open override func setupView() { diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 04d10423..061c67fb 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -232,6 +232,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(handler: ActionAlertHandler.self, for: ActionAlertModel.self) ModelRegistry.register(handler: ActionTopAlertHandler.self, for: ActionTopAlertModel.self) ModelRegistry.register(handler: ActionCollapseNotificationHandler.self, for: ActionCollapseNotificationModel.self) + ModelRegistry.register(handler: ActionDismissNotificationHandler.self, for: ActionDismissNotificationModel.self) ModelRegistry.register(handler: ActionOpenPanelHandler.self, for: ActionOpenPanelModel.self) ModelRegistry.register(handler: ActionTopNotificationHandler.self, for: ActionTopNotificationModel.self) ModelRegistry.register(handler: MVMCoreUIActionOpenPageHandler.self, for: ActionOpenPageModel.self, allowsReplace: true) diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertAnimationDelegateProtocol.h b/MVMCoreUI/TopAlert/MVMCoreTopAlertAnimationDelegateProtocol.h index bb9f6dfc..52922df4 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertAnimationDelegateProtocol.h +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertAnimationDelegateProtocol.h @@ -16,7 +16,10 @@ // Called when the top alert is ending an animation - (void)topAlertViewFinishAnimation; -// Called when the top alert close button was pressed by the user -- (void)topAlertCloseButtonPressed; +// Called when the top alert is starting to dismiss. +- (void)topAlertWillDismiss; + +// Called when the top alert is dismissed. +- (void)topAlertDismissed; @end diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertOperation.m b/MVMCoreUI/TopAlert/MVMCoreTopAlertOperation.m index 7a57f989..f0011719 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertOperation.m +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertOperation.m @@ -183,11 +183,11 @@ if (self.isCancelled) { // Cancelled, dismiss immediately. - [self dismissAlertView:YES forceful:YES]; + [self dismissAlertView:YES]; } else if (self.isPaused) { // Paused, dismiss for the time being if persistent. - [self dismissAlertView:!self.topAlertObject.persistent forceful:YES]; + [self dismissAlertView:YES]; } else { [self updateDismissTimer]; } @@ -223,7 +223,7 @@ if (weakSelf.isFinished || [weakSelf checkAndHandleForCancellation]) { return; } - [weakSelf dismissAlertView:YES forceful:NO]; + [weakSelf dismissAlertView:NO]; }); dispatch_resume(self.timerSource); } @@ -235,27 +235,21 @@ if (!self.isAnimating) { if (self.isDisplayed) { - [self dismissAlertView:YES forceful:YES]; + [self dismissAlertView:YES]; } else if (self.isExecuting) { [self markAsFinished]; } } } -- (void)dismissAlertView:(BOOL)andFinish forceful:(BOOL)forceful { +- (void)dismissAlertView:(BOOL)forceful { if (self.timerSource) { dispatch_source_cancel(self.timerSource); } if (self.isDisplayed && !self.isAnimating) { // Dismisses. - [[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView] hideAlertView:forceful completionHandler:^(BOOL finished) { - - self.displayed = NO; - if (andFinish) { - [self markAsFinished]; - } - }]; + [[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView] hideAlertView:forceful completionHandler:NULL]; } } @@ -266,7 +260,7 @@ self.paused = YES; [self didChangeValueForKey:@"isPaused"]; } - [self dismissAlertView:!self.topAlertObject.persistent forceful:YES]; + [self dismissAlertView:YES]; } - (void)unpause { @@ -291,8 +285,20 @@ self.animating = NO; } +- (void)topAlertDismissed { + self.displayed = NO; + if (!self.isCancelled && self.isPaused && self.topAlertObject.persistent) { return; } + [self markAsFinished]; +} + +- (void)topAlertWillDismiss { + if (self.timerSource) { + dispatch_source_cancel(self.timerSource); + } +} + - (void)topAlertCloseButtonPressed { - [self dismissAlertView:YES forceful:YES]; + [self dismissAlertView:YES]; } - (id)copyWithZone:(nullable NSZone *)zone { diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m index 19570ca2..862e4b5b 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m @@ -70,11 +70,7 @@ - (nonnull Button *)addCloseButtonWithAnimationDelegate:(nullable id )animationDelegate { Button *closeButton = [MVMCoreUICommonViewsUtility addCloseButtonTo:self action:^(Button * _Nonnull button) { - if (animationDelegate) { - [animationDelegate topAlertCloseButtonPressed]; - } else { - [[MVMCoreUISession sharedGlobal].topAlertView hideAlertView:YES completionHandler:nil]; - } + [[MVMCoreUIActionHandler sharedActionHandler] handleActionWithDictionary:@{KeyActionType: @"dismissNotification"} additionalData:nil delegateObject:nil]; } centeredVertically:YES]; [closeButton.heightAnchor constraintEqualToConstant:16.0].active = YES; [closeButton.widthAnchor constraintEqualToConstant:16.0].active = YES; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 108d7a84..292d9132 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -226,6 +226,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; __weak typeof(self) weakSelf = self; MVMCoreBlockOperation *operation = [MVMCoreBlockOperation blockOperationWithBlock:^(MVMCoreBlockOperation * _Nonnull operation) { [MVMCoreDispatchUtility performBlockOnMainThread:^{ + [weakSelf.animationDelegate topAlertWillDismiss]; [weakSelf.animationDelegate topAlertViewBeginAnimation]; // accessibility - below line added to notify VI user through voiceover user when the top alert is closed @@ -251,6 +252,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; if (completionHandler) { completionHandler(finished); } + [weakSelf.animationDelegate topAlertDismissed]; weakSelf.topAlertObject = nil; if (weakSelf.currentAlertOverridingStatusBar) { weakSelf.currentAlertOverridingStatusBar = NO; From 0c47fdc60f1ac661d63f99be669835ebe0758a8e Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 29 Jul 2022 09:36:38 -0400 Subject: [PATCH 08/17] add back broken delegate --- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index d04c7335..763028ff 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore -@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionOpenPageDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionDelegateProtocol, ActionOpenPageDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { //-------------------------------------------------- // MARK: - Properties From 6853274a6770d1106aff9e9d2c4299ca78ea5662 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 29 Jul 2022 16:20:22 -0400 Subject: [PATCH 09/17] Descriptor changes --- MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift index 6b30353f..230e7978 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift @@ -26,7 +26,8 @@ import SafariServices } @objc(openURLInSafariWebView:) - @MainActor open func openURL(inSafariWebView url: URL) { + @MainActor + open func openURL(inSafariWebView url: URL) { let safariViewController = SFSafariViewController(url: url) MVMCoreNavigationHandler.shared()?.present(safariViewController, animated: true) } From 558eb9bfd06c08a7c83e7f65e3fb82c756071856 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 29 Jul 2022 16:27:49 -0400 Subject: [PATCH 10/17] Revert --- .../TextFields/Dropdown Fields/BaseDropdownEntryField.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift | 2 +- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 ++-- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 2 +- .../Atomic/Molecules/HorizontalCombinationViews/Tabs.swift | 2 +- .../Molecules/Items/AccordionMoleculeTableViewCell.swift | 6 +++--- .../Molecules/Items/DropDownFilterTableViewCell.swift | 2 +- MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift | 6 +++--- .../Molecules/TopNotification/NotificationXButton.swift | 2 +- MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift | 2 +- MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift | 2 +- MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift | 2 +- MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index 037cf2ef..c6b233a7 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -7,7 +7,7 @@ // import UIKit - +import MVMCore /** This class is intended to be subclassed. See ItemDropdownEntryField and DateDropdownEntryField. @@ -100,6 +100,6 @@ import UIKit else { return } let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index 01ef9b04..4bd64c7c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -391,7 +391,7 @@ import MVMCore private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { var additionalDataToUpdate = additionalData ?? [:] additionalDataToUpdate[KeySourceModel] = checkboxModel - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index b8ad4577..04c34da2 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -396,11 +396,11 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let self = self else { return } if self.isOn { if let action = model.action { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } else { if let action = model.alternateAction ?? model.action { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index d18d62e0..91bf44b8 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -387,7 +387,7 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) } addActionAttributes(range: range, string: attributedString) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 653566b7..4e424549 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -256,7 +256,7 @@ extension Tabs: UICollectionViewDelegateFlowLayout { if let delegate = delegate { delegate.didSelectItem(indexPath, tabs: self) } else if let action = tabsModel.tabs[selectedIndex].action { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift index ff87ef2b..6975f8cb 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -46,9 +46,9 @@ model.selected = accordionButton.isSelected if accordionButton.isSelected { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } else { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { @@ -56,7 +56,7 @@ } if let actionModel = accordionButton.isSelected ? accordionListItemModel?.expandAction : accordionListItemModel?.collapseAction { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index d157bce1..58e9dfc4 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -37,7 +37,7 @@ import UIKit actions.append(AddMoleculesActionModel(.fade)) let actionsModel = ActionActionsModel(actions: actions) actionsModel.concurrent = false - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 0fc353e4..d3b91b11 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -57,7 +57,7 @@ extension TabsTableViewCell: TabsDelegate { public func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool { guard indexPath.row != tabs.selectedIndex else { return false } if let model = tabsListItemModel { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } previousTabIndex = tabs.selectedIndex return true @@ -68,9 +68,9 @@ extension TabsTableViewCell: TabsDelegate { guard let model = tabsListItemModel, index < model.molecules.count else { return } if let action = model.tabs.tabs[index].action { - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) } - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index 2bce8658..560dcf23 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers open class NotificationXButton: Button { open func closeTopAlert() { - _ = MVMCoreUIActionHandler.shared()?.asyncHandleAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) + MVMCoreUIActionHandler.shared()?.asyncHandleAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift index f14ebcd8..71c23c16 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift @@ -32,7 +32,7 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalListPageTemplateModel)?.closeAction ?? ActionBackModel() - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift index 9f050f3f..1c76b467 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift @@ -28,7 +28,7 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ?? ActionBackModel() - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift index 7ff515f8..3e4f3fc2 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift @@ -27,7 +27,7 @@ open class ModalSectionListTemplate: SectionListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ?? ActionBackModel() - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index a4d4e54f..237fa71e 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -277,7 +277,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { // Perform the tab action - _ = MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) + MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) } return false } From d8bf3c9a086060997101d15237aaa72b747461f0 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 8 Aug 2022 17:45:28 -0400 Subject: [PATCH 11/17] Button -> Delegate -> ActionHandler. Components will go through delegate. Delegate will choose how to handle it. --- .../Atomic/Actions/ActionAlertHandler.swift | 2 +- .../ActionCollapseNotificationHandler.swift | 2 +- .../ActionDismissNotificationHandler.swift | 2 +- .../Actions/ActionOpenPanelHandler.swift | 2 +- .../Atomic/Actions/ActionPopupHandler.swift | 2 +- .../Actions/ActionTopAlertHandler.swift | 2 +- .../ActionTopNotificationHandler.swift | 2 +- .../Atomic/Atoms/FormFields/Tags/Tags.swift | 4 +++- .../BaseDropdownEntryField.swift | 2 +- .../Atomic/Atoms/Selectors/Checkbox.swift | 2 +- MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift | 4 +++- .../Atomic/Atoms/Selectors/RadioBox.swift | 4 +++- .../Atomic/Atoms/Selectors/RadioButton.swift | 4 +++- .../Atomic/Atoms/Selectors/RadioSwatch.swift | 4 +++- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 4 ++-- .../Atomic/Atoms/Views/Label/Label.swift | 2 +- .../HorizontalCombinationViews/TabBar.swift | 5 +++- .../HorizontalCombinationViews/Tabs.swift | 2 +- .../AccordionMoleculeTableViewCell.swift | 10 ++++---- .../Items/DropDownFilterTableViewCell.swift | 2 +- .../Molecules/Items/TabsTableViewCell.swift | 6 ++--- .../CollapsableNotification.swift | 4 +++- .../TopNotification/NotificationXButton.swift | 2 +- .../Templates/ModalMoleculeListTemplate.swift | 2 +- .../ModalMoleculeStackTemplate.swift | 2 +- .../Templates/ModalSectionListTemplate.swift | 2 +- MVMCoreUI/BaseClasses/BarButtonItem.swift | 4 +++- MVMCoreUI/BaseClasses/Button.swift | 23 +++++++++---------- .../BaseClasses/CollectionViewCell.swift | 4 +++- MVMCoreUI/BaseClasses/TableViewCell.swift | 4 +++- .../BaseControllers/ViewController.swift | 8 +++++++ .../SubNav/SubNavManagerController.swift | 2 +- 32 files changed, 77 insertions(+), 49 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift index cc40b20b..0f4a11fa 100644 --- a/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionAlertHandler.swift @@ -24,7 +24,7 @@ open class ActionAlertHandler: MVMCoreJSONActionHandlerProtocol { } } - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { let json = try MVMCoreActionHandler.convertActionToJSON(model) try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift index f12b2db9..069ee74f 100644 --- a/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionCollapseNotificationHandler.swift @@ -13,7 +13,7 @@ import MVMCore open class ActionCollapseNotificationHandler: MVMCoreActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { CoreUIObject.sharedInstance()?.globalTopAlertDelegate?.getTopAlertView?().collapseNotification?() } } diff --git a/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift index 65db5455..a2e1f279 100644 --- a/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionDismissNotificationHandler.swift @@ -13,7 +13,7 @@ import MVMCore open class ActionDismissNotificationHandler: MVMCoreActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { await withCheckedContinuation { continuation in CoreUIObject.sharedInstance()?.globalTopAlertDelegate?.getTopAlertView?().hideAlertView?(true, completionHandler: { finished in continuation.resume() diff --git a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift index 20853583..98287b27 100644 --- a/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionOpenPanelHandler.swift @@ -25,7 +25,7 @@ open class ActionOpenPanelHandler: MVMCoreJSONActionHandlerProtocol { } } - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionOpenPanelModel else { return } let json = try MVMCoreActionHandler.convertActionToJSON(model) try await performAction(with: json, model: model, delegateObject: delegateObject, additionalData: additionalData) diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift index 2bafd60b..9fe86eef 100644 --- a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift @@ -13,7 +13,7 @@ import MVMCore open class ActionPopupHandler: MVMCoreActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionPopupModel else { return } try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in diff --git a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift index b7d3d5eb..49ca8561 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopAlertHandler.swift @@ -13,7 +13,7 @@ import MVMCore open class ActionTopAlertHandler: MVMCoreActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionTopAlertModel else { return } try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in MVMCoreCache.shared()?.fetchJSON(forPageType: model.pageType, queue: nil, waitUntilFinished: true, completionHandler: { json in diff --git a/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift index 89762268..858c1d09 100644 --- a/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionTopNotificationHandler.swift @@ -13,7 +13,7 @@ import MVMCore open class ActionTopNotificationHandler: MVMCoreActionHandlerProtocol { required public init() {} - open func performAction(_ model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { + open func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { guard let model = model as? ActionTopNotificationModel else { return } await MVMCoreUITopAlertView.sharedGlobal()?.showTopAlert(with: model.topNotification) } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tags.swift b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tags.swift index 4b1fa4f9..a112a723 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tags.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/Tags/Tags.swift @@ -100,6 +100,8 @@ extension Tags: UICollectionViewDelegate { open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard let tagModel = tags?[indexPath.row], let tagAction = tagModel.action else { return } - Button.performButtonAction(with: tagAction, button: self, delegateObject: delegateObject, additionalData: nil) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: tagAction, button: self, delegateObject: delegateObject, additionalData: nil) + } } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index c6b233a7..fdf80f29 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -100,6 +100,6 @@ import MVMCore else { return } let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index 4bd64c7c..bbbeec00 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -391,7 +391,7 @@ import MVMCore private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { var additionalDataToUpdate = additionalData ?? [:] additionalDataToUpdate[KeySourceModel] = checkboxModel - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift index eb0b0b4c..1f22e328 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Heart.swift @@ -106,7 +106,9 @@ import UIKit guard isEnabled else { return } isSelected = !isSelected if let heartModel = heartModel { - Button.performButtonAction(with: heartModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: heartModel) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: heartModel.action, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: heartModel) + } } setNeedsDisplay() } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift index 27323048..9fb6b354 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioBox.swift @@ -142,7 +142,9 @@ open class RadioBox: Control, MFButtonProtocol { isSelected = true radioBoxModel?.selected = isSelected if let radioBoxModel = radioBoxModel, let actionModel = radioBoxModel.action { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioBoxModel) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioBoxModel) + } } layer.setNeedsDisplay() } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift index 1f82a63c..ddd155be 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioButton.swift @@ -104,7 +104,9 @@ import VDSFormControlsTokens } if let radioModel = radioModel, let actionModel = radioModel.action, isSelected, !wasPreviouslySelected { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioModel) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioModel) + } } _ = FormValidator.validate(delegate: delegateObject?.formHolderDelegate) diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift index eb569810..50d9d9c5 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/RadioSwatch.swift @@ -124,7 +124,9 @@ open class RadioSwatch: Control, MFButtonProtocol { isSelected = true radioSwatchModel?.selected = isSelected if let radioSwatchModel = radioSwatchModel, let actionModel = radioSwatchModel.action { - Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioSwatchModel) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: radioSwatchModel) + } } layer.setNeedsDisplay() } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 04c34da2..dc16312e 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -396,11 +396,11 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let self = self else { return } if self.isOn { if let action = model.action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } else { if let action = model.alternateAction ?? model.action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 91bf44b8..d78d15d5 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -387,7 +387,7 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) } addActionAttributes(range: range, string: attributedString) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift index 527ed054..e49006fa 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabBar.swift @@ -69,7 +69,10 @@ import VDSColorTokens // MARK: - UITabBarDelegate public func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) { model.selectedTab = item.tag - Button.performButtonAction(with: model.tabs[item.tag].action, button: item, delegateObject: delegateObject, additionalData: nil) + let action = model.tabs[item.tag].action + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: action, button: item, delegateObject: delegateObject, additionalData: nil) + } } // MARK: - TabBarProtocol diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index f8e00ae6..42217612 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -259,7 +259,7 @@ extension Tabs: UICollectionViewDelegateFlowLayout { if let delegate = delegate { delegate.didSelectItem(indexPath, tabs: self) } else if let action = tabsModel.tabs[selectedIndex].action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) } if UIAccessibility.isVoiceOverRunning { UIAccessibility.post(notification: .layoutChanged, argument: tabCell) diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift index 6975f8cb..1a219840 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -6,8 +6,8 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // - -@objcMembers public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { +import MVMCore +public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- @@ -46,9 +46,9 @@ model.selected = accordionButton.isSelected if accordionButton.isSelected { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } else { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { @@ -56,7 +56,7 @@ } if let actionModel = accordionButton.isSelected ? accordionListItemModel?.expandAction : accordionListItemModel?.collapseAction { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index 58e9dfc4..0a845a92 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -37,7 +37,7 @@ import UIKit actions.append(AddMoleculesActionModel(.fade)) let actionsModel = ActionActionsModel(actions: actions) actionsModel.concurrent = false - MVMCoreActionHandler.shared()?.asyncHandleAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index d3b91b11..8e63cbd4 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -57,7 +57,7 @@ extension TabsTableViewCell: TabsDelegate { public func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool { guard indexPath.row != tabs.selectedIndex else { return false } if let model = tabsListItemModel { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } previousTabIndex = tabs.selectedIndex return true @@ -68,9 +68,9 @@ extension TabsTableViewCell: TabsDelegate { guard let model = tabsListItemModel, index < model.molecules.count else { return } if let action = model.tabs.tabs[index].action { - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) } - MVMCoreActionHandler.shared()?.asyncHandleAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift index 82983f4d..8c9416c0 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/CollapsableNotification.swift @@ -60,7 +60,9 @@ import Foundation if let topAction = model.topAction, topAction.actionType == ActionNoopModel.identifier { topView.button.addActionBlock(event: .touchUpInside) { [weak self] (button) in - Button.performButtonAction(with: topAction, button: button, delegateObject: delegateObject, additionalData: additionalData) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: topAction, button: button, delegateObject: delegateObject, additionalData: additionalData) + } self?.expand(topViewShowing: model.alwaysShowTopLabel) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index 560dcf23..698aedcd 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -12,7 +12,7 @@ import MVMCore @objcMembers open class NotificationXButton: Button { open func closeTopAlert() { - MVMCoreUIActionHandler.shared()?.asyncHandleAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift index 71c23c16..033bebb4 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift @@ -32,7 +32,7 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalListPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift index 1c76b467..1531d35b 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift @@ -28,7 +28,7 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift index 3e4f3fc2..96052ee1 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift @@ -27,7 +27,7 @@ open class ModalSectionListTemplate: SectionListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreActionHandler.shared()?.asyncHandleAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) }) } } diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index b46647f2..c360b457 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -33,7 +33,9 @@ public typealias BarButtonAction = (BarButtonItem) -> () buttonDelegate = delegateObject?.buttonDelegate actionDelegate?.buttonAction = { sender in let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: model) - Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalDataWithSource) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalDataWithSource) + } } } } diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index a94cafe8..ebda6af4 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -6,8 +6,9 @@ // Copyright © 2019 Verizon Wireless. All rights reserved. // -public typealias ButtonAction = (Button) -> () +import MVMCore +public typealias ButtonAction = (Button) -> () @objcMembers open class Button: UIButton, MFButtonProtocol, MoleculeViewProtocol { //-------------------------------------------------- @@ -79,21 +80,19 @@ public typealias ButtonAction = (Button) -> () addActionBlock(event: .touchUpInside) { [weak self] sender in guard let self = self, let actionModel = actionModel else { return } - Self.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.model) + Task(priority: .userInitiated) { + try await Self.performButtonAction(with: actionModel, button: self, delegateObject: delegateObject, additionalData: additionalData, sourceModel: self.model) + } } } - open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) { - if let data = try? model.encode(using: JSONEncoder()), - let actionMap = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.init()) as? [AnyHashable: Any], - delegateObject?.buttonDelegate?.button?(button, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true { - if let sourceModel = sourceModel { - let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: sourceModel) - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalDataWithSource, delegateObject: delegateObject) - } else { - MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) - } + open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) async throws { + guard delegateObject?.buttonDelegate?.button?(button, shouldPerformActionWithMap: model.toJSON(), additionalData: additionalData) ?? true else { return } + var additionalData = additionalData + if let sourceModel = sourceModel { + additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: sourceModel) } + try await MVMCoreUIActionHandler.handleActionCheckingDelegate(with: model, additionalData: additionalData, delegateObject: delegateObject) } // MARK:- MoleculeViewProtocol diff --git a/MVMCoreUI/BaseClasses/CollectionViewCell.swift b/MVMCoreUI/BaseClasses/CollectionViewCell.swift index cfbe4ac7..c57afd41 100644 --- a/MVMCoreUI/BaseClasses/CollectionViewCell.swift +++ b/MVMCoreUI/BaseClasses/CollectionViewCell.swift @@ -118,7 +118,9 @@ open class CollectionViewCell: UICollectionViewCell, MoleculeViewProtocol, MVMCo open func shouldSelect(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) -> Bool { if let action = model?.action { - Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + } } return false } diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index d90d0338..c21e2c49 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -256,7 +256,9 @@ import UIKit open func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { guard let action = listItemModel?.action else { return } - Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + Task(priority: .userInitiated) { + try await Button.performButtonAction(with: action, button: self, delegateObject: delegateObject, additionalData: additionalData) + } } open func didDeselectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { } diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 763028ff..bd62a3ad 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -467,6 +467,14 @@ import MVMCore return handled } + open func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { + do { + try await MVMCoreUIActionHandler.shared()?.handleAction(with: model, additionalData: additionalData, delegateObject: delegateObject) + } catch { + MVMCoreUIActionHandler.shared()?.defaultHandle(error: error, model: model, additionalData: additionalData, delegateObject: delegateObject) + } + } + //-------------------------------------------------- // MARK: - MoleculeDelegateProtocol //-------------------------------------------------- diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 237fa71e..2d1ab302 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -277,7 +277,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { // Perform the tab action - MVMCoreActionHandler.shared()?.asyncHandleAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) + MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) } return false } From 1f75221915f8b43e5763f9df309be3dc3cb8cab3 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Wed, 10 Aug 2022 22:19:01 -0400 Subject: [PATCH 12/17] Drive through delegate up front. Remove some legacy delegate back and forth --- .../BaseDropdownEntryField.swift | 4 +- .../Atomic/Atoms/Selectors/Checkbox.swift | 7 +-- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 8 ++- .../Atomic/Atoms/Views/Label/Label.swift | 4 +- .../HorizontalCombinationViews/Tabs.swift | 4 +- .../AccordionMoleculeTableViewCell.swift | 12 +++-- .../Items/DropDownFilterTableViewCell.swift | 4 +- .../Molecules/Items/TabsTableViewCell.swift | 12 +++-- .../TopNotification/NotificationXButton.swift | 8 +-- .../Templates/ModalMoleculeListTemplate.swift | 6 ++- .../ModalMoleculeStackTemplate.swift | 5 +- .../Templates/ModalSectionListTemplate.swift | 6 ++- MVMCoreUI/BaseClasses/Button.swift | 2 +- .../BaseControllers/ViewController.swift | 53 ++++++++++--------- .../Behaviors/AddRemoveMoleculeBehavior.swift | 30 +++++------ .../Protocols/PageBehaviorProtocol.swift | 8 ++- .../SubNav/SubNavManagerController.swift | 26 +++++---- 17 files changed, 118 insertions(+), 81 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index fdf80f29..8fa985c7 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -100,6 +100,8 @@ import MVMCore else { return } let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) + } } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index bbbeec00..fc6427b3 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -389,9 +389,10 @@ import MVMCore } private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - var additionalDataToUpdate = additionalData ?? [:] - additionalDataToUpdate[KeySourceModel] = checkboxModel - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) + let additionalDataToUpdate = (checkboxModel != nil) ? additionalData.dictionaryAdding(key: KeySourceModel, value: checkboxModel!) : additionalData + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) + } } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index dc16312e..9c1f91ca 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -396,11 +396,15 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let self = self else { return } if self.isOn { if let action = model.action { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + } } } else { if let action = model.alternateAction ?? model.action { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) + } } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index d78d15d5..9723f18d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -387,7 +387,9 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) + } } addActionAttributes(range: range, string: attributedString) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 42217612..66a4b263 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -259,7 +259,9 @@ extension Tabs: UICollectionViewDelegateFlowLayout { if let delegate = delegate { delegate.didSelectItem(indexPath, tabs: self) } else if let action = tabsModel.tabs[selectedIndex].action { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject:delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject: delegateObject) + } } if UIAccessibility.isVoiceOverRunning { UIAccessibility.post(notification: .layoutChanged, argument: tabCell) diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift index 1a219840..12916ac3 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -46,9 +46,13 @@ public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { model.selected = accordionButton.isSelected if accordionButton.isSelected { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + } } else { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + } } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { @@ -56,7 +60,9 @@ public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { } if let actionModel = accordionButton.isSelected ? accordionListItemModel?.expandAction : accordionListItemModel?.collapseAction { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) + } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index 0a845a92..70122918 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -37,7 +37,9 @@ import UIKit actions.append(AddMoleculesActionModel(.fade)) let actionsModel = ActionActionsModel(actions: actions) actionsModel.concurrent = false - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) + Task(priority: .userInitiated) { + try await (self.delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) + } } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index 8e63cbd4..b7f76f2b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -57,7 +57,9 @@ extension TabsTableViewCell: TabsDelegate { public func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool { guard indexPath.row != tabs.selectedIndex else { return false } if let model = tabsListItemModel { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + } } previousTabIndex = tabs.selectedIndex return true @@ -68,9 +70,13 @@ extension TabsTableViewCell: TabsDelegate { guard let model = tabsListItemModel, index < model.molecules.count else { return } if let action = model.tabs.tabs[index].action { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject:delegateObject) + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject: delegateObject) + } + } + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index 698aedcd..f6d6a5f6 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -11,8 +11,10 @@ import MVMCore @objcMembers open class NotificationXButton: Button { - open func closeTopAlert() { - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: nil) + open func closeTopAlert(with delegateObject: MVMCoreUIDelegateObject?) { + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: delegateObject) + } } open override func setupView() { @@ -35,7 +37,7 @@ import MVMCore // TODO: Temporary, consider action for dismissing top alert if model.action.actionType == ActionNoopModel.identifier { addActionBlock(event: .touchUpInside) { (button) in - (button as? NotificationXButton)?.closeTopAlert() + (button as? NotificationXButton)?.closeTopAlert(with: delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift index 033bebb4..01a0b49e 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift @@ -7,7 +7,7 @@ // import UIKit - +import MVMCore open class ModalMoleculeListTemplate: MoleculeListTemplate { //-------------------------------------------------- @@ -32,7 +32,9 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalListPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + Task(priority: .userInitiated) { + try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) + } }) } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift index 1531d35b..00f125d8 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift @@ -7,6 +7,7 @@ // import UIKit +import MVMCore open class ModalMoleculeStackTemplate: MoleculeStackTemplate { //-------------------------------------------------- @@ -28,7 +29,9 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + Task(priority: .userInitiated) { + try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) + } }) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift index 96052ee1..c5fbb6be 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift @@ -5,7 +5,7 @@ // Created by Scott Pfeil on 10/8/20. // Copyright © 2020 Verizon Wireless. All rights reserved. // - +import MVMCore open class ModalSectionListTemplate: SectionListTemplate { //-------------------------------------------------- @@ -27,7 +27,9 @@ open class ModalSectionListTemplate: SectionListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ?? ActionBackModel() - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: closeAction, additionalData: nil, delegateObject: self.delegateObjectIVar) + Task(priority: .userInitiated) { + try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) + } }) } } diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index ebda6af4..1b62a741 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -92,7 +92,7 @@ public typealias ButtonAction = (Button) -> () if let sourceModel = sourceModel { additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: sourceModel) } - try await MVMCoreUIActionHandler.handleActionCheckingDelegate(with: model, additionalData: additionalData, delegateObject: delegateObject) + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model, additionalData: additionalData, delegateObject: delegateObject) } // MARK:- MoleculeViewProtocol diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index bd62a3ad..e0de37f1 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -9,7 +9,7 @@ import UIKit import MVMCore -@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionDelegateProtocol, ActionOpenPageDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { +@objc open class ViewController: UIViewController, MVMCoreViewControllerProtocol, MVMCoreViewManagerViewControllerProtocol, MoleculeDelegateProtocol, FormHolderProtocol, MVMCoreActionDelegateProtocol, ActionDelegateProtocol, MVMCoreLoadDelegateProtocol, UITextFieldDelegate, UITextViewDelegate, ObservingTextFieldDelegate, MVMCoreUIDetailViewProtocol, PageProtocol, PageBehaviorHandlerProtocol { //-------------------------------------------------- // MARK: - Properties @@ -439,40 +439,41 @@ import MVMCore //-------------------------------------------------- // MARK: - MVMCoreActionDelegateProtocol //-------------------------------------------------- - open func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable : Any]? = nil) throws -> (MVMCoreRequestParameters,[AnyHashable : Any]?) { - let json = try MVMCoreActionHandler.convertActionToJSON(model) - let requestParameters = MVMCoreRequestParameters(actionMap: json)! - addFormParams(requestParameters: requestParameters, model: model, additionalData: additionalData) - requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") - var pageForwardedData = additionalData ?? [:] - - executeBehaviors { (behavior: PageLocalDataShareBehavior) in - let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) - pageForwardedData.merge(dataMap) { current, _ in current } - } - return (requestParameters, pageForwardedData) - } open func logAction(withActionInformation actionInformation: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?) { MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: self, actionInformation: actionInformation, additionalData: additionalData) } - public func handlesUnknownAction(for model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> Bool { - var handled = false - executeBehaviors { (behavior: PageCustomActionHandlerBehavior) in - if !handled { - handled = behavior.handleAction(with: model, additionalData: additionalData) + open func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { + var additionalData = additionalData + if let model = model as? ActionOpenPageModel { + addFormParams(requestParameters: model.requestParameters, model: model, additionalData: additionalData) + model.requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") + + var pageForwardedData = additionalData ?? [:] + executeBehaviors { (behavior: PageLocalDataShareBehavior) in + let dataMap = behavior.compileLocalPageDataForTransfer(delegateObjectIVar) + pageForwardedData.merge(dataMap) { current, _ in current } } + additionalData = pageForwardedData + } + + do { + if let behavior = behaviors?.compactMap({ $0 as? PageCustomActionHandlerBehavior }).first(where: { $0.canHandleAction(with: model, additionalData: additionalData) }) { + delegateObject?.actionDelegate?.logAction?(withActionInformation: model.toJSON(), additionalData: additionalData) + try await behavior.handleAction(with: model, additionalData: additionalData) + } else { + try await MVMCoreUIActionHandler.shared()?.handleAction(with: model, additionalData: additionalData, delegateObject: delegateObject) + } + } catch { + handleAction(error: error, model: model, additionalData: additionalData, delegateObject: delegateObject) + throw error } - return handled } - open func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { - do { - try await MVMCoreUIActionHandler.shared()?.handleAction(with: model, additionalData: additionalData, delegateObject: delegateObject) - } catch { - MVMCoreUIActionHandler.shared()?.defaultHandle(error: error, model: model, additionalData: additionalData, delegateObject: delegateObject) - } + open func handleAction(error: Error, model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) { + let errorObject = MVMCoreErrorObject.createErrorObject(for: error, location: MVMCoreActionHandler.getErrorLocation(with: delegateObject?.actionDelegate, actionType: model.actionType))! + MVMCoreUIActionHandler.shared()?.defaultHandleActionError(errorObject, additionalData: additionalData) } //-------------------------------------------------- diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index acd3527a..75171d73 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore public enum AddMoleculesPosition { case above @@ -85,28 +86,27 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo } } - public func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool { - if model.actionType == AddMoleculesActionModel.identifier { - guard let model = model as? AddMoleculesActionModel, - let list = delegate?.moleculeListDelegate, - let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), - let moleculesToAdd = sourceModel.getRecursiveMoleculesToAdd(), - let indexPath = list.getAdjustedIndexPath(for: sourceModel, position: moleculesToAdd.1) else { return true } - DispatchQueue.main.async { + public func canHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool { + return model.actionType == AddMoleculesActionModel.identifier || model.actionType == RemoveMoleculesActionModel.identifier + } + + public func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) async throws { + if let model = model as? AddMoleculesActionModel, + let list = delegate?.moleculeListDelegate, + let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), + let moleculesToAdd = sourceModel.getRecursiveMoleculesToAdd(), + let indexPath = list.getAdjustedIndexPath(for: sourceModel, position: moleculesToAdd.1) { + await MainActor.run { list.addMolecules(moleculesToAdd.0, indexPath: indexPath, animation: model.animation) } - return true - } else if model.actionType == RemoveMoleculesActionModel.identifier { - guard let model = model as? RemoveMoleculesActionModel, + } else if let model = model as? RemoveMoleculesActionModel, let list = delegate?.moleculeListDelegate, let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & RemoveMolecules), - let moleculesToRemove = sourceModel.getRecursiveMoleculesToRemove() else { return true } - DispatchQueue.main.async { + let moleculesToRemove = sourceModel.getRecursiveMoleculesToRemove() { + await MainActor.run { list.removeMolecules(moleculesToRemove, animation: model.animation) } - return true } - return false } } diff --git a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift index 0245fd7c..3420299d 100644 --- a/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift +++ b/MVMCoreUI/Behaviors/Protocols/PageBehaviorProtocol.swift @@ -6,6 +6,8 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // +import MVMCore + public protocol PageBehaviorProtocol: ModelHandlerProtocol { @@ -65,12 +67,14 @@ public protocol PageLocalDataShareBehavior: PageBehaviorProtocol { } public protocol PageCustomActionHandlerBehavior: PageBehaviorProtocol { + + /// Returns if this behavior can handle the action. + func canHandleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool /// - Parameters: /// - model: The action model. /// - additionalData: Additional information of the - /// - Returns: Boolean determines if the action has been handled. - func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) -> Bool + func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) async throws } public extension MVMCoreUIDelegateObject { diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 2d1ab302..6ef2b8d0 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -170,19 +170,15 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, requestParameters.tabWasPressed = true return requestParameters } - - open override func getRequestParameters(for model: ActionOpenPageModel, delegateObject: DelegateObject? = nil, additionalData: [AnyHashable : Any]? = nil) throws -> (MVMCoreRequestParameters, [AnyHashable : Any]?) { - let value = try super.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) - var requestParameters = value.0 - let additionalData = value.1 - guard let additionalData = additionalData, - additionalData.boolForKey("tabBarPressed") else { - // Pass to delegate - return try (viewController as? ActionOpenPageDelegateProtocol)?.getRequestParameters(for: model, delegateObject: delegateObject, additionalData: additionalData) ?? value - } - // Allow opportunity to modify parameters. - requestParameters = getRequestParametersForNewTabLoad(requestParameters: requestParameters, model: model, additionalData: additionalData) - return (requestParameters, additionalData) + + open override func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { + if let model = model as? ActionOpenPageModel, + let additionalData = additionalData, + additionalData.boolForKey("tabBarPressed") { + // Allow opportunity to modify parameters. + model.requestParameters = getRequestParametersForNewTabLoad(requestParameters: model.requestParameters, model: model, additionalData: additionalData) + } + try await super.performAction(with: model, additionalData: additionalData, delegateObject: delegateObject) } // MARK: - MVMCorePresentationDelegateProtocol @@ -277,7 +273,9 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { // Perform the tab action - MVMCoreUIActionHandler.asyncHandleActionCheckingDelegate(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) + Task(priority: .userInitiated) { + try await (delegateObjectIVar.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) + } } return false } From 31169e318ed33ee4a6dc5e74273411096b6fe2a6 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 11 Aug 2022 22:34:37 -0400 Subject: [PATCH 13/17] bug fixes --- MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift | 2 +- MVMCoreUI/BaseControllers/ViewController.swift | 2 +- MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 2 +- MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift | 5 +++++ MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift | 3 +++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 4f4801c6..8818107b 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -210,7 +210,7 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat if let style = try typeContainer.decodeIfPresent(Styler.Button.Style.self, forKey: .style){ self.style = style setFacade(by: style) - } else if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style { ///Reading the style param from context which is set is molecules, ex: TwoButtonView + } else if let style = decoder.context?.value(forKey: CodingKeys.style.stringValue) as? Styler.Button.Style { ///Reading the style param from context which is set is molecules, ex: TwoButtonView self.style = style setFacade(by: style) } else { ///Default style diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index e0de37f1..09ae06c8 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -460,7 +460,7 @@ import MVMCore do { if let behavior = behaviors?.compactMap({ $0 as? PageCustomActionHandlerBehavior }).first(where: { $0.canHandleAction(with: model, additionalData: additionalData) }) { - delegateObject?.actionDelegate?.logAction?(withActionInformation: model.toJSON(), additionalData: additionalData) + logAction(withActionInformation: model.toJSON(), additionalData: additionalData) try await behavior.handleAction(with: model, additionalData: additionalData) } else { try await MVMCoreUIActionHandler.shared()?.handleAction(with: model, additionalData: additionalData, delegateObject: delegateObject) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 6ef2b8d0..e8660a51 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -155,7 +155,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Logs the action for the selected tab. open func trackSelectTab() { guard let action = tabs.tabsModel?.tabs[tabs.selectedIndex].action else { return } - MVMCoreUIActionHandler.shared()?.logAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) + MVMCoreUIActionHandler.shared()?.logAction(with: action.toJSON(), additionalData: getAdditionalDataForNewTabLoad(indexPath: IndexPath(row: tabs.selectedIndex, section: 0)), delegateObject: delegateObjectIVar) } /// Allow override of additioonal data for tab press action diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift index 230e7978..f4f0461a 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift @@ -25,6 +25,11 @@ import SafariServices } } + open override func logAction(with JSON: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { + // Legacy logging. + delegateObject?.actionDelegate?.logAction?(withActionInformation: JSON, additionalData: additionalData) ?? MVMCoreUILoggingHandler.shared()?.defaultLogAction(forController: nil, actionInformation: JSON, additionalData: additionalData) + } + @objc(openURLInSafariWebView:) @MainActor open func openURL(inSafariWebView url: URL) { diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index d7747383..0ae1e879 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -7,6 +7,7 @@ // import Foundation +import MVMCore /// Allows top alerts to determine the status bar color and style. protocol StatusBarUI { @@ -138,3 +139,5 @@ public extension MVMCoreUITopAlertView { } } } + +extension MVMCoreUITopAlertView: ActionDelegateProtocol {} From 78034bb8d09c398f4b7aad8942decb9afef771c8 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Fri, 12 Aug 2022 16:17:05 -0400 Subject: [PATCH 14/17] Centralize SoureModel --- .../Atomic/Actions/ActionPopupHandler.swift | 6 ++-- .../MVMCoreUIActionOpenPageHandler.swift | 4 +-- .../BaseDropdownEntryField.swift | 6 +--- .../Atomic/Atoms/Selectors/Checkbox.swift | 5 +-- MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift | 9 ++--- .../Atomic/Atoms/Views/Label/Label.swift | 4 +-- .../HorizontalCombinationViews/Tabs.swift | 4 +-- .../AccordionMoleculeTableViewCell.swift | 12 ++----- .../Items/DropDownFilterTableViewCell.swift | 5 +-- .../Molecules/Items/TabsTableViewCell.swift | 12 ++----- .../TopNotification/NotificationXButton.swift | 4 +-- .../Templates/ModalMoleculeListTemplate.swift | 4 +-- .../ModalMoleculeStackTemplate.swift | 4 +-- .../Templates/ModalSectionListTemplate.swift | 4 +-- MVMCoreUI/BaseClasses/BarButtonItem.swift | 3 +- MVMCoreUI/BaseClasses/Button.swift | 6 +--- .../BaseControllers/ViewController.swift | 2 +- .../Behaviors/AddRemoveMoleculeBehavior.swift | 4 +-- .../SubNav/SubNavManagerController.swift | 10 +++--- .../MVMCoreUIActionHandler.swift | 34 +++++++++++++++---- 20 files changed, 58 insertions(+), 84 deletions(-) diff --git a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift index 9fe86eef..554a000a 100644 --- a/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift +++ b/MVMCoreUI/Atomic/Actions/ActionPopupHandler.swift @@ -23,10 +23,8 @@ open class ActionPopupHandler: MVMCoreActionHandlerProtocol { return } (delegateObject?.actionDelegate as? MVMCoreUIActionDelegateProtocol)?.willShowPopup(with: alertObject, alertJson: json!) - Task { - _ = await MainActor.run { - MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) - } + Task { @MainActor in + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) continuation.resume() } }) diff --git a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift index 5de3ed27..9e0187e6 100644 --- a/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift +++ b/MVMCoreUI/Atomic/Actions/MVMCoreUIActionOpenPageHandler.swift @@ -12,8 +12,6 @@ import MVMCore open class MVMCoreUIActionOpenPageHandler: ActionOpenPageHandler { open override func performAction(with JSON: [AnyHashable : Any], model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws { // Cleanup the source model data to prevent it from being accidentally auto-forwarded in openPage network requests by blind additionalData insertions. (https://onejira.verizon.com/browse/CXTDT-135642, https://onejira.verizon.com/browse/CXTDT-136001). - var additionalData = additionalData - additionalData?.removeValue(forKey: KeySourceModel) - try await super.performAction(with: JSON, model: model, delegateObject: delegateObject, additionalData: additionalData) + try await super.performAction(with: JSON, model: model, delegateObject: delegateObject, additionalData: MVMCoreUIActionHandler.removeSourceModel(from: additionalData)) } } diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift index 8fa985c7..172f304d 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/Dropdown Fields/BaseDropdownEntryField.swift @@ -98,10 +98,6 @@ import MVMCore guard let baseDropdownEntryFieldModel = baseDropdownEntryFieldModel, let actionModel = baseDropdownEntryFieldModel.action else { return } - - let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: baseDropdownEntryFieldModel) - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: additionalDataWithSource, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: actionModel, sourceModel: baseDropdownEntryFieldModel, additionalData: additionalData, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift index fc6427b3..9efc554a 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Checkbox.swift @@ -389,10 +389,7 @@ import MVMCore } private func performCheckboxAction(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { - let additionalDataToUpdate = (checkboxModel != nil) ? additionalData.dictionaryAdding(key: KeySourceModel, value: checkboxModel!) : additionalData - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: additionalDataToUpdate, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: actionModel, sourceModel: checkboxModel, additionalData: additionalData, delegateObject: delegateObject) } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 9c1f91ca..85ad8e9c 100644 --- a/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -390,21 +390,16 @@ public typealias ActionBlockConfirmation = () -> (Bool) accessibilityLabel = accessibileString } - let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: model) if model.action != nil || model.alternateAction != nil { didToggleAction = { [weak self] in guard let self = self else { return } if self.isOn { if let action = model.action { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } } else { if let action = model.alternateAction ?? model.action { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: additionalDataWithSource, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 9723f18d..1beb6069 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -387,9 +387,7 @@ public typealias ActionBlock = () -> () } case let actionAtt as LabelAttributeActionModel: addTappableLinkAttribute(range: NSRange(location: range.location, length: range.length)) { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionAtt.action, additionalData: additionalData, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: actionAtt.action, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } addActionAttributes(range: range, string: attributedString) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 66a4b263..de9ef49f 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -259,9 +259,7 @@ extension Tabs: UICollectionViewDelegateFlowLayout { if let delegate = delegate { delegate.didSelectItem(indexPath, tabs: self) } else if let action = tabsModel.tabs[selectedIndex].action { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: [KeySourceModel: tabsModel], delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: tabsModel, additionalData: nil, delegateObject: delegateObject) } if UIAccessibility.isVoiceOverRunning { UIAccessibility.post(notification: .layoutChanged, argument: tabCell) diff --git a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift index 12916ac3..f8832ad5 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/AccordionMoleculeTableViewCell.swift @@ -46,13 +46,9 @@ public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { model.selected = accordionButton.isSelected if accordionButton.isSelected { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: AddMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: AddMoleculesActionModel(.automatic), sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } else { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: RemoveMoleculesActionModel(.automatic), additionalData: [KeySourceModel: model], delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: RemoveMoleculesActionModel(.automatic), sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } if (accordionListItemModel?.hideLineWhenExpanded ?? false) && (self.bottomSeparatorView?.shouldBeVisible() ?? false) { @@ -60,9 +56,7 @@ public class AccordionMoleculeTableViewCell: MoleculeTableViewCell { } if let actionModel = accordionButton.isSelected ? accordionListItemModel?.expandAction : accordionListItemModel?.collapseAction { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionModel, additionalData: [KeySourceModel: model], delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: actionModel, sourceModel: model, additionalData: additionalData, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index 70122918..bec86c0b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -28,7 +28,6 @@ import UIKit let self = self, let model = self.listItemModel as? DropDownListItemModel else { return } - let additionData = [KeySourceModel: model] var actions: [ActionModelProtocol] = [] if let oldValue = oldValue, oldValue.count > 0 { @@ -37,9 +36,7 @@ import UIKit actions.append(AddMoleculesActionModel(.fade)) let actionsModel = ActionActionsModel(actions: actions) actionsModel.concurrent = false - Task(priority: .userInitiated) { - try await (self.delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: actionsModel, additionalData: additionData, delegateObject: self.delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: actionsModel, sourceModel: model, additionalData: nil, delegateObject: self.delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift index b7f76f2b..6a941881 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/TabsTableViewCell.swift @@ -57,9 +57,7 @@ extension TabsTableViewCell: TabsDelegate { public func shouldSelectItem(_ indexPath: IndexPath, tabs: Tabs) -> Bool { guard indexPath.row != tabs.selectedIndex else { return false } if let model = tabsListItemModel { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), additionalData: [KeySourceModel: model], delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: RemoveMoleculesActionModel(indexPath.row < tabs.selectedIndex ? .right : .left), sourceModel: model, additionalData: nil, delegateObject: delegateObject) } previousTabIndex = tabs.selectedIndex return true @@ -70,13 +68,9 @@ extension TabsTableViewCell: TabsDelegate { guard let model = tabsListItemModel, index < model.molecules.count else { return } if let action = model.tabs.tabs[index].action { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: [KeySourceModel: model.tabs], delegateObject: delegateObject) - } - } - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), additionalData: [KeySourceModel: model], delegateObject: delegateObject) + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: model.tabs, additionalData: nil, delegateObject: delegateObject) } + MVMCoreUIActionHandler.performActionUnstructured(with: AddMoleculesActionModel(index < previousTabIndex ? .left : .right), sourceModel: model, additionalData: nil, delegateObject: delegateObject) } } diff --git a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift index f6d6a5f6..d0071668 100644 --- a/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift +++ b/MVMCoreUI/Atomic/Molecules/TopNotification/NotificationXButton.swift @@ -12,9 +12,7 @@ import MVMCore @objcMembers open class NotificationXButton: Button { open func closeTopAlert(with delegateObject: MVMCoreUIDelegateObject?) { - Task(priority: .userInitiated) { - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: ActionDismissNotificationModel(), additionalData: nil, delegateObject: delegateObject) - } + MVMCoreUIActionHandler.performActionUnstructured(with: ActionDismissNotificationModel(), sourceModel: model, additionalData: nil, delegateObject: delegateObject) } open override func setupView() { diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift index 01a0b49e..656d5086 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeListTemplate.swift @@ -32,9 +32,7 @@ open class ModalMoleculeListTemplate: MoleculeListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalListPageTemplateModel)?.closeAction ?? ActionBackModel() - Task(priority: .userInitiated) { - try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) - } + MVMCoreUIActionHandler.performActionUnstructured(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) }) } diff --git a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift index 00f125d8..97aced2a 100644 --- a/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalMoleculeStackTemplate.swift @@ -29,9 +29,7 @@ open class ModalMoleculeStackTemplate: MoleculeStackTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalStackPageTemplateModel)?.closeAction ?? ActionBackModel() - Task(priority: .userInitiated) { - try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) - } + MVMCoreUIActionHandler.performActionUnstructured(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) }) } } diff --git a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift index c5fbb6be..baf8d78a 100644 --- a/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/ModalSectionListTemplate.swift @@ -27,9 +27,7 @@ open class ModalSectionListTemplate: SectionListTemplate { guard let self = self else { return } let closeAction = (self.templateModel as? ModalSectionListTemplateModel)?.closeAction ?? ActionBackModel() - Task(priority: .userInitiated) { - try await (self.delegateObject()?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) - } + MVMCoreUIActionHandler.performActionUnstructured(with: closeAction, additionalData: nil, delegateObject: self.delegateObject()) }) } } diff --git a/MVMCoreUI/BaseClasses/BarButtonItem.swift b/MVMCoreUI/BaseClasses/BarButtonItem.swift index c360b457..d759b147 100644 --- a/MVMCoreUI/BaseClasses/BarButtonItem.swift +++ b/MVMCoreUI/BaseClasses/BarButtonItem.swift @@ -32,9 +32,8 @@ public typealias BarButtonAction = (BarButtonItem) -> () self.model = model buttonDelegate = delegateObject?.buttonDelegate actionDelegate?.buttonAction = { sender in - let additionalDataWithSource = additionalData.dictionaryAdding(key: KeySourceModel, value: model) Task(priority: .userInitiated) { - try await Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalDataWithSource) + try await Button.performButtonAction(with: model.action, button: sender, delegateObject: delegateObject, additionalData: additionalData, sourceModel: model) } } } diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index 1b62a741..15ea1e03 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -88,11 +88,7 @@ public typealias ButtonAction = (Button) -> () open class func performButtonAction(with model: ActionModelProtocol, button: MFButtonProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, sourceModel: MoleculeModelProtocol? = nil) async throws { guard delegateObject?.buttonDelegate?.button?(button, shouldPerformActionWithMap: model.toJSON(), additionalData: additionalData) ?? true else { return } - var additionalData = additionalData - if let sourceModel = sourceModel { - additionalData = additionalData.dictionaryAdding(key: KeySourceModel, value: sourceModel) - } - try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model, additionalData: additionalData, delegateObject: delegateObject) + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model, additionalData: MVMCoreUIActionHandler.add(sourceModel: sourceModel, to: additionalData), delegateObject: delegateObject) } // MARK:- MoleculeViewProtocol diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 09ae06c8..c0e8c832 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -419,7 +419,7 @@ import MVMCore /// Override this method to avoid adding form params. open func addFormParams(requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, additionalData: [AnyHashable: Any]?) { - formValidator?.addFormParams(requestParameters: requestParameters, model: additionalData?[KeySourceModel] as? MoleculeModelProtocol & FormItemProtocol) + formValidator?.addFormParams(requestParameters: requestParameters, model: MVMCoreUIActionHandler.getSourceModel(from: additionalData) as? MoleculeModelProtocol & FormItemProtocol) } public func handleFieldErrors(_ fieldErrors: [Any]?, loadObject: MVMCoreLoadObject) { diff --git a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift index 75171d73..ed9b8196 100644 --- a/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift +++ b/MVMCoreUI/Behaviors/AddRemoveMoleculeBehavior.swift @@ -93,7 +93,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo public func handleAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?) async throws { if let model = model as? AddMoleculesActionModel, let list = delegate?.moleculeListDelegate, - let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), + let sourceModel = MVMCoreUIActionHandler.getSourceModel(from: additionalData) as? (ListItemModelProtocol & MoleculeModelProtocol & AddMolecules), let moleculesToAdd = sourceModel.getRecursiveMoleculesToAdd(), let indexPath = list.getAdjustedIndexPath(for: sourceModel, position: moleculesToAdd.1) { await MainActor.run { @@ -101,7 +101,7 @@ public class AddRemoveMoleculesBehavior: PageCustomActionHandlerBehavior, PageMo } } else if let model = model as? RemoveMoleculesActionModel, let list = delegate?.moleculeListDelegate, - let sourceModel = additionalData?[KeySourceModel] as? (ListItemModelProtocol & MoleculeModelProtocol & RemoveMolecules), + let sourceModel = MVMCoreUIActionHandler.getSourceModel(from: additionalData) as? (ListItemModelProtocol & MoleculeModelProtocol & RemoveMolecules), let moleculesToRemove = sourceModel.getRecursiveMoleculesToRemove() { await MainActor.run { list.removeMolecules(moleculesToRemove, animation: model.animation) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index e8660a51..6e0a6712 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -145,7 +145,9 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open func shouldContinue(toErrorPage loadObject: MVMCoreLoadObject, error: MVMCoreErrorObject?) -> Bool { // Push error screens so they do not replace the tab page. - loadObject.requestParameters?.navigationController = navigationController + MVMCoreDispatchUtility.performSyncBlock(onMainThread: { + loadObject.requestParameters?.navigationController = self.navigationController + }) loadObject.requestParameters?.loadStyle = .push return true } @@ -160,7 +162,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, /// Allow override of additioonal data for tab press action open func getAdditionalDataForNewTabLoad(indexPath: IndexPath) -> [AnyHashable: Any]? { - return ["tabBarPressed": true, KeySourceModel: tabsModel] + return MVMCoreUIActionHandler.add(sourceModel: tabsModel, to: ["tabBarPressed": true]) } /// Allows modification of requestParameters object for openPage request @@ -273,9 +275,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } else if let tabsModel = tabs.tabsModel, let action = tabsModel.tabs[indexPath.row].action { // Perform the tab action - Task(priority: .userInitiated) { - try await (delegateObjectIVar.actionDelegate as? ActionDelegateProtocol)?.performAction(with: action, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObjectIVar) - } + MVMCoreUIActionHandler.performActionUnstructured(with: action, sourceModel: tabsModel, additionalData: getAdditionalDataForNewTabLoad(indexPath: indexPath), delegateObject: delegateObject()) } return false } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift index f4f0461a..24d57f8d 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.swift @@ -12,16 +12,38 @@ import SafariServices @objc open class MVMCoreUIActionHandler: MVMCoreActionHandler { + /// Adds the source model to the additionalData + public static func add(sourceModel: MoleculeModelProtocol?, to additionalData: [AnyHashable: Any]?) -> [AnyHashable: Any]? { + guard let sourceModel = sourceModel else { return additionalData } + return additionalData.dictionaryAdding(key: KeySourceModel, value: sourceModel) + } + + /// Gets the source model from the additionalData + public static func getSourceModel(from additionalData: [AnyHashable: Any]?) -> MoleculeModelProtocol? { + return additionalData?[KeySourceModel] as? MoleculeModelProtocol + } + + /// Removes the source model to the additionalData + public static func removeSourceModel(from additionalData: [AnyHashable: Any]?) -> [AnyHashable: Any]? { + guard var additionalData = additionalData else { return nil } + additionalData.removeValue(forKey: KeySourceModel) + return additionalData + } + + /// Starts the action in a task, adding the source model. + public static func performActionUnstructured(with model: ActionModelProtocol, sourceModel: MoleculeModelProtocol? = nil, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) { + Task(priority: .userInitiated) { + try await (delegateObject?.actionDelegate as? ActionDelegateProtocol)?.performAction(with: model, additionalData: MVMCoreUIActionHandler.add(sourceModel: sourceModel, to: additionalData), delegateObject: delegateObject) + } + } + /// Logs the error and shows a popup if the error is not silent. open override func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable : Any]?) { super.defaultHandleActionError(error, additionalData: additionalData) guard !error.silentError else { return } - Task(priority: .userInitiated) { - await MainActor.run { - // Show alert - let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)! - MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) - } + Task(priority: .userInitiated) { @MainActor in + let alertObject = MVMCoreAlertObject.init(popupAlertWithError: error, isGreedy: false)! + MVMCoreAlertHandler.shared()?.showAlert(with: alertObject) } } From 36df641ce1442b74a19ec575ea6d57d0eed548ff Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 15 Aug 2022 12:16:57 -0400 Subject: [PATCH 15/17] cleanup --- MVMCoreUI/BaseControllers/ViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index c0e8c832..c6c64f3a 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -418,7 +418,7 @@ import MVMCore } /// Override this method to avoid adding form params. - open func addFormParams(requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, additionalData: [AnyHashable: Any]?) { + open func addFormParams(requestParameters: MVMCoreRequestParameters, additionalData: [AnyHashable: Any]?) { formValidator?.addFormParams(requestParameters: requestParameters, model: MVMCoreUIActionHandler.getSourceModel(from: additionalData) as? MoleculeModelProtocol & FormItemProtocol) } @@ -447,7 +447,7 @@ import MVMCore open func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { var additionalData = additionalData if let model = model as? ActionOpenPageModel { - addFormParams(requestParameters: model.requestParameters, model: model, additionalData: additionalData) + addFormParams(requestParameters: model.requestParameters, additionalData: additionalData) model.requestParameters.parentPageType = loadObject?.pageJSON?.optionalStringForKey("parentPageType") var pageForwardedData = additionalData ?? [:] From c75e3fb92c26d624455237e21382de2c32e272fe Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 15 Aug 2022 15:30:51 -0400 Subject: [PATCH 16/17] Version Bump --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 7b1bfd19..3e7cca54 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -3369,7 +3369,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0; + MARKETING_VERSION = 2.1; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -3400,7 +3400,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.0; + MARKETING_VERSION = 2.1; PRODUCT_BUNDLE_IDENTIFIER = com.vzw.MVMCoreUI; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; From 39d42515c6f01105ad9b1d2897d87c34bc451c40 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 15 Aug 2022 17:53:29 -0400 Subject: [PATCH 17/17] typo fixes --- .../Molecules/Items/DropDownFilterTableViewCell.swift | 2 +- .../Managers/SubNav/SubNavManagerController.swift | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift index bec86c0b..663a53fa 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/DropDownFilterTableViewCell.swift @@ -34,7 +34,7 @@ import UIKit actions.append(RemoveMoleculesActionModel(.fade)) } actions.append(AddMoleculesActionModel(.fade)) - let actionsModel = ActionActionsModel(actions: actions) + var actionsModel = ActionActionsModel(actions: actions) actionsModel.concurrent = false MVMCoreUIActionHandler.performActionUnstructured(with: actionsModel, sourceModel: model, additionalData: nil, delegateObject: self.delegateObject) } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 6e0a6712..db339cf8 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -174,12 +174,13 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, } open override func performAction(with model: ActionModelProtocol, additionalData: [AnyHashable : Any]?, delegateObject: DelegateObject?) async throws { - if let model = model as? ActionOpenPageModel, + guard var model = model as? ActionOpenPageModel, let additionalData = additionalData, - additionalData.boolForKey("tabBarPressed") { - // Allow opportunity to modify parameters. - model.requestParameters = getRequestParametersForNewTabLoad(requestParameters: model.requestParameters, model: model, additionalData: additionalData) - } + additionalData.boolForKey("tabBarPressed") else { + return try await super.performAction(with: model, additionalData: additionalData, delegateObject: delegateObject) + } + // Allow opportunity to modify parameters. + model.requestParameters = getRequestParametersForNewTabLoad(requestParameters: model.requestParameters, model: model, additionalData: additionalData) try await super.performAction(with: model, additionalData: additionalData, delegateObject: delegateObject) }