Merge branch 'develop' of gitlab.verizon.com:BPHV_MIPS/mvm_core into develop

This commit is contained in:
Kevin G Christiano 2020-11-03 13:06:27 -05:00
commit 03024522b2
4 changed files with 32 additions and 6 deletions

View File

@ -780,11 +780,10 @@
return; return;
} }
// If we have an alert to show and a loaded view controller, allow the loaded view controller to be the delegate.
DelegateObject *delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject;
// Show any alerts that we have been saving. // Show any alerts that we have been saving.
if (loadObject.operation.alertToShow) { if (loadObject.operation.alertToShow) {
// If we have an alert to show and a loaded view controller, allow the loaded view controller to be the delegate.
DelegateObject *delegateObject = [loadedViewController respondsToSelector:@selector(delegateObject)] ? [loadedViewController delegateObject] : loadObject.operation.delegateObject;
[MVMCoreLoadRequestOperation createAndShowAlertForLoadObject:loadObject error:loadObject.operation.errorForAlertToShow delegateObject:delegateObject]; [MVMCoreLoadRequestOperation createAndShowAlertForLoadObject:loadObject error:loadObject.operation.errorForAlertToShow delegateObject:delegateObject];
} }
@ -797,6 +796,7 @@
//make post load calls function //make post load calls function
[MVMCoreLoadRequestOperation loadPostCallActions:loadObject]; [MVMCoreLoadRequestOperation loadPostCallActions:loadObject];
[MVMCoreLoadRequestOperation loadPostAction:loadObject delegateObject:delegateObject];
[loadObject.operation markAsFinished]; [loadObject.operation markAsFinished];
} }
@ -819,6 +819,13 @@
} }
} }
+ (void)loadPostAction:(nonnull MVMCoreLoadObject *)loadObject delegateObject:(nullable DelegateObject *)delegateObject {
NSDictionary *actionDict = [loadObject.responseJSON dict:@"PostAction"];
if (actionDict) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionDict additionalData:nil delegateObject:delegateObject];
}
}
+ (void)removeCaches:(nullable NSDictionary *)cacheDictionary { + (void)removeCaches:(nullable NSDictionary *)cacheDictionary {
if (cacheDictionary) { if (cacheDictionary) {

View File

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

View File

@ -10,10 +10,16 @@
@interface MVMCoreViewControllerProgrammaticMappingObject : NSObject <MVMCoreViewControllerMappingProtocol> @interface MVMCoreViewControllerProgrammaticMappingObject : NSObject <MVMCoreViewControllerMappingProtocol>
// View Controller Class, for loading by class. /// View Controller Class, for loading by class.
@property (nonnull, strong, nonatomic) Class viewControllerClass; @property (nonnull, strong, nonatomic) Class viewControllerClass;
// Initializes with the given class. /// Configuration block executed on creation of the controller before loading.
@property (nullable, copy, nonatomic) void (^configureHandler)(UIViewController * _Nonnull);
/// Initializes with the given class.
- (nullable id)initWithClass:(nonnull Class)viewControllerClass; - (nullable id)initWithClass:(nonnull Class)viewControllerClass;
/// Initializes with the given class. Assigns a configuration block triggered on intiailization which allows additional configuration of the view controller before its loaded, i.e. injecting top level dependencies.
- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^_Nonnull)(UIViewController * _Nonnull))configureBlock;
@end @end

View File

@ -19,8 +19,20 @@
return self; return self;
} }
- (nullable id)initWithClass:(nonnull Class)viewControllerClass configureHandler:(void(^)(UIViewController * _Nonnull))configureBlock {
self = [self initWithClass:viewControllerClass];
if (self) {
self.configureHandler = configureBlock;
}
return self;
}
- (nullable UIViewController <MVMCoreViewControllerProtocol> *)createViewController { - (nullable UIViewController <MVMCoreViewControllerProtocol> *)createViewController {
return [[self.viewControllerClass alloc] init]; UIViewController <MVMCoreViewControllerProtocol> *newController = [[self.viewControllerClass alloc] init];
if (self.configureHandler) {
self.configureHandler(newController);
}
return newController;
} }
@end @end