From dbedbfeac190880ef5a14ca9b8e5a0212d5de229 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Wed, 6 Jun 2018 11:51:46 -0400 Subject: [PATCH] move protocol to core --- MVMCore/MVMCore.xcodeproj/project.pbxproj | 4 ++++ MVMCore/MVMCore/MVMCore.h | 1 + .../MVMCoreNavigationOperation.m | 9 ++++++--- .../MVMCorePresentationDelegateProtocol.h | 2 +- .../MVMCoreViewControllerAnimatedTransitioning.h | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 MVMCore/MVMCore/PresentationHandling/MVMCoreViewControllerAnimatedTransitioning.h diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index f1d48bc..6782c50 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 8876D5F51FB50AB000EB2E3D /* UILabel+MFCustom.m in Sources */ = {isa = PBXBuildFile; fileRef = 8876D5E71FB50AB000EB2E3D /* UILabel+MFCustom.m */; }; 88D1FBE11FCCCBA100338A3A /* MVMCoreMainSplitViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 88D1FBDF1FCCCADC00338A3A /* MVMCoreMainSplitViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; 88D1FBE21FCCCBA500338A3A /* PanelProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 88D1FBE01FCCCB2C00338A3A /* PanelProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A332F33F20C7231700DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h in Headers */ = {isa = PBXBuildFile; fileRef = A332F33E20C7231600DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF26DDAE1FCE6A37004E8F65 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = AF26DDB01FCE6A37004E8F65 /* Localizable.strings */; }; AF43A5771FBA5B7C008E9347 /* MVMCoreJSONConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = AF43A5751FBA5B7C008E9347 /* MVMCoreJSONConstants.h */; settings = {ATTRIBUTES = (Public, ); }; }; AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = AF43A5761FBA5B7C008E9347 /* MVMCoreJSONConstants.m */; }; @@ -166,6 +167,7 @@ 8876D5E71FB50AB000EB2E3D /* UILabel+MFCustom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+MFCustom.m"; sourceTree = ""; }; 88D1FBDF1FCCCADC00338A3A /* MVMCoreMainSplitViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreMainSplitViewProtocol.h; sourceTree = ""; }; 88D1FBE01FCCCB2C00338A3A /* PanelProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanelProtocol.h; sourceTree = ""; }; + A332F33E20C7231600DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreViewControllerAnimatedTransitioning.h; sourceTree = ""; }; AF26DDAF1FCE6A37004E8F65 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; AF43A5751FBA5B7C008E9347 /* MVMCoreJSONConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreJSONConstants.h; sourceTree = ""; }; AF43A5761FBA5B7C008E9347 /* MVMCoreJSONConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreJSONConstants.m; sourceTree = ""; }; @@ -488,6 +490,7 @@ AFBB96771FBA3A9A0008D868 /* MVMCorePresentationDelegateProtocol.h */, AFBB96781FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.h */, AFBB96791FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m */, + A332F33E20C7231600DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h */, ); path = PresentationHandling; sourceTree = ""; @@ -619,6 +622,7 @@ 881D26951FCC9D180079C521 /* MVMCoreErrorObject.h in Headers */, AFBB96341FBA34310008D868 /* MVMCoreErrorConstants.h in Headers */, 88D1FBE21FCCCBA500338A3A /* PanelProtocol.h in Headers */, + A332F33F20C7231700DCD9D9 /* MVMCoreViewControllerAnimatedTransitioning.h in Headers */, AFBB968D1FBA3A9A0008D868 /* MVMCoreNavigationHandler.h in Headers */, AFBB96A51FBA3A9A0008D868 /* MVMCoreTopAlertOperation.h in Headers */, AFBB96A11FBA3A9A0008D868 /* MVMCoreTopAlertAnimationDelegateProtocol.h in Headers */, diff --git a/MVMCore/MVMCore/MVMCore.h b/MVMCore/MVMCore/MVMCore.h index e3402cf..3dabd81 100644 --- a/MVMCore/MVMCore/MVMCore.h +++ b/MVMCore/MVMCore/MVMCore.h @@ -77,6 +77,7 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[]; #import #import #import +#import // Action Handling #import diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m index c037aa4..60dfd9e 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreNavigationOperation.m @@ -12,6 +12,7 @@ #import "MVMCoreViewControllerProtocol.h" #import "MVMCoreLoggingHandler.h" #import "MVMCoreLoadingOverlayHandler.h" +#import "MVMCoreViewControllerAnimatedTransitioning.h" @interface MVMCoreNavigationOperation () @@ -241,7 +242,9 @@ - (nullable id )navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC { if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:animationControllerForOperation:fromViewController:toViewController:)]) { id animatedTransitioning = [self.delegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC]; - [animatedTransitioning addObserver:self forKeyPath:@"interactiveTransitionCanceled" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil]; + if ([animatedTransitioning conformsToProtocol:@protocol(MVMCoreViewControllerAnimatedTransitioning)]) { + [animatedTransitioning addObserver:self forKeyPath:@"interactiveTransitionCanceled" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil]; + } return animatedTransitioning; } else { return nil; @@ -264,8 +267,8 @@ //When interactive transition canceled, the destination viewController should be removed from navigationController [self.navigationObject.viewController removeFromParentViewController]; [self markAsFinished]; - if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:interactiveTransitionGetCanceled:)]) { - [self.delegate navigationController:self.navigationObject.navigationController interactiveTransitionGetCanceled: true]; + if (self.delegate && [self.delegate respondsToSelector:@selector(navigationController:interactiveTransitionWasCanceled:)]) { + [self.delegate navigationController:self.navigationObject.navigationController interactiveTransitionWasCanceled: true]; } } } else { diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h index c57afab..8dc27f4 100644 --- a/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h +++ b/MVMCore/MVMCore/PresentationHandling/MVMCorePresentationDelegateProtocol.h @@ -20,7 +20,7 @@ - (void)navigationController:(nonnull UINavigationController *)navigationController displayedViewController:(nonnull UIViewController *)viewController; // Called when interactive transition get canceled -- (void)navigationController:(nonnull UINavigationController *)navigationController interactiveTransitionGetCanceled:(BOOL)canceled; +- (void)navigationController:(nonnull UINavigationController *)navigationController interactiveTransitionWasCanceled:(BOOL)canceled; - (nullable id )navigationController:(nonnull UINavigationController *)navigationController diff --git a/MVMCore/MVMCore/PresentationHandling/MVMCoreViewControllerAnimatedTransitioning.h b/MVMCore/MVMCore/PresentationHandling/MVMCoreViewControllerAnimatedTransitioning.h new file mode 100644 index 0000000..9a4a384 --- /dev/null +++ b/MVMCore/MVMCore/PresentationHandling/MVMCoreViewControllerAnimatedTransitioning.h @@ -0,0 +1,16 @@ +// +// MVMCoreViewControllerAnimatedTransitioning.h +// MVMCore +// +// Created by Chen, Mingyuan on 6/5/18. +// Copyright © 2018 myverizon. All rights reserved. +// + +#import + +@protocol MVMCoreViewControllerAnimatedTransitioning + +@optional +@property (nonatomic) BOOL interactiveTransitionCanceled; + +@end