queue changes
This commit is contained in:
parent
15ca6142fe
commit
38cb3eb80e
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#import "MVMCoreDismissViewControllerOperation.h"
|
#import "MVMCoreDismissViewControllerOperation.h"
|
||||||
#import "MVMCoreConstants.h"
|
#import "MVMCoreConstants.h"
|
||||||
|
#import "MVMCoreDispatchUtility.h"
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, DismissType) {
|
typedef NS_ENUM(NSInteger, DismissType) {
|
||||||
DismissTypeTop = 0,
|
DismissTypeTop = 0,
|
||||||
@ -49,29 +50,31 @@ typedef NS_ENUM(NSInteger, DismissType) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (self.type) {
|
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||||
case DismissTypeTop:
|
switch (self.type) {
|
||||||
{
|
case DismissTypeTop:
|
||||||
// Gets the top most presented.
|
{
|
||||||
UIViewController *controllerToDismiss = self.viewController;
|
// Gets the top most presented.
|
||||||
while (controllerToDismiss.presentedViewController) {
|
UIViewController *controllerToDismiss = self.viewController;
|
||||||
controllerToDismiss = controllerToDismiss.presentedViewController;
|
while (controllerToDismiss.presentedViewController) {
|
||||||
|
controllerToDismiss = controllerToDismiss.presentedViewController;
|
||||||
|
}
|
||||||
|
[self dismissViewController:controllerToDismiss];
|
||||||
}
|
}
|
||||||
[self dismissViewController:controllerToDismiss];
|
break;
|
||||||
}
|
case DismissTypeSpecific:
|
||||||
break;
|
{
|
||||||
case DismissTypeSpecific:
|
if (self.viewController.presentingViewController) {
|
||||||
{
|
[self dismissViewController:self.viewController.presentingViewController];
|
||||||
if (self.viewController.presentingViewController) {
|
} else {
|
||||||
[self dismissViewController:self.viewController.presentingViewController];
|
[self dismissViewController:self.viewController];
|
||||||
} else {
|
}
|
||||||
[self dismissViewController:self.viewController];
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
}];
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dismissViewController:(nonnull UIViewController *)viewController {
|
- (void)dismissViewController:(nonnull UIViewController *)viewController {
|
||||||
|
|||||||
@ -136,9 +136,6 @@
|
|||||||
// Use this to dismiss all presented view controllers stacked on the bottom one.
|
// Use this to dismiss all presented view controllers stacked on the bottom one.
|
||||||
- (void)dismissToBottom:(BOOL)animated;
|
- (void)dismissToBottom:(BOOL)animated;
|
||||||
|
|
||||||
// Removes all queued up items.
|
|
||||||
- (void)cancelPresentation;
|
|
||||||
|
|
||||||
#pragma mark - Presentation Extra
|
#pragma mark - Presentation Extra
|
||||||
|
|
||||||
// Use this to present.
|
// Use this to present.
|
||||||
|
|||||||
@ -46,9 +46,6 @@
|
|||||||
self.navigationQueue = [[NSOperationQueue alloc] init];
|
self.navigationQueue = [[NSOperationQueue alloc] init];
|
||||||
self.navigationQueue.maxConcurrentOperationCount = 1;
|
self.navigationQueue.maxConcurrentOperationCount = 1;
|
||||||
|
|
||||||
self.presentationQueue = [[NSOperationQueue alloc] init];
|
|
||||||
self.presentationQueue.maxConcurrentOperationCount = 1;
|
|
||||||
|
|
||||||
self.delegates = (NSHashTable <MVMCorePresentationDelegateProtocol>*)[NSHashTable weakObjectsHashTable];
|
self.delegates = (NSHashTable <MVMCorePresentationDelegateProtocol>*)[NSHashTable weakObjectsHashTable];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
@ -308,10 +305,6 @@
|
|||||||
[self dismissToBottom:animated delegate:nil completionHandler:NULL];
|
[self dismissToBottom:animated delegate:nil completionHandler:NULL];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)cancelPresentation {
|
|
||||||
[self.presentationQueue cancelAllOperations];
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Presentation Extra
|
#pragma mark - Presentation Extra
|
||||||
|
|
||||||
- (void)presentViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
|
- (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];
|
MVMCorePresentViewControllerOperation *operation = [[MVMCorePresentViewControllerOperation alloc] initWithPresentingViewController:controllerToPresentOn presentedViewController:viewController animated:animated];
|
||||||
operation.delegate = delegate;
|
operation.delegate = delegate;
|
||||||
operation.completionBlock = completionBlock;
|
operation.completionBlock = completionBlock;
|
||||||
[self.presentationQueue addOperation:operation];
|
[self.navigationQueue addOperation:operation];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -336,7 +329,7 @@
|
|||||||
UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
||||||
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissTopViewController:controllerToPresentOn animated:animated];
|
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissTopViewController:controllerToPresentOn animated:animated];
|
||||||
operation.completionBlock = completionBlock;
|
operation.completionBlock = completionBlock;
|
||||||
[[NSOperationQueue mainQueue] addOperation:operation];
|
[self.navigationQueue addOperation:operation];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +337,7 @@
|
|||||||
|
|
||||||
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:viewController animated:animated];
|
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:viewController animated:animated];
|
||||||
operation.completionBlock = completionBlock;
|
operation.completionBlock = completionBlock;
|
||||||
[[NSOperationQueue mainQueue] addOperation:operation];
|
[self.navigationQueue addOperation:operation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dismissToBottom:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
|
- (void)dismissToBottom:(BOOL)animated delegate:(nullable NSObject<MVMCorePresentationDelegateProtocol>*)delegate completionHandler:(nullable void (^)(void))completionBlock {
|
||||||
@ -353,7 +346,7 @@
|
|||||||
UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
UIViewController *controllerToPresentOn = self.viewControllerToPresentOn ?: [MVMCoreGetterUtility getKeyWindow].rootViewController;
|
||||||
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:controllerToPresentOn animated:animated];
|
MVMCoreDismissViewControllerOperation *operation = [[MVMCoreDismissViewControllerOperation alloc] initAndDismissViewController:controllerToPresentOn animated:animated];
|
||||||
operation.completionBlock = completionBlock;
|
operation.completionBlock = completionBlock;
|
||||||
[[NSOperationQueue mainQueue] addOperation:operation];
|
[self.navigationQueue addOperation:operation];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user