From b907943bb1928bc684790674e6fa0e063a264209 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Oct 2021 12:35:28 -0500 Subject: [PATCH 1/4] added methods for prepareForDisplay protocols Signed-off-by: Matt Bruce --- MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h | 3 +++ .../PresentationHandling/MVMCorePresentationDelegateProtocol.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h index 4407a49..f628227 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h @@ -22,6 +22,9 @@ /// Notifies the manager that the controller received new data. - (void)newDataReceivedInViewController:(nonnull UIViewController *)viewController; +/// Call on a manager when a view controller is being prepared to be displayed. (Mostly called by other managers) +- (void)prepareDisplayForViewController:(nonnull UIViewController *)viewController; + /// Call on a manager when a view controller will be displayed. (Mostly called by other managers) - (void)willDisplayViewController:(nonnull UIViewController *)viewController; diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h index 8dc27f4..4ecb774 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h +++ b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h @@ -12,6 +12,8 @@ @protocol MVMCorePresentationDelegateProtocol @optional +// Called when a view controller is about to be added to a navigation controller +- (void)navigationController:(nonnull UINavigationController *)navigationController prepareDisplayForViewController:(nonnull UIViewController *)viewController; // Called when a view controller will be displayed on a navigation controller - (void)navigationController:(nonnull UINavigationController *)navigationController willDisplayViewController:(nonnull UIViewController *)viewController; From 7bc26a8e46703d484f623c7b88611dbd6405a077 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Oct 2021 12:36:04 -0500 Subject: [PATCH 2/4] implemented delegate callbacks for prepareForDisplay Signed-off-by: Matt Bruce --- .../MVMCoreNavigationOperation.m | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m index b700005..5865ebf 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m @@ -213,12 +213,14 @@ - (void)pushViewController { // Although the post animation state is currently fine with push, store anyway as a precaution self.futureViewControllers = [self.navigationObject.navigationController.viewControllers arrayByAddingObject:self.navigationObject.viewController]; + [self navigationController:self.navigationObject.navigationController prepareDisplayForViewController:self.navigationObject.viewController]; [self.navigationObject.navigationController pushViewController:self.navigationObject.viewController animated:self.navigationObject.animated]; } - (void)setViewControllers:(NSArray *)viewControllers { self.futureViewControllers = viewControllers; if (![self.navigationObject.navigationController.viewControllers isEqualToArray:viewControllers]) { + [self navigationController:self.navigationObject.navigationController prepareDisplayForViewController:viewControllers.lastObject]; [self.navigationObject.navigationController setViewControllers:viewControllers animated:self.navigationObject.animated]; } else { @@ -227,6 +229,21 @@ } } +- (void) navigationController:(UINavigationController *)navigationController prepareDisplayForViewController:(UIViewController *)viewController{ + + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:prepareDisplayForViewController:)]) { + [self.delegate navigationController:navigationController + prepareDisplayForViewController:viewController]; + } + + for (NSObject *delegate in [MVMCoreNavigationHandler sharedNavigationHandler].delegates.allObjects) { + if (delegate && [delegate respondsToSelector:@selector(navigationController:prepareDisplayForViewController:)]) { + [delegate navigationController:navigationController + prepareDisplayForViewController:viewController]; + } + } +} + - (void)markAsFinished { self.navigationObject.navigationController.delegate = nil; if (self.navigationObject.stopLoadingOverlay) { @@ -241,7 +258,6 @@ } #pragma mark - Delegate - - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (self.navigationObject.stopLoadingOverlay) { [[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:YES]; From 54ba48bb124b34b838ef80d9ac473425a46ee489 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 14 Oct 2021 12:36:26 -0500 Subject: [PATCH 3/4] implemented prepareForDisplay protocol Signed-off-by: Matt Bruce --- MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index 2b49d66..957b3f1 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -842,6 +842,11 @@ } #pragma mark - Presentation Delegate +- (void)navigationController:(UINavigationController *)navigationController prepareDisplayForViewController:(UIViewController *)viewController { + if ([self.delegateObject.presentationDelegate respondsToSelector:@selector(navigationController:prepareDisplayForViewController:)]) { + [self.delegateObject.presentationDelegate navigationController:navigationController prepareDisplayForViewController:viewController]; + } +} - (void)navigationController:(UINavigationController *)navigationController willDisplayViewController:(UIViewController *)viewController { From bbad2e84377668de4ffdece63bd415be2a0a32b2 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 18 Oct 2021 13:13:05 -0400 Subject: [PATCH 4/4] formatting, remove manager stuff --- MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h | 3 --- .../MVMCore/PresentationHandling/MVMCoreNavigationOperation.m | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h index f628227..4407a49 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreViewManagerProtocol.h @@ -22,9 +22,6 @@ /// Notifies the manager that the controller received new data. - (void)newDataReceivedInViewController:(nonnull UIViewController *)viewController; -/// Call on a manager when a view controller is being prepared to be displayed. (Mostly called by other managers) -- (void)prepareDisplayForViewController:(nonnull UIViewController *)viewController; - /// Call on a manager when a view controller will be displayed. (Mostly called by other managers) - (void)willDisplayViewController:(nonnull UIViewController *)viewController; diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m index 5865ebf..794975d 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m @@ -229,7 +229,8 @@ } } -- (void) navigationController:(UINavigationController *)navigationController prepareDisplayForViewController:(UIViewController *)viewController{ +// Notify delegates to prepare for the controller to be added to the navigation controller. +- (void)navigationController:(UINavigationController *)navigationController prepareDisplayForViewController:(UIViewController *)viewController { if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:prepareDisplayForViewController:)]) { [self.delegate navigationController:navigationController