@@ -42,6 +42,10 @@ @interface SlideNavigationController() <UIGestureRecognizerDelegate>
4242
4343@implementation SlideNavigationController
4444
45+ NSString * const SlideNavigationControllerDidOpen = @" SlideNavigationControllerDidOpen" ;
46+ NSString * const SlideNavigationControllerDidClose = @" SlideNavigationControllerDidClose" ;
47+ NSString *const SlideNavigationControllerDidReveal = @" SlideNavigationControllerDidReveal" ;
48+
4549#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (v ) ([[[UIDevice currentDevice ] systemVersion ] compare: v options: NSNumericSearch] != NSOrderedAscending)
4650#define MENU_SLIDE_ANIMATION_DURATION .3
4751#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
@@ -51,6 +55,9 @@ @implementation SlideNavigationController
5155#define MENU_DEFAULT_SLIDE_OFFSET 60
5256#define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200
5357#define STATUS_BAR_HEIGHT 20
58+ #define NOTIFICATION_USER_INFO_MENU_LEFT @" left"
59+ #define NOTIFICATION_USER_INFO_MENU_RIGHT @" right"
60+ #define NOTIFICATION_USER_INFO_MENU @" menu"
5461
5562static SlideNavigationController *singletonInstance;
5663
@@ -462,12 +469,16 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^)
462469 completion: ^(BOOL finished) {
463470 if (completion)
464471 completion ();
472+
473+ [self postNotificationWithName: SlideNavigationControllerDidOpen forMenu: menu];
465474 }];
466475}
467476
468477- (void )closeMenuWithDuration : (float )duration andCompletion : (void (^)())completion
469478{
470479 [self enableTapGestureToCloseMenu: NO ];
480+
481+ Menu menu = (self.horizontalLocation > 0 ) ? MenuLeft : MenuRight;
471482
472483 [UIView animateWithDuration: duration
473484 delay: 0
@@ -480,6 +491,8 @@ - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completi
480491 completion: ^(BOOL finished) {
481492 if (completion)
482493 completion ();
494+
495+ [self postNotificationWithName: SlideNavigationControllerDidClose forMenu: menu];
483496 }];
484497}
485498
@@ -488,6 +501,10 @@ - (void)moveHorizontallyToLocation:(CGFloat)location
488501 CGRect rect = self.view .frame ;
489502 UIInterfaceOrientation orientation = self.interfaceOrientation ;
490503 Menu menu = (self.horizontalLocation >= 0 && location >= 0 ) ? MenuLeft : MenuRight;
504+
505+ if ((location > 0 && self.horizontalLocation <= 0 ) || (location < 0 && self.horizontalLocation >= 0 )) {
506+ [self postNotificationWithName: SlideNavigationControllerDidReveal forMenu: (location > 0 ) ? MenuLeft : MenuRight];
507+ }
491508
492509 if (UIInterfaceOrientationIsLandscape (orientation))
493510 {
@@ -596,6 +613,13 @@ - (CGFloat)horizontalSize
596613 }
597614}
598615
616+ - (void )postNotificationWithName : (NSString *)name forMenu : (Menu)menu
617+ {
618+ NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
619+ NSDictionary *userInfo = @{ NOTIFICATION_USER_INFO_MENU : menuString };
620+ [[NSNotificationCenter defaultCenter ] postNotificationName: name object: nil userInfo: userInfo];
621+ }
622+
599623#pragma mark - UINavigationControllerDelegate Methods -
600624
601625- (void )navigationController : (UINavigationController *)navigationController
@@ -624,7 +648,6 @@ - (void)leftMenuSelected:(id)sender
624648 [self closeMenuWithCompletion: nil ];
625649 else
626650 [self openMenu: MenuLeft withCompletion: nil ];
627-
628651}
629652
630653- (void )righttMenuSelected : (id )sender
@@ -670,6 +693,9 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer
670693 else
671694 currentMenu = (translation.x > 0 ) ? MenuLeft : MenuRight;
672695
696+ if (![self shouldDisplayMenu: currentMenu forViewController: self .topViewController])
697+ return ;
698+
673699 [self prepareMenuForReveal: currentMenu];
674700
675701 if (aPanRecognizer.state == UIGestureRecognizerStateBegan)
0 commit comments