From 213e0d2ce0203bd8d4880d72eae8741563b4d8a2 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 29 Oct 2020 11:16:48 -0400 Subject: [PATCH] Changes for file movement --- MVMCoreUI.xcodeproj/project.pbxproj | 42 +++-- .../Alerts/MVMCoreAlertDelegateProtocol.h | 10 +- MVMCoreUI/Alerts/MVMCoreAlertHandler.h | 4 +- MVMCoreUI/Alerts/MVMCoreAlertHandler.m | 8 +- MVMCoreUI/Alerts/MVMCoreAlertObject.h | 2 +- MVMCoreUI/Alerts/MVMCoreAlertObject.m | 28 +-- MVMCoreUI/Alerts/MVMCoreAlertOperation.h | 4 +- MVMCoreUI/Alerts/MVMCoreAlertOperation.m | 6 +- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 2 + .../MVMCoreUISplitViewController.m | 5 +- MVMCoreUI/MVMCoreUI.h | 14 ++ MVMCoreUI/OtherHandlers/CoreUIObject.swift | 1 + .../MVMCoreUIActionDelegateProtocol.h | 19 ++ .../OtherHandlers/MVMCoreUIActionHandler.h | 40 +++++ .../OtherHandlers/MVMCoreUIActionHandler.m | 164 ++++++++++++++++++ .../MVMCoreUIDelegateObject.swift | 4 + .../MVMCoreGlobalTopAlertDelegateProtocol.h | 2 +- MVMCoreUI/TopAlert/MVMCoreTopAlertObject.h | 2 +- MVMCoreUI/TopAlert/MVMCoreTopAlertObject.m | 5 +- .../TopAlert/MVMCoreTopAlertViewProtocol.h | 2 +- .../TopAlert/MVMCoreUITopAlertBaseView.h | 2 +- .../TopAlert/MVMCoreUITopAlertBaseView.m | 3 +- .../MVMCoreUITopAlertExpandableView.h | 2 +- .../MVMCoreUITopAlertExpandableView.m | 4 +- .../TopAlert/MVMCoreUITopAlertMainView.h | 2 +- .../TopAlert/MVMCoreUITopAlertMainView.m | 4 +- .../MVMCoreUITopAlertView+Extension.swift | 10 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h | 4 +- MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m | 10 +- MVMCoreUI/Utility/MVMCoreUIConstants.h | 5 + MVMCoreUI/Utility/MVMCoreUIConstants.m | 4 + 31 files changed, 350 insertions(+), 64 deletions(-) create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionDelegateProtocol.h create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h create mode 100644 MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 5ee5ca5b..13ddbef7 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -506,23 +506,26 @@ D2ED27ED254B0CE700A1C293 /* ActionPopupModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27E8254B0CE600A1C293 /* ActionPopupModel.swift */; }; D2ED27EE254B0CE700A1C293 /* ActionAlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27E9254B0CE600A1C293 /* ActionAlertModel.swift */; }; D2ED27EF254B0CE700A1C293 /* AlertModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27EA254B0CE700A1C293 /* AlertModel.swift */; }; - D2ED27FB254B0E0300A1C293 /* MVMCoreAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F2254B0E0200A1C293 /* MVMCoreAlertDelegateProtocol.h */; }; + D2ED27FB254B0E0300A1C293 /* MVMCoreAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F2254B0E0200A1C293 /* MVMCoreAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED27FC254B0E0300A1C293 /* MVMCoreAlertObject+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27F3254B0E0200A1C293 /* MVMCoreAlertObject+Swift.swift */; }; D2ED27FD254B0E0300A1C293 /* MVMCoreAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27F4254B0E0200A1C293 /* MVMCoreAlertOperation.m */; }; - D2ED27FE254B0E0300A1C293 /* MVMCoreAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F5254B0E0200A1C293 /* MVMCoreAlertObject.h */; }; - D2ED27FF254B0E0300A1C293 /* MVMCoreAlertHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F6254B0E0200A1C293 /* MVMCoreAlertHandler.h */; }; + D2ED27FE254B0E0300A1C293 /* MVMCoreAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F5254B0E0200A1C293 /* MVMCoreAlertObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D2ED27FF254B0E0300A1C293 /* MVMCoreAlertHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F6254B0E0200A1C293 /* MVMCoreAlertHandler.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED2800254B0E0300A1C293 /* MVMCoreAlertHandler+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27F7254B0E0200A1C293 /* MVMCoreAlertHandler+Extension.swift */; }; - D2ED2801254B0E0300A1C293 /* MVMCoreAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F8254B0E0200A1C293 /* MVMCoreAlertOperation.h */; }; + D2ED2801254B0E0300A1C293 /* MVMCoreAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED27F8254B0E0200A1C293 /* MVMCoreAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED2802254B0E0300A1C293 /* MVMCoreAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27F9254B0E0200A1C293 /* MVMCoreAlertObject.m */; }; D2ED2803254B0E0300A1C293 /* MVMCoreAlertHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED27FA254B0E0300A1C293 /* MVMCoreAlertHandler.m */; }; - D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2805254B0EB700A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h */; }; - D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2806254B0EB700A1C293 /* MVMCoreTopAlertOperation.h */; }; + D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2805254B0EB700A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2806254B0EB700A1C293 /* MVMCoreTopAlertOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED280E254B0EB800A1C293 /* MVMCoreTopAlertOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED2807254B0EB700A1C293 /* MVMCoreTopAlertOperation.m */; }; - D2ED280F254B0EB800A1C293 /* MVMCoreTopAlertViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2808254B0EB700A1C293 /* MVMCoreTopAlertViewProtocol.h */; }; - D2ED2810254B0EB800A1C293 /* MVMCoreTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2809254B0EB700A1C293 /* MVMCoreTopAlertDelegateProtocol.h */; }; - D2ED2811254B0EB800A1C293 /* MVMCoreTopAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED280A254B0EB700A1C293 /* MVMCoreTopAlertObject.h */; }; + D2ED280F254B0EB800A1C293 /* MVMCoreTopAlertViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2808254B0EB700A1C293 /* MVMCoreTopAlertViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D2ED2810254B0EB800A1C293 /* MVMCoreTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2809254B0EB700A1C293 /* MVMCoreTopAlertDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D2ED2811254B0EB800A1C293 /* MVMCoreTopAlertObject.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED280A254B0EB700A1C293 /* MVMCoreTopAlertObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; D2ED2812254B0EB800A1C293 /* MVMCoreTopAlertObject.m in Sources */ = {isa = PBXBuildFile; fileRef = D2ED280B254B0EB800A1C293 /* MVMCoreTopAlertObject.m */; }; - D2ED2815254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D2ED2814254B0EE400A1C293 /* MVMCoreGlobalTopAlertDelegateProtocol.h */; }; + 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 */; }; @@ -1058,6 +1061,9 @@ D2ED280A254B0EB700A1C293 /* MVMCoreTopAlertObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreTopAlertObject.h; sourceTree = ""; }; 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 = ""; }; @@ -2045,6 +2051,9 @@ D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */, D2092352244F7D630044AD09 /* MVMCoreUIViewControllerMappingObject+Extension.swift */, D296E14622A597490051EBE7 /* MVMCoreUIViewConstrainingProtocol.h */, + D2ED2817254B112900A1C293 /* MVMCoreUIActionDelegateProtocol.h */, + D2ED281B254B119D00A1C293 /* MVMCoreUIActionHandler.h */, + D2ED281C254B119D00A1C293 /* MVMCoreUIActionHandler.m */, ); path = OtherHandlers; sourceTree = ""; @@ -2262,18 +2271,14 @@ 9458C3172406C8FD00930963 /* UIFont+FontWrapping.h in Headers */, D29DF0D121E404D4003B2FB9 /* MVMCoreUI.h in Headers */, D29DF11521E6805F003B2FB9 /* UIColor+MFConvenience.h in Headers */, - D2ED2811254B0EB800A1C293 /* MVMCoreTopAlertObject.h in Headers */, D29DF25921E6A22D003B2FB9 /* MFButtonProtocol.h in Headers */, D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */, - D2ED27FE254B0E0300A1C293 /* MVMCoreAlertObject.h in Headers */, D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */, D29DF12A21E6851E003B2FB9 /* MVMCoreUITopAlertView.h in Headers */, - D2ED280F254B0EB800A1C293 /* MVMCoreTopAlertViewProtocol.h in Headers */, D29DF27521E79E81003B2FB9 /* MVMCoreUILoggingHandler.h in Headers */, D29DF2B321E7B76D003B2FB9 /* MFLoadingSpinner.h in Headers */, D20492A424329A2800A5EED6 /* MVMCoreUIPagingProtocol.h in Headers */, D296E14722A5984C0051EBE7 /* MVMCoreUIViewConstrainingProtocol.h in Headers */, - D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */, D29DF17521E69E1F003B2FB9 /* ButtonDelegateProtocol.h in Headers */, D29DF26E21E6AA0B003B2FB9 /* FLAnimatedImage.h in Headers */, D29DF11621E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.h in Headers */, @@ -2281,11 +2286,16 @@ D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */, D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */, D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */, - D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */, D29DF2EE21ECEADF003B2FB9 /* MFFonts.h in Headers */, D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */, D2C5001821F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h in Headers */, + D2ED2811254B0EB800A1C293 /* MVMCoreTopAlertObject.h in Headers */, + D2ED27FE254B0E0300A1C293 /* MVMCoreAlertObject.h in Headers */, + D2ED280F254B0EB800A1C293 /* MVMCoreTopAlertViewProtocol.h in Headers */, + D2ED280C254B0EB800A1C293 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */, + D2ED280D254B0EB800A1C293 /* MVMCoreTopAlertOperation.h in Headers */, D2ED2801254B0E0300A1C293 /* MVMCoreAlertOperation.h in Headers */, + D2ED2818254B115400A1C293 /* MVMCoreUIActionDelegateProtocol.h in Headers */, D2ED27FB254B0E0300A1C293 /* MVMCoreAlertDelegateProtocol.h in Headers */, D2ED2810254B0EB800A1C293 /* MVMCoreTopAlertDelegateProtocol.h in Headers */, D2ED27FF254B0E0300A1C293 /* MVMCoreAlertHandler.h in Headers */, @@ -2295,6 +2305,7 @@ 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; @@ -2700,6 +2711,7 @@ 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/Alerts/MVMCoreAlertDelegateProtocol.h b/MVMCoreUI/Alerts/MVMCoreAlertDelegateProtocol.h index f4f05e5d..1b8d65c1 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertDelegateProtocol.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertDelegateProtocol.h @@ -9,6 +9,8 @@ #import @class MVMCoreAlertObject; +@class MVMCoreLoadObject; +@class MVMCoreErrorObject; @protocol MVMCoreAlertDelegateProtocol @@ -24,5 +26,11 @@ - (void)alertPaused:(nonnull UIAlertController *)alertController; - (void)alertUnpaused:(nonnull UIAlertController *)alertController; -@end +/** Get the alert object whose data will be presented. Overwrite this to alter how you want the alert to show. + * @param loadObject The load object. + * @param errorObject An error object if there was an error. + * @return Returns the alert object. + * Details: Gets the alert that will display to the screen. Easier to subclass here to avoid subclassing the displaying logic. */ +- (nullable MVMCoreAlertObject *)alertObjectToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)errorObject; +@end diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h index bba77410..f3b30efd 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h @@ -9,8 +9,8 @@ #import #import -#import -#import +#import +#import @class MVMCoreAlertObject; @class MVMCoreTopAlertOperation; diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m index dce4056b..4e7be1f7 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m @@ -8,12 +8,12 @@ #import "MVMCoreAlertHandler.h" #import "MVMCoreAlertObject.h" -#import "MVMCoreAlertController.h" +#import #import "MVMCoreAlertOperation.h" #import "MVMCoreTopAlertOperation.h" -#import "MVMCoreJSONConstants.h" -#import "NSDictionary+MFConvenience.h" -#import "NSArray+MFConvenience.h" +#import +#import +#import #import @interface MVMCoreAlertHandler () diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.h b/MVMCoreUI/Alerts/MVMCoreAlertObject.h index 161e123a..87c5050a 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.h @@ -11,7 +11,7 @@ #import #import #import -#import +#import @class MVMCoreErrorObject; @class MVMCoreLoadObject; diff --git a/MVMCoreUI/Alerts/MVMCoreAlertObject.m b/MVMCoreUI/Alerts/MVMCoreAlertObject.m index c8deb7a6..975c9540 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertObject.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertObject.m @@ -9,16 +9,17 @@ #import "MVMCoreAlertObject.h" #import "MVMCoreAlertHandler.h" #import "MVMCoreTopAlertObject.h" -#import "MVMCoreCache.h" -#import "MVMCoreErrorConstants.h" -#import "MVMCoreErrorObject.h" -#import "MVMCoreLoadObject.h" -#import "MVMCoreGetterUtility.h" -#import "NSDictionary+MFConvenience.h" -#import "MVMCoreHardcodedStringsConstants.h" -#import "MVMCoreJSONConstants.h" +#import +#import +#import +#import +#import +#import +#import +#import #import #import +#import @interface MVMCoreAlertObject () @@ -47,6 +48,10 @@ } + (nullable instancetype)alertObjectForPageType:(nullable NSString *)pageType responseInfo:(nullable NSDictionary *)responseInfo additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject { + MVMCoreUIDelegateObject *alertDelegateObject = nil; + if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) { + alertDelegateObject = (MVMCoreUIDelegateObject *)delegateObject; + } __block MVMCoreAlertObject *alert = [[MVMCoreAlertObject alloc] init]; alert.title = [responseInfo stringForKey:KeyErrorHeading]; @@ -64,7 +69,7 @@ if ([messageStyle isEqualToString:ValueMessageStyleTopPersistent] || [messageStyle isEqualToString:ValueMessageStyleTop]) { alert.topAlertObject = [[MVMCoreTopAlertObject alloc] initWithResponseInfo:responseInfo]; - alert.topAlertObject.delegate = delegateObject.topAlertDelegate; + alert.topAlertObject.delegate = alertDelegateObject.topAlertDelegate; alert.topAlertObject.pageType = pageType; alert.type = MFAlertTypeTop; } else if ([messageStyle isEqualToString:ValueMessageStylePopup]) { @@ -100,7 +105,7 @@ alert.alertStyle = UIAlertControllerStyleAlert; } } - alert.alertDelegate = delegateObject.alertDelegate; + alert.alertDelegate = alertDelegateObject.alertDelegate; return alert; } @@ -166,7 +171,8 @@ return alert; } else { if (error) { - *error = [[MVMCoreErrorObject alloc] initWithTitle:nil messageToLog:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegateObject.alertDelegate class]),[page stringForKey:KeyPageType]]]; + id delegate = [delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]] ? ((MVMCoreUIDelegateObject *)delegateObject).alertDelegate : nil; + *error = [[MVMCoreErrorObject alloc] initWithTitle:nil message:[MVMCoreGetterUtility hardcodedStringWithKey:HardcodedErrorUnableToProcess] code:ErrorCodePopupFailed domain:ErrorDomainNative location:[NSString stringWithFormat:@"%@_Popup_pageType:%@",NSStringFromClass([delegate class]),[page stringForKey:KeyPageType]]]; } return nil; } diff --git a/MVMCoreUI/Alerts/MVMCoreAlertOperation.h b/MVMCoreUI/Alerts/MVMCoreAlertOperation.h index c48fd867..a8031e5e 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertOperation.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertOperation.h @@ -9,8 +9,8 @@ #import #import -#import "MVMCoreOperation.h" -#import "MVMCoreAlertDelegateProtocol.h" +#import +#import @interface MVMCoreAlertOperation : MVMCoreOperation diff --git a/MVMCoreUI/Alerts/MVMCoreAlertOperation.m b/MVMCoreUI/Alerts/MVMCoreAlertOperation.m index 5aa9058b..c96ebe57 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertOperation.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertOperation.m @@ -7,9 +7,9 @@ // #import "MVMCoreAlertOperation.h" -#import "MVMCoreAlertHandler.h" -#import "MVMCoreAlertController.h" -#import "MVMCoreNavigationHandler.h" +#import +#import +#import @interface MVMCoreAlertOperation () { __block BOOL _paused; diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index 8a5b737a..fbd5f742 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -251,6 +251,8 @@ import Foundation try? ModelRegistry.register(RuleRegexModel.self) // MARK:- Actions + try? ModelRegistry.register(ActionPopupModel.self) + try? ModelRegistry.register(ActionAlertModel.self) try? ModelRegistry.register(ActionTopAlertModel.self) try? ModelRegistry.register(ActionCollapseNotificationModel.self) try? ModelRegistry.register(ActionOpenPanelModel.self) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 72152c40..7377701b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -10,7 +10,6 @@ @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreDispatchUtility; @import MVMCore.MVMCoreViewManagerProtocol; -@import MVMCore.MVMCoreObject; @import MVMCore.MVMCoreActionUtility; @import MVMCore.NSDictionary_MFConvenience; #import "MVMCoreUIUtility.h" @@ -847,8 +846,8 @@ CGFloat const PanelAnimationDuration = 0.2; // Top Alert MVMCoreUITopAlertView *topAlertView = nil; - if ([[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { - topAlertView = (MVMCoreUITopAlertView *)[[MVMCoreObject sharedInstance].globalTopAlertDelegate getTopAlertView]; + if ([[CoreUIObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { + topAlertView = (MVMCoreUITopAlertView *)[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView]; if (topAlertView) { self.topAlertView = topAlertView; [self.view addSubview:topAlertView]; diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index 278f8a49..ce663709 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -20,8 +20,22 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #import #import +#import +#import + +// Alert Handling +#import +#import +#import +#import #pragma mark - TopAlert +#import +#import +#import +#import +#import +#import #import #import #import diff --git a/MVMCoreUI/OtherHandlers/CoreUIObject.swift b/MVMCoreUI/OtherHandlers/CoreUIObject.swift index 3553b54b..3a4d2cbc 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIObject.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIObject.swift @@ -10,6 +10,7 @@ import UIKit @objcMembers open class CoreUIObject: MVMCoreObject { public var moleculeMap: MoleculeObjectMapping? + public var globalTopAlertDelegate: MVMCoreGlobalTopAlertDelegateProtocol? open override func defaultInitialSetup() { cache = MVMCoreCache() diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionDelegateProtocol.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionDelegateProtocol.h new file mode 100644 index 00000000..5659db85 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionDelegateProtocol.h @@ -0,0 +1,19 @@ +// +// MVMCoreUIActionDelegateProtocol.h +// MVMCoreUI +// +// Created by Scott Pfeil on 10/28/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// +#import +@class MVMCoreAlertObject; + +@protocol MVMCoreUIActionDelegateProtocol + +// Gives the delegate a chance to alter the alert object +- (void)willShowPopupWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson; + +// Gives the delegate a chance to alter the alert object +- (nullable MVMCoreAlertObject *)willShowTopAlertWithAlertObject:(nonnull MVMCoreAlertObject *)alertObject alertJson:(nonnull NSDictionary *)alertJson; + +@end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h new file mode 100644 index 00000000..3835207b --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.h @@ -0,0 +1,40 @@ +// +// MVMCoreUIActionHandler.h +// MVMCoreUI +// +// Created by Scott Pfeil on 10/28/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +#import + +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; + +#pragma mark - Deprecated + +// Shows a popup +- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; + +// Shows a top alert +- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; + +// Collapses the current top notification +- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate __deprecated; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m new file mode 100644 index 00000000..eaf7d821 --- /dev/null +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIActionHandler.m @@ -0,0 +1,164 @@ +// +// 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; + +@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; + } + return NO; +} + +- (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)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]; + }]; + } +} + +#pragma mark - Deprecated + +- (BOOL)handleOtherActions:(nullable NSString *)actionType actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + if ([actionType isEqualToString:KeyActionTypePopup]) { + [self popupAction:actionInformation additionalData:additionalData delegate:delegate]; + } else if ([actionType isEqualToString:KeyActionTypeTopAlert]) { + [self topAlertAction:actionInformation additionalData:additionalData delegate:delegate]; + return YES; + } else if ([actionType isEqualToString:KeyActionTypeCollapseNotification]) { + [self collapseNotificationAction:actionInformation additionalData:additionalData delegate:delegate]; + return YES; + } + return NO; +} + +- (void)popupAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + // 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 delegate:delegate error:&error]; + if ([delegate respondsToSelector:@selector(willShowPopupWithAlertObject:alertJson:)]) { + [((id )delegate) willShowPopupWithAlertObject:alertObject alertJson:jsonDictionary]; + } + + if (alertObject) { + [[MVMCoreAlertHandler sharedAlertHandler] showAlertWithAlertObject:alertObject]; + } else { + [self handleActionError:error actionInformation:actionInformation additionalData:additionalData delegate:delegate]; + } + }]; +} + +- (void)topAlertAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + // 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 actionDelegate:delegate]; + if ([delegate respondsToSelector:@selector(willShowTopAlertWithAlertObject:alertJson:)]) { + alertObject = [((id )delegate) willShowTopAlertWithAlertObject:alertObject alertJson:jsonDictionary]; + } + [alertObject showAlert]; + } + }]; +} + +- (void)collapseNotificationAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject *)delegate { + // Collapse the current notification. + if ([[CoreUIObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { + [[[CoreUIObject sharedInstance].globalTopAlertDelegate getTopAlertView] collapseNotification]; + } +} + +@end diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift index c63c4a87..b4ea0cd7 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIDelegateObject.swift @@ -17,6 +17,8 @@ open class MVMCoreUIDelegateObject: DelegateObject { public weak var uiTextViewDelegate: UITextViewDelegate? public weak var observingTextFieldDelegate: ObservingTextFieldDelegate? public weak var moleculeDelegate: MoleculeDelegateProtocol? + public weak var alertDelegate: (MVMCoreAlertDelegateProtocol & NSObjectProtocol)? + public weak var topAlertDelegate: (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol)? open override func setAll(withDelegate delegate: Any) { super.setAll(withDelegate: delegate) @@ -26,6 +28,8 @@ open class MVMCoreUIDelegateObject: DelegateObject { uiTextViewDelegate = delegate as? UITextViewDelegate observingTextFieldDelegate = delegate as? ObservingTextFieldDelegate moleculeDelegate = delegate as? MoleculeDelegateProtocol + alertDelegate = delegate as? (MVMCoreAlertDelegateProtocol & NSObjectProtocol) + topAlertDelegate = delegate as? (MVMCoreTopAlertDelegateProtocol & NSObjectProtocol) } class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? { diff --git a/MVMCoreUI/TopAlert/MVMCoreGlobalTopAlertDelegateProtocol.h b/MVMCoreUI/TopAlert/MVMCoreGlobalTopAlertDelegateProtocol.h index 5ee82e70..ff35c5e9 100644 --- a/MVMCoreUI/TopAlert/MVMCoreGlobalTopAlertDelegateProtocol.h +++ b/MVMCoreUI/TopAlert/MVMCoreGlobalTopAlertDelegateProtocol.h @@ -7,7 +7,7 @@ // #import -#import +#import @class MVMCoreTopAlertObject; @protocol MVMCoreGlobalTopAlertDelegateProtocol diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.h b/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.h index 350f6e19..c222747a 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.h +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.h @@ -7,7 +7,7 @@ // #import -#import +#import extern NSUInteger const TopAlertDismissTime; diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.m b/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.m index 72b6de4d..141f4cf8 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.m +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertObject.m @@ -8,10 +8,9 @@ #import "MVMCoreTopAlertObject.h" #import -#import "MVMCoreGetterUtility.h" +#import +#import #import "MVMCoreAlertHandler.h" -#import "MVMCoreJSONConstants.h" - NSUInteger const TopAlertDismissTime = 5; diff --git a/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h b/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h index 27789712..e10cec10 100644 --- a/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h +++ b/MVMCoreUI/TopAlert/MVMCoreTopAlertViewProtocol.h @@ -6,7 +6,7 @@ // Copyright © 2018 myverizon. All rights reserved. // -#import +#import @class MVMCoreTopAlertObject; @protocol MVMCoreTopAlertViewProtocol diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h index c4053d30..f8c3d7f5 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.h @@ -7,7 +7,7 @@ // #import -#import +#import #import @class Button; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m index f2401757..11d10ff0 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertBaseView.m @@ -19,8 +19,7 @@ #import "MFStyler.h" #import "MVMCoreUISession.h" #import - -@import MVMCore.MVMCoreTopAlertDelegateProtocol; +#import "MVMCoreTopAlertDelegateProtocol.h" @implementation MVMCoreUITopAlertBaseView diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.h index 04d41363..7a5519b3 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.h @@ -8,7 +8,7 @@ #import #import -#import +#import @class PrimaryButton; @class MVMCoreUITopAlertShortView; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m index 76ddb1ed..55468c95 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertExpandableView.m @@ -10,8 +10,8 @@ #import "MVMCoreUITopAlertShortView.h" #import "MVMCoreUITopAlertMainView.h" #import -#import -#import +#import +#import #import #import #import "MFStyler.h" diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h index b08ca00b..618730bc 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.h @@ -8,7 +8,7 @@ #import #import -#import +#import @class PillButton; @class MVMCoreTopAlertObject; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m index c817059d..44f248f3 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertMainView.m @@ -11,9 +11,9 @@ #import "NSLayoutConstraint+MFConvenience.h" #import #import -#import +#import #import "UIColor+MFConvenience.h" -#import +#import #import #import #import "MVMCoreUICommonViewsUtility.h" diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 58a06420..9bceb57a 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -28,7 +28,15 @@ public extension MVMCoreUITopAlertView { /// Checks for new top alert json @objc private func responseJSONUpdated(notification: Notification) { - guard let responseJSON = (notification.userInfo?[String(describing: MVMCoreLoadObject.self)] as? MVMCoreLoadObject)?.responseJSON, + guard let loadObject = (notification.userInfo?[String(describing: MVMCoreLoadObject.self)] as? MVMCoreLoadObject) else { return } + + // Dismiss any top alerts that server wants us to dismiss/ + if let disableType = loadObject.responseInfoMap?.optionalStringForKey("disableType") { + MVMCoreAlertHandler.shared()?.hidePersistentTopAlertView(ofType: disableType) + } + + // Show any new top alert. + guard let responseJSON = loadObject.responseJSON, let json = responseJSON.optionalDictionaryForKey("TopNotification"), let model = decodeTopNotification(with: json, delegateObject: getDelegateObject()) else { return } showTopAlert(with: model) diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index 1979a850..5bb033d7 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -7,12 +7,12 @@ // #import -@import MVMCore.MVMCoreTopAlertAnimationDelegateProtocol; @import MVMCore.MVMCoreLoadDelegateProtocol; @import MVMCore.MVMCoreActionDelegateProtocol; @import MVMCore.MVMCorePresentationDelegateProtocol; -@import MVMCore.MVMCoreTopAlertViewProtocol; @import MVMCore.MVMCoreViewProtocol; +#import +#import #import @class MVMCoreTopAlertObject; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index 14f4dee2..4ac5aaa0 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -17,13 +17,13 @@ #import "MVMCoreUISession.h" #import "MVMCoreUIUtility.h" #import -@import MVMCore.MVMCoreTopAlertObject; +#import @import MVMCore.MVMCoreLoadHandler; @import MVMCore.MVMCoreNavigationHandler; @import MVMCore.MVMCoreBlockOperation; -@import MVMCore.MVMCoreAlertObject; +#import @import MVMCore.MVMCoreActionHandler; -@import MVMCore.MVMCoreAlertHandler; +#import @import MVMCore.NSDictionary_MFConvenience; @import MVMCore.MVMCoreRequestParameters; @import MVMCore.MVMCoreJSONConstants; @@ -274,7 +274,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed."; [weakSelf.topAlertObject.delegate topAlertViewDismissed:view]; } [operation markAsFinished]; - completionHandler(finished); + if (completionHandler) { + completionHandler(finished); + } weakSelf.topAlertObject = nil; [MVMCoreDispatchUtility performBlockOnMainThread:^{ [weakSelf setStatusBarColor:[UIColor whiteColor] statusBarStyle:UIStatusBarStyleDefault]; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.h b/MVMCoreUI/Utility/MVMCoreUIConstants.h index 684d6044..ddd93d44 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.h +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.h @@ -44,6 +44,11 @@ extern NSString * const KeyFieldKey; extern NSString * const KeyRequired; extern NSString * const KeySourceModel; +extern NSString * const KeyActionTypePopup; +extern NSString * const KeyActionTypeAlert; +extern NSString * const KeyActionTypeTopAlert; +extern NSString * const KeyActionTypeCollapseNotification; + #pragma mark - Values extern NSString * const StringY; diff --git a/MVMCoreUI/Utility/MVMCoreUIConstants.m b/MVMCoreUI/Utility/MVMCoreUIConstants.m index e4954b01..a2b352fb 100644 --- a/MVMCoreUI/Utility/MVMCoreUIConstants.m +++ b/MVMCoreUI/Utility/MVMCoreUIConstants.m @@ -42,6 +42,10 @@ NSString * const KeyIsHidden = @"isHidden"; NSString * const KeyIsOpaque = @"isOpaque"; NSString * const KeySourceModel = @"sourceModel"; +NSString * const KeyActionTypePopup = @"popup"; +NSString * const KeyActionTypeAlert = @"alert"; +NSString * const KeyActionTypeTopAlert = @"topAlert"; +NSString * const KeyActionTypeCollapseNotification = @"collapseNotification"; #pragma mark - Values