Merge branch 'develop' into feature/pageLoadTracking

This commit is contained in:
Krishna Kishore Bandaru 2023-04-24 11:57:53 +05:30
commit cbb17edcf9
17 changed files with 96 additions and 193 deletions

View File

@ -109,6 +109,7 @@
AF7069A02880F0EB00077CF6 /* ActionOpenPageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */; };
AF787413286DEF8B00670588 /* ActionBackHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF787412286DEF8B00670588 /* ActionBackHandler.swift */; };
AF8D13392774EA1D008AF4A9 /* ActionOpenUrlHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */; };
AFA4931E29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */; };
AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */; };
AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -133,8 +134,6 @@
AFBB96951FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96771FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96961FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96781FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */; };
AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */; };
AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */; };
AFBB96B21FBA3B590008D868 /* MVMCoreGetterUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -273,6 +272,7 @@
AF70699F2880F0EB00077CF6 /* ActionOpenPageHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenPageHandler.swift; sourceTree = "<group>"; };
AF787412286DEF8B00670588 /* ActionBackHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackHandler.swift; sourceTree = "<group>"; };
AF8D13382774EA1D008AF4A9 /* ActionOpenUrlHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionOpenUrlHandler.swift; sourceTree = "<group>"; };
AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreActionUtility+Extension.swift"; sourceTree = "<group>"; };
AFBB96321FBA34310008D868 /* MVMCoreErrorConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreErrorConstants.h; sourceTree = "<group>"; };
AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreErrorConstants.m; sourceTree = "<group>"; };
AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadDelegateProtocol.h; sourceTree = "<group>"; };
@ -297,8 +297,6 @@
AFBB96771FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCorePresentationDelegateProtocol.h; sourceTree = "<group>"; };
AFBB96781FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCorePresentViewControllerOperation.h; sourceTree = "<group>"; };
AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCorePresentViewControllerOperation.m; sourceTree = "<group>"; };
AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreAlertController.h; sourceTree = "<group>"; };
AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreAlertController.m; sourceTree = "<group>"; };
AFBB96AC1FBA3B590008D868 /* MVMCoreDispatchUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreDispatchUtility.h; sourceTree = "<group>"; };
AFBB96AD1FBA3B590008D868 /* MVMCoreDispatchUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreDispatchUtility.m; sourceTree = "<group>"; };
AFBB96AE1FBA3B590008D868 /* MVMCoreGetterUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreGetterUtility.h; sourceTree = "<group>"; };
@ -391,7 +389,6 @@
8876D5D41FB50AAB00EB2E3D /* Utility */,
AF43A7191FC5BE9E008E9347 /* MainProtocols */,
AFBB96B41FBA3CEC0008D868 /* ActionHandling */,
AFBB967A1FBA3A9A0008D868 /* AlertHandling */,
AFBB966B1FBA3A9A0008D868 /* PresentationHandling */,
AFBB96361FBA39E70008D868 /* LoadHandling */,
AFBB96131FBA26650008D868 /* ViewControllerMapping */,
@ -611,15 +608,6 @@
path = PresentationHandling;
sourceTree = "<group>";
};
AFBB967A1FBA3A9A0008D868 /* AlertHandling */ = {
isa = PBXGroup;
children = (
AFBB967B1FBA3A9A0008D868 /* MVMCoreAlertController.h */,
AFBB967C1FBA3A9A0008D868 /* MVMCoreAlertController.m */,
);
path = AlertHandling;
sourceTree = "<group>";
};
AFBB96AB1FBA3B590008D868 /* Helpers */ = {
isa = PBXGroup;
children = (
@ -630,6 +618,7 @@
D282AAB52240085300C46919 /* MVMCoreGetterUtility+Extension.swift */,
AF43A5851FBB67D6008E9347 /* MVMCoreActionUtility.h */,
AF43A5861FBB67D6008E9347 /* MVMCoreActionUtility.m */,
AFA4931D29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift */,
);
path = Helpers;
sourceTree = "<group>";
@ -756,7 +745,6 @@
8876D5EC1FB50AB000EB2E3D /* NSDictionary+MFConvenience.h in Headers */,
AFFCFA651FCCC0D700FD0730 /* MVMCoreLoadingOverlayDelegateProtocol.h in Headers */,
AF1201832108C9B400E2F592 /* MVMCoreViewManagerViewControllerProtocol.h in Headers */,
AFBB96981FBA3A9A0008D868 /* MVMCoreAlertController.h in Headers */,
881D26961FCC9D180079C521 /* MVMCoreOperation.h in Headers */,
8876D5EA1FB50AB000EB2E3D /* NSDecimalNumber+MFConvenience.h in Headers */,
AF43A7201FC5D2BA008E9347 /* MVMCoreViewManagerProtocol.h in Headers */,
@ -905,7 +893,6 @@
BB780ADF250F8C890030BD2F /* ActionNoopModel.swift in Sources */,
D2E1FAD92260C3E400AEFD8C /* DelegateObject.swift in Sources */,
01F2A03623A80A7300D954D8 /* ActionModelProtocol.swift in Sources */,
AFBB96991FBA3A9A0008D868 /* MVMCoreAlertController.m in Sources */,
881D26941FCC9D180079C521 /* MVMCoreOperation.m in Sources */,
AFED77A41FCCA29400BAE689 /* MVMCoreViewControllerMappingObject.m in Sources */,
01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */,
@ -916,6 +903,7 @@
AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */,
D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */,
AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */,
AFA4931E29E5C988001A9663 /* MVMCoreActionUtility+Extension.swift in Sources */,
1DAD0FFE26AAB40000216E83 /* ActionRunJavaScriptModel.swift in Sources */,
946EE1AB237B5C940036751F /* Decoder.swift in Sources */,
2723337D28BD53C2004EAEE0 /* Date+Extension.swift in Sources */,

View File

@ -129,7 +129,7 @@ public protocol MVMCoreJSONActionHandlerProtocol: MVMCoreActionHandlerProtocol {
}
/// Logs the error.
@objc open func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable: Any]?) {
@objc open func defaultHandleActionError(_ error: MVMCoreErrorObject, additionalData: [AnyHashable: Any]? = nil, delegateObject: DelegateObject? = nil) {
guard error.logError else { return }
MVMCoreLoggingHandler.addError(toLog: error)
error.logError = false // Further attempts to log the same error will be skipped. (Legacy action flow.)

View File

@ -1,18 +0,0 @@
//
// MVMCoreAlertController.h
// alerts
//
// Created by Scott Pfeil on 10/22/14.
// Copyright (c) 2014 Verizon Wireless. All rights reserved.
//
// Used by our alert handler. Not for subclassing. Simply keeps track of if it's visible. Tries to parallel the UIAlertView to make it easier for the MVMCoreAlertHandler.
#import <UIKit/UIKit.h>
@class MVMCoreAlertObject;
@interface MVMCoreAlertController : UIAlertController
@property (nonatomic, readonly, getter=isVisible) BOOL visible;
@property (nullable, nonatomic, strong) MVMCoreAlertObject *alertObject;
@end

View File

@ -1,49 +0,0 @@
//
// MVMAlertController.m
// alerts
//
// Created by Scott Pfeil on 10/22/14.
// Copyright (c) 2014 Verizon Wireless. All rights reserved.
//
#import "MVMCoreAlertController.h"
#import "MVMCoreLoggingHandler.h"
#import "MVMCoreGetterUtility.h"
@interface MVMCoreAlertController ()
@property (nonatomic, readwrite, getter=isVisible) BOOL visible;
@end
@implementation MVMCoreAlertController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self willChangeValueForKey:@"isVisible"];
self.visible = YES;
[self didChangeValueForKey:@"isVisible"];
[MVMCoreLoggingHandler logAlertForAlertController:self];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self willChangeValueForKey:@"isVisible"];
self.visible = NO;
[self didChangeValueForKey:@"isVisible"];
}
- (NSString *)description {
return [NSString stringWithFormat:@"%@|title=%@|message=%@", [super description],self.title,self.message];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
if ([MVMCoreGetterUtility isOnIPad]) {
return UIInterfaceOrientationMaskAll;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
@end

View File

@ -11,7 +11,6 @@
#import <MVMCore/MVMCoreViewControllerProtocol.h>
@class MVMCoreRequestParameters;
@class MVMCoreErrorObject;
@class MVMCoreAlertObject;
@class MVMCoreLoadObject;
@protocol MVMCoreLoadDelegateProtocol

View File

@ -135,31 +135,7 @@
- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
NSURL *url = requestParameters.URL;
if (!url) {
if (requestParameters.alternateBaseURL) {
url = requestParameters.alternateBaseURL;
} else {
url = [MVMCoreSessionObject sharedGlobal].baseURL ?: [NSURL URLWithString:URLProdPostpayBase];
}
// Appends the context root.
if (requestParameters.contextRoot) {
url = [url URLByAppendingPathComponent:requestParameters.contextRoot];
} else if ([MVMCoreSessionObject sharedGlobal].contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (requestParameters.pageType) {
url = [url URLByAppendingPathComponent:requestParameters.pageType];
}
// This has changed since the initial agreement. Seems server always needs page type now.
/* else if (requestParameters.modules) {
url = [url URLByAppendingPathComponent:KeyModuleMap];
}*/
}
NSURL *url = [requestParameters resolveURL:[MVMCoreSessionObject sharedGlobal]];
// Adds modules needed to the request parameters.
if (requestParameters.modules.count > 0) {

View File

@ -113,6 +113,8 @@
- (void)main {
MVMCoreLog(@"Load Operation begun for page type %@, background load %@, delegate %@", self.requestParameters.pageType, @(self.backgroundLoad),self.delegateObject.loadDelegate);
[self.requestParameters resolveURL:[MVMCoreSessionObject sharedGlobal]];
// Always check for cancellation before launching the task.
if ([self checkAndHandleForCancellation]) {
return;

View File

@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <MVMCore/MVMCoreSessionObject.h>
// The loading style.
// MFLoadStyleDefault: This means it has not been explicitely set by the developer. Standard push.
@ -124,4 +125,7 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
/// Returns optional and required modules
- (nullable NSArray<NSString *> *)allModules;
/// Resolves the URL given the session object and the current request parameters.
- (nonnull NSURL *)resolveURL:(nonnull MVMCoreSessionObject *)sessionObject;
@end

View File

@ -10,9 +10,12 @@
#import "NSDictionary+MFConvenience.h"
#import "MVMCoreJSONConstants.h"
#import "MVMCoreViewControllerMappingObject.h"
#import "MVMCoreConstants.h"
@interface MVMCoreRequestParameters ()
@property (nonatomic, strong, nullable) NSURL *determinedURL;
- (nullable instancetype)initWithExtraParameters:(nullable NSDictionary *)extraParameters;
@end
@ -86,6 +89,56 @@
return self;
}
- (void)setAlternateBaseURL:(NSURL *)alternateBaseURL {
_alternateBaseURL = alternateBaseURL;
_URL = self.determinedURL; // Reset resolution when changed.
}
- (void)setPageType:(NSString *)pageType {
_pageType = pageType;
_URL = self.determinedURL; // Reset resolution when changed.
}
- (void)setContextRoot:(NSString *)contextRoot {
_contextRoot = contextRoot;
_URL = self.determinedURL; // Reset resolution when changed.
}
- (void)setURL:(NSURL *)URL {
self.determinedURL = URL; // If set directly, this becomes the ultimate URL.
_URL = URL;
}
- (NSURL *)resolveURL:(MVMCoreSessionObject *)sessionObject {
if (self.URL) {
// Previously resovled.
return self.URL;
}
NSURL *url;
if (self.alternateBaseURL) {
url = self.alternateBaseURL;
} else {
url = sessionObject.baseURL ?: [NSURL URLWithString:URLProdPostpayBase];
}
// Appends the context root.
if (self.contextRoot) {
url = [url URLByAppendingPathComponent:self.contextRoot];
} else if (sessionObject.contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (self.pageType) {
url = [url URLByAppendingPathComponent:self.pageType];
}
_URL = url;
return url;
}
- (void)addRequestParameters:(nonnull NSDictionary *)parameters {
if ([parameters count] > 0) {
@ -152,6 +205,7 @@
copyObject.customTimeoutTime = self.customTimeoutTime;
copyObject.backgroundRequest = self.backgroundRequest;
copyObject.URL = self.URL;
copyObject.determinedURL = self.determinedURL;
copyObject.actionMap = self.actionMap;
return copyObject;
}

View File

@ -63,7 +63,6 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[];
#import <MVMCore/MVMCorePresentViewControllerOperation.h>
#import <MVMCore/MVMCoreNavigationOperation.h>
#import <MVMCore/MVMCoreViewControllerAnimatedTransitioning.h>
#import <MVMCore/MVMCoreAlertController.h>
// Action Handling
#import <MVMCore/MVMCoreActionDelegateProtocol.h>

View File

@ -7,7 +7,6 @@
//
#import <UIKit/UIKit.h>
@class MVMCoreAlertController;
@protocol MVMCoreLoggingDelegateProtocol <NSObject>
@ -25,7 +24,4 @@
// Log that the load has finished.
- (void)logLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
// Log alert
- (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
@end

View File

@ -11,7 +11,6 @@
#import <MVMCore/MVMCoreViewControllerProtocol.h>
#import <MVMCore/MVMCoreLoadObject.h>
#import <MVMCore/MVMCoreLoggingDelegateProtocol.h>
@class MVMCoreAlertController;
#define MVMCoreLog(fmt, ...) \
[MVMCoreLoggingHandler logDebugMessageWithDelegate:[NSString stringWithFormat:(@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__]];
@ -24,7 +23,6 @@
+ (void)logDebugMessageWithDelegate:(nullable NSString *)message;
+ (void)logWithDelegateWithObject:(nullable id)object withName:(nullable NSString *)name withExtraInfo:(nullable NSDictionary *)extra;
+ (void)logWithDelegateLoadFinished:(nullable MVMCoreLoadObject *)loadObject loadedViewController:(nullable UIViewController <MVMCoreViewControllerProtocol> *)loadedViewController error:(nullable MVMCoreErrorObject *)error;
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController;
- (void)recordEvent:(nonnull NSString *)name attributes:(nullable NSDictionary<NSString *, id> *)attributes;
#pragma mark MVMCoreLoggingDelegateProtocol

View File

@ -45,12 +45,6 @@
}
}
+ (void)logAlertForAlertController:(nullable MVMCoreAlertController *)alertController {
if ([[MVMCoreObject sharedInstance].loggingDelegate respondsToSelector:@selector(logAlertForAlertController:)]) {
[[MVMCoreObject sharedInstance].loggingDelegate logAlertForAlertController:alertController];
}
}
- (void)recordEvent:(nonnull NSString *)name attributes:(nullable NSDictionary<NSString *, id> *)attributes {}
#pragma mark - logging delegate

View File

@ -136,9 +136,6 @@
// Use this to dismiss all presented view controllers stacked on the bottom one.
- (void)dismissToBottom:(BOOL)animated;
// Removes all queued up items.
- (void)cancelPresentation;
#pragma mark - Presentation Extra
// Use this to present.

View File

@ -46,9 +46,6 @@
self.navigationQueue = [[NSOperationQueue alloc] init];
self.navigationQueue.maxConcurrentOperationCount = 1;
self.presentationQueue = [[NSOperationQueue alloc] init];
self.presentationQueue.maxConcurrentOperationCount = 1;
self.delegates = (NSHashTable <MVMCorePresentationDelegateProtocol>*)[NSHashTable weakObjectsHashTable];
}
return self;
@ -308,10 +305,6 @@
[self dismissToBottom:animated delegate:nil completionHandler:NULL];
}
- (void)cancelPresentation {
[self.presentationQueue cancelAllOperations];
}
#pragma mark - Presentation Extra
- (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
@ -325,7 +318,7 @@
MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:viewController animated:animated];
operation.delegate = delegate;
operation.completionBlock = completionBlock;
[self.presentationQueue addOperation:operation];
[self.navigationQueue addOperation:operation];
}
}];
}

View File

@ -7,7 +7,6 @@
//
#import "MVMCorePresentViewControllerOperation.h"
#import "MVMCoreAlertController.h"
#import "MVMCorePresentAnimationOperation.h"
#import "MVMCoreDispatchUtility.h"
#import "MVMCoreConstants.h"
@ -18,20 +17,10 @@
@property (nullable, strong, nonatomic) UIViewController *presentedViewController;
@property (nonatomic) BOOL animate;
@property (nonatomic) BOOL beingObserved;
@property (nullable, weak, nonatomic) MVMCoreAlertController *alertController;
@end
@implementation MVMCorePresentViewControllerOperation
// The context for kvo
static void * XXContext = &XXContext;
- (void)dealloc {
[self stopObservingAlertView];
}
- (nullable instancetype)initWithPresentingViewController:(nullable UIViewController *)presentingViewController presentedViewController:(nullable UIViewController *)presentedViewController animated:(BOOL)animated {
if (self = [super init]) {
@ -67,57 +56,19 @@ static void * XXContext = &XXContext;
controllerToPresentOn = controllerToPresentOn.presentedViewController;
}
// If an alert is showing, don't present until the alerts are dismissed.
if ([controllerToPresentOn isKindOfClass:[MVMCoreAlertController class]]) {
[self observeForAlertDismissal:(MVMCoreAlertController *)controllerToPresentOn];
} else {
MVMCorePresentAnimationOperation *animationOperation = [[MVMCorePresentAnimationOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:self.presentedViewController animated:self.animate];
animationOperation.delegate = self.delegate;
[animationOperation setCompletionBlock:^{
[self markAsFinished];
// Notify that page has changed
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationViewControllerChanged object:nil];
});
}];
[[NSOperationQueue mainQueue] addOperation:animationOperation];
}
MVMCorePresentAnimationOperation *animationOperation = [[MVMCorePresentAnimationOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:self.presentedViewController animated:self.animate];
animationOperation.delegate = self.delegate;
[animationOperation setCompletionBlock:^{
[self markAsFinished];
// Notify that page has changed
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationViewControllerChanged object:nil];
});
}];
[[NSOperationQueue mainQueue] addOperation:animationOperation];
} else {
[self markAsFinished];
}
}
- (void)cancel {
[super cancel];
[self stopObservingAlertView];
}
#pragma mark - Observer Functions
- (void)observeForAlertDismissal:(MVMCoreAlertController *)alertController {
if (!self.beingObserved) {
self.beingObserved = YES;
self.alertController = alertController;
[alertController addObserver:self forKeyPath:@"visible" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:XXContext];
}
}
- (void)stopObservingAlertView {
if (self.beingObserved) {
[self.alertController removeObserver:self forKeyPath:@"visible" context:XXContext];
self.alertController = nil;
self.beingObserved = NO;
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (context == XXContext && [keyPath isEqualToString:@"visible"]) {
if (![object isVisible]) {
[self stopObservingAlertView];
[self present];
}
}
}
@end

View File

@ -0,0 +1,19 @@
//
// MVMCoreActionUtility+Extension.swift
// MVMCore
//
// Created by Scott Pfeil on 4/11/23.
// Copyright © 2023 myverizon. All rights reserved.
//
public extension MVMCoreActionUtility {
static func fatalClassCheck<T>(object: AnyObject?) -> T {
guard let object = object else {
fatalError("Object \(T.self) is nil.")
}
guard let instance = object as? T else {
fatalError("\(object) is not an instance of \(T.self)")
}
return instance
}
}