Merge branch 'develop' of gitlab.verizon.com:BPHV_MIPS/mvm_core into develop
This commit is contained in:
commit
e573262990
@ -8,18 +8,20 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class ActionOpenPageModel: ActionModelProtocol {
|
||||
@objcMembers open class ActionOpenPageModel: ActionModelProtocol {
|
||||
public static var identifier: String = "openPage"
|
||||
public var actionType: String = ActionOpenPageModel.identifier
|
||||
public var pageType: String
|
||||
public var extraParameters: JSONValueDictionary?
|
||||
public var analyticsData: JSONValueDictionary?
|
||||
public var presentationStyle: String?
|
||||
public var tabBarIndex: Int?
|
||||
|
||||
public init(pageType: String, _ presentationStyle: String? = nil, _ extraParameters: JSONValueDictionary? = nil, _ analyticsData: JSONValueDictionary? = nil) {
|
||||
public init(pageType: String, presentationStyle: String? = nil, extraParameters: JSONValueDictionary? = nil, analyticsData: JSONValueDictionary? = nil, tabBarIndex: Int? = nil) {
|
||||
self.pageType = pageType
|
||||
self.presentationStyle = presentationStyle
|
||||
self.extraParameters = extraParameters
|
||||
self.analyticsData = analyticsData
|
||||
self.tabBarIndex = tabBarIndex
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,9 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO
|
||||
@property (nullable, strong, nonatomic, readonly) NSDictionary *staticStringCache;
|
||||
@property (nonnull, strong, nonatomic) NSOperationQueue *completionQueue;
|
||||
|
||||
/// Contains all bundles to search for images.
|
||||
@property (nonnull, strong, nonatomic) NSMutableArray<NSBundle *>* imageBundles;
|
||||
|
||||
// Returns the shared instance of this singleton
|
||||
+ (nullable instancetype)sharedCache;
|
||||
|
||||
@ -108,8 +111,14 @@ typedef void(^MVMCoreGetImageBlock)(UIImage * _Nullable, NSData * _Nullable, BOO
|
||||
|
||||
#pragma mark Image Functions
|
||||
|
||||
// Subclass to return the bundle to use
|
||||
- (nonnull NSBundle *)bundleToUseForImages;
|
||||
/// Register a bundle as one to search for images in.
|
||||
- (void)registerBundleForImages:(nonnull NSBundle *)bundle;
|
||||
|
||||
/// Tries to create an image from a registered bundle.
|
||||
- (nullable UIImage *)getImageFromRegisteredBundles:(nonnull NSString *)imageName;
|
||||
|
||||
/// Tries to get image data from a registered bundle. Can specify the type of extension if desired.
|
||||
- (nullable NSData *)getImageDataFromRegisteredBundles:(nonnull NSString *)imageName type:(nullable NSString *)type;
|
||||
|
||||
/// Returns if the imageName pointing to a local image. Currently just checks if it begins with http.
|
||||
+ (BOOL)isHostedImage:(nullable NSString *)imageName;
|
||||
|
||||
@ -57,6 +57,8 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
self.moduleQueue.maxConcurrentOperationCount = 1;
|
||||
|
||||
self.imageCacheQueue = dispatch_queue_create("imgCache", DISPATCH_QUEUE_CONCURRENT);
|
||||
|
||||
self.imageBundles = [NSMutableArray array];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -374,8 +376,30 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
|
||||
#pragma mark - Image Functions
|
||||
|
||||
- (nonnull NSBundle *)bundleToUseForImages {
|
||||
return [MVMCoreGetterUtility bundleForMVMCore];
|
||||
- (void)registerBundleForImages:(nonnull NSBundle *)bundle {
|
||||
[self.imageBundles addObject:bundle];
|
||||
}
|
||||
|
||||
- (nullable UIImage *)getImageFromRegisteredBundles:(nonnull NSString *)imageName {
|
||||
UIImage *image = nil;
|
||||
for (NSBundle *bundle in self.imageBundles) {
|
||||
image = [UIImage imageNamed:imageName inBundle:bundle compatibleWithTraitCollection:nil];
|
||||
if (image) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
- (nullable NSData *)getImageDataFromRegisteredBundles:(nonnull NSString *)imageName type:(nullable NSString *)type {
|
||||
NSData *imageData = nil;
|
||||
for (NSBundle *bundle in self.imageBundles) {
|
||||
imageData = [NSData dataWithContentsOfFile:[bundle pathForResource:imageName ofType:type]];
|
||||
if (imageData) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return imageData;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)imgCache {
|
||||
@ -487,8 +511,11 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
// Try Local. Check in memory cache
|
||||
imageData = [self getCachedDataWithName:pathOrName];
|
||||
if (!imageData) {
|
||||
NSBundle *imageBundle = localBundle ? : [self bundleToUseForImages];
|
||||
imageData = [NSData dataWithContentsOfFile:[imageBundle pathForResource:pathOrName ofType:@"gif"]];
|
||||
if (localBundle) {
|
||||
imageData = [NSData dataWithContentsOfFile:[localBundle pathForResource:pathOrName ofType:@"gif"]];
|
||||
} else {
|
||||
imageData = [self getImageDataFromRegisteredBundles:pathOrName type:@"gif"];
|
||||
}
|
||||
if (imageData) {
|
||||
[self addDataToCache:imageData withName:pathOrName];
|
||||
}
|
||||
@ -525,7 +552,11 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
// Try native image. Check in memory cache
|
||||
image = [self getCachedImageWithName:pathOrName];
|
||||
if (!image) {
|
||||
image = [UIImage imageNamed:pathOrName inBundle:localBundle ?: [self bundleToUseForImages] compatibleWithTraitCollection:nil];
|
||||
if (localBundle) {
|
||||
image = [UIImage imageNamed:pathOrName inBundle:localBundle compatibleWithTraitCollection:nil];
|
||||
} else {
|
||||
image = [self getImageFromRegisteredBundles:pathOrName];
|
||||
}
|
||||
if (image) {
|
||||
[self addImageToCache:image withName:pathOrName];
|
||||
}
|
||||
@ -585,7 +616,7 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
|
||||
image = [self getCachedImageWithName:fallbackImageName];
|
||||
if (!image) {
|
||||
|
||||
image = [UIImage imageNamed:fallbackImageName inBundle:[self bundleToUseForImages] compatibleWithTraitCollection:nil];
|
||||
image = [self getImageFromRegisteredBundles:fallbackImageName];
|
||||
if (image) {
|
||||
|
||||
// Cache the fallback image if not already cached.
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
@class MVMCoreNavigationObject;
|
||||
@class MVMCoreLoadObject;
|
||||
|
||||
@interface MVMCoreNavigationHandler : NSObject
|
||||
@interface MVMCoreNavigationHandler : NSObject <UINavigationControllerDelegate>
|
||||
|
||||
// Returns the shared instance of this singleton
|
||||
+ (nullable instancetype)sharedNavigationHandler;
|
||||
@ -25,6 +25,8 @@
|
||||
// reference to main navigation controller
|
||||
@property (nullable, weak, nonatomic) UINavigationController *navigationController;
|
||||
|
||||
/// A list of possible delegates looking for information.
|
||||
@property (nonnull, strong, nonatomic) NSHashTable<MVMCorePresentationDelegateProtocol> *delegates;
|
||||
|
||||
// Will navigate appropriately based on the load style
|
||||
- (void)navigateWithLoadObject:(nullable MVMCoreLoadObject *)loadObject viewController:(nonnull UIViewController *)viewController delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock;
|
||||
@ -35,6 +37,14 @@
|
||||
// pops or dimisses as needed
|
||||
- (void)removeCurrentViewController;
|
||||
|
||||
#pragma mark - Delegate Handling
|
||||
|
||||
/// Adds a listener for navigation delegate functions
|
||||
- (void)addDelegate:(nonnull id <MVMCorePresentationDelegateProtocol>)delegate;
|
||||
|
||||
/// Removes a listener for navigation delegate functions
|
||||
- (void)removeDelegate:(nullable id <MVMCorePresentationDelegateProtocol>)delegate;
|
||||
|
||||
#pragma mark - Navigation Simple
|
||||
// Uses the default navigation controller in app delegate
|
||||
|
||||
|
||||
@ -47,10 +47,24 @@
|
||||
|
||||
self.presentationQueue = [[NSOperationQueue alloc] init];
|
||||
self.presentationQueue.maxConcurrentOperationCount = 1;
|
||||
|
||||
self.delegates = (NSHashTable <MVMCorePresentationDelegateProtocol>*)[NSHashTable weakObjectsHashTable];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Delegate Handling
|
||||
|
||||
- (void)addDelegate:(nonnull id <MVMCorePresentationDelegateProtocol>)delegate {
|
||||
[self.delegates addObject:delegate];
|
||||
}
|
||||
|
||||
- (void)removeDelegate:(nullable id <MVMCorePresentationDelegateProtocol>)delegate {
|
||||
[self.delegates removeObject:delegate];
|
||||
}
|
||||
|
||||
#pragma mark - Navigation Helpers
|
||||
|
||||
- (void)navigateWithLoadObject:(nullable MVMCoreLoadObject *)loadObject viewController:(nonnull UIViewController *)viewController delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
|
||||
|
||||
BOOL shouldAnimate = !loadObject.requestParameters.shouldNotAnimatePush;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#import "MVMCoreLoggingHandler.h"
|
||||
#import "MVMCoreLoadingOverlayHandler.h"
|
||||
#import "MVMCoreViewControllerAnimatedTransitioning.h"
|
||||
#import "MVMCoreNavigationHandler.h"
|
||||
|
||||
@interface MVMCoreNavigationOperation ()
|
||||
|
||||
@ -225,6 +226,8 @@
|
||||
[super markAsFinished];
|
||||
}
|
||||
|
||||
#pragma mark - Delegate
|
||||
|
||||
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
||||
if (self.navigationObject.stopLoadingOverlay) {
|
||||
[[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:YES];
|
||||
@ -234,6 +237,11 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:willDisplayViewController:)]) {
|
||||
[self.delegate navigationController:navigationController willDisplayViewController:viewController];
|
||||
}
|
||||
for (NSObject<MVMCorePresentationDelegateProtocol> *delegate in [MVMCoreNavigationHandler sharedNavigationHandler].delegates.allObjects) {
|
||||
if (delegate && [delegate respondsToSelector:@selector(navigationController:willDisplayViewController:)]) {
|
||||
[delegate navigationController:navigationController willDisplayViewController:viewController];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
||||
@ -241,8 +249,13 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:displayedViewController:)]) {
|
||||
[self.delegate navigationController:navigationController displayedViewController:viewController];
|
||||
}
|
||||
for (NSObject<MVMCorePresentationDelegateProtocol> *delegate in [MVMCoreNavigationHandler sharedNavigationHandler].delegates.allObjects) {
|
||||
if (delegate && [delegate respondsToSelector:@selector(navigationController:displayedViewController:)]) {
|
||||
[delegate navigationController:navigationController displayedViewController:viewController];
|
||||
}
|
||||
}
|
||||
[self markAsFinished];
|
||||
// Notify that page has changed
|
||||
// Legacy notify that page has changed
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MVMCoreNotificationViewControllerChanged object:nil];
|
||||
});
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "MVMCorePresentAnimationOperation.h"
|
||||
#import "MVMCoreNavigationHandler.h"
|
||||
|
||||
@interface MVMCorePresentAnimationOperation ()
|
||||
|
||||
@ -39,12 +40,22 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(viewController:willPresentViewController:)]) {
|
||||
[self.delegate viewController:self.presentingViewController willPresentViewController:self.presentedViewController];
|
||||
}
|
||||
for (NSObject<MVMCorePresentationDelegateProtocol> *delegate in [MVMCoreNavigationHandler sharedNavigationHandler].delegates.allObjects) {
|
||||
if (delegate && [delegate respondsToSelector:@selector(viewController:willPresentViewController:)]) {
|
||||
[delegate viewController:self.presentingViewController willPresentViewController:self.presentedViewController];
|
||||
}
|
||||
}
|
||||
|
||||
[self.presentingViewController presentViewController:self.presentedViewController animated:self.animate completion:^{
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(viewController:didPresentViewController:)]) {
|
||||
[self.delegate viewController:self.presentingViewController didPresentViewController:self.presentedViewController];
|
||||
}
|
||||
for (NSObject<MVMCorePresentationDelegateProtocol> *delegate in [MVMCoreNavigationHandler sharedNavigationHandler].delegates.allObjects) {
|
||||
if (delegate && [delegate respondsToSelector:@selector(viewController:didPresentViewController:)]) {
|
||||
[delegate viewController:self.presentingViewController didPresentViewController:self.presentedViewController];
|
||||
}
|
||||
}
|
||||
[self markAsFinished];
|
||||
}];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user