Compare commits
14 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
d48909d9c4 | |
|
|
71eb343abe | |
|
|
95f692c225 | |
|
|
42e62a4dbd | |
|
|
2ed9400c82 | |
|
|
06deaf308c | |
|
|
f3b60362da | |
|
|
9550d4719b | |
|
|
d088879c28 | |
|
|
5ef5a8d832 | |
|
|
0da57dfd53 | |
|
|
240684c788 | |
|
|
c6c729bb52 | |
|
|
7fb3ec03e9 |
|
|
@ -1,6 +1,5 @@
|
||||||
iOS-Slide-Menu [](http://cocoadocs.org/docsets/iOS-Slide-Menu)
|
iOS-Slide-Menu
|
||||||
---------
|
---------
|
||||||
|
|
||||||
iOS Slide Menu built on top of UINavigationController, with configurable buttons, reveal animations, and tap/swiper gesture recognizers.
|
iOS Slide Menu built on top of UINavigationController, with configurable buttons, reveal animations, and tap/swiper gesture recognizers.
|
||||||
|
|
||||||
- [Setup](https://github.com/aryaxt/iOS-Slide-Menu#setup)
|
- [Setup](https://github.com/aryaxt/iOS-Slide-Menu#setup)
|
||||||
|
|
@ -12,10 +11,6 @@ iOS Slide Menu built on top of UINavigationController, with configurable buttons
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Version 1.4.5 Notes
|
|
||||||
---------
|
|
||||||
Enabling shouldRecognizeSimultaneouslyWithGestureRecognizer was causing issues, if you are seeing unexpected gesture behavior delete the pod and reinstall as that method has been removed
|
|
||||||
|
|
||||||
Version 1.4.0 Notes
|
Version 1.4.0 Notes
|
||||||
---------
|
---------
|
||||||
```switchToViewController:withCompletion:``` method has been deprecated. In order to get the exact same behavior use ```popToRootAndSwitchToViewController:withCompletion```
|
```switchToViewController:withCompletion:``` method has been deprecated. In order to get the exact same behavior use ```popToRootAndSwitchToViewController:withCompletion```
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,11 @@
|
||||||
NSLog(@"Opened %@", menu);
|
NSLog(@"Opened %@", menu);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerWillOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||||
|
NSString *menu = note.userInfo[@"menu"];
|
||||||
|
NSLog(@"Opening %@", menu);
|
||||||
|
}];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
|
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||||
NSString *menu = note.userInfo[@"menu"];
|
NSString *menu = note.userInfo[@"menu"];
|
||||||
NSLog(@"Revealed %@", menu);
|
NSLog(@"Revealed %@", menu);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
? [SlideNavigationController sharedInstance].leftMenu
|
? [SlideNavigationController sharedInstance].leftMenu
|
||||||
: [SlideNavigationController sharedInstance].rightMenu;
|
: [SlideNavigationController sharedInstance].rightMenu;
|
||||||
|
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;
|
||||||
CGRect rect = menuViewController.view.frame;
|
CGRect rect = menuViewController.view.frame;
|
||||||
|
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
||||||
|
|
@ -67,9 +67,9 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
if (orientation == UIDeviceOrientationLandscapeRight)
|
if (orientation == UIInterfaceOrientationLandscapeRight)
|
||||||
{
|
{
|
||||||
rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
|
rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (orientation == UIDeviceOrientationPortrait)
|
if (orientation == UIInterfaceOrientationPortrait)
|
||||||
{
|
{
|
||||||
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
|
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
? [SlideNavigationController sharedInstance].leftMenu
|
? [SlideNavigationController sharedInstance].leftMenu
|
||||||
: [SlideNavigationController sharedInstance].rightMenu;
|
: [SlideNavigationController sharedInstance].rightMenu;
|
||||||
|
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation = [SlideNavigationController sharedInstance].interfaceOrientation;
|
||||||
|
|
||||||
NSInteger location = (menu == MenuLeft)
|
NSInteger location = (menu == MenuLeft)
|
||||||
? (self.slideMovement * -1) + (self.slideMovement * progress)
|
? (self.slideMovement * -1) + (self.slideMovement * progress)
|
||||||
|
|
@ -120,13 +120,13 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location : location*-1;
|
rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rect.origin.x = (orientation == UIDeviceOrientationPortrait) ? location : location*-1;
|
rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,8 +147,8 @@
|
||||||
? [SlideNavigationController sharedInstance].leftMenu
|
? [SlideNavigationController sharedInstance].leftMenu
|
||||||
: [SlideNavigationController sharedInstance].rightMenu;
|
: [SlideNavigationController sharedInstance].rightMenu;
|
||||||
|
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation= [SlideNavigationController sharedInstance].interfaceOrientation;
|
||||||
|
|
||||||
CGRect rect = menuViewController.view.frame;
|
CGRect rect = menuViewController.view.frame;
|
||||||
|
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
||||||
|
|
@ -157,7 +157,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
rect.origin.y = 0;
|
rect.origin.y = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ extern NSString * const SlideNavigationControllerDidOpen;
|
||||||
extern NSString *const SlideNavigationControllerDidClose;
|
extern NSString *const SlideNavigationControllerDidClose;
|
||||||
extern NSString *const SlideNavigationControllerDidReveal;
|
extern NSString *const SlideNavigationControllerDidReveal;
|
||||||
|
|
||||||
|
extern NSString *const SlideMenuOpenAfterSwipeKey;
|
||||||
|
|
||||||
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
|
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
|
||||||
@property (nonatomic, assign) BOOL enableSwipeGesture;
|
@property (nonatomic, assign) BOOL enableSwipeGesture;
|
||||||
@property (nonatomic, assign) BOOL enableShadow;
|
@property (nonatomic, assign) BOOL enableShadow;
|
||||||
|
|
@ -58,7 +60,8 @@ extern NSString *const SlideNavigationControllerDidReveal;
|
||||||
@property (nonatomic, assign) CGFloat portraitSlideOffset;
|
@property (nonatomic, assign) CGFloat portraitSlideOffset;
|
||||||
@property (nonatomic, assign) CGFloat landscapeSlideOffset;
|
@property (nonatomic, assign) CGFloat landscapeSlideOffset;
|
||||||
@property (nonatomic, assign) CGFloat panGestureSideOffset;
|
@property (nonatomic, assign) CGFloat panGestureSideOffset;
|
||||||
@property (nonatomic, assign) CGFloat menuRevealAnimationDuration;
|
@property (nonatomic, assign) CGFloat menuOpenAnimationDuration;
|
||||||
|
@property (nonatomic, assign) CGFloat menuCloseAnimationDuration;
|
||||||
@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption;
|
@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption;
|
||||||
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
|
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
|
||||||
|
|
||||||
|
|
@ -75,4 +78,6 @@ extern NSString *const SlideNavigationControllerDidReveal;
|
||||||
- (void)toggleRightMenu;
|
- (void)toggleRightMenu;
|
||||||
- (BOOL)isMenuOpen;
|
- (BOOL)isMenuOpen;
|
||||||
|
|
||||||
|
- (void)prepareMenuForReveal:(Menu)menu;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,12 @@ NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerD
|
||||||
NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose";
|
NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose";
|
||||||
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
|
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
|
||||||
|
|
||||||
|
NSString *const SlideMenuOpenAfterSwipeKey = @"SlideMenuOpenAfterSwipeKey";
|
||||||
|
|
||||||
#define MENU_SLIDE_ANIMATION_DURATION .3
|
#define MENU_SLIDE_ANIMATION_DURATION .3
|
||||||
#define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveEaseOut
|
#define MENU_SLIDE_OPEN_ANIMATION_DURATION .4
|
||||||
|
#define MENU_SLIDE_CLOSE_ANIMATION_DURATION .2
|
||||||
|
#define MENU_SLIDE_ANIMATION_OPTION UIViewAnimationOptionCurveLinear
|
||||||
#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
|
#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
|
||||||
#define MENU_IMAGE @"menu-button"
|
#define MENU_IMAGE @"menu-button"
|
||||||
#define MENU_SHADOW_RADIUS 10
|
#define MENU_SHADOW_RADIUS 10
|
||||||
|
|
@ -119,7 +123,8 @@ static SlideNavigationController *singletonInstance;
|
||||||
|
|
||||||
singletonInstance = self;
|
singletonInstance = self;
|
||||||
|
|
||||||
self.menuRevealAnimationDuration = MENU_SLIDE_ANIMATION_DURATION;
|
self.menuOpenAnimationDuration = MENU_SLIDE_OPEN_ANIMATION_DURATION;
|
||||||
|
self.menuCloseAnimationDuration = MENU_SLIDE_CLOSE_ANIMATION_DURATION;
|
||||||
self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION;
|
self.menuRevealAnimationOption = MENU_SLIDE_ANIMATION_OPTION;
|
||||||
self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
|
self.landscapeSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
|
||||||
self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
|
self.portraitSlideOffset = MENU_DEFAULT_SLIDE_OFFSET;
|
||||||
|
|
@ -140,7 +145,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
|
|
||||||
// When menu open we disable user interaction
|
// When menu open we disable user interaction
|
||||||
// When rotates we want to make sure that userInteraction is enabled again
|
// When rotates we want to make sure that userInteraction is enabled again
|
||||||
[self enableTapGestureToCloseMenu:NO];
|
//[self enableTapGestureToCloseMenu:NO];
|
||||||
|
|
||||||
if (self.menuNeedsLayout)
|
if (self.menuNeedsLayout)
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +156,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && [self isMenuOpen])
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && [self isMenuOpen])
|
||||||
{
|
{
|
||||||
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
|
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
|
||||||
[self openMenu:menu withDuration:0 andCompletion:nil];
|
[self openMenu:menu withCompletion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
self.menuNeedsLayout = NO;
|
self.menuNeedsLayout = NO;
|
||||||
|
|
@ -208,8 +213,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)switchToViewController:(UIViewController *)viewController
|
- (void)switchToViewController:(UIViewController *)viewController
|
||||||
withSlideOutAnimation:(BOOL)slideOutAnimation
|
popType:(PopType)poptype
|
||||||
popType:(PopType)poptype
|
|
||||||
andCompletion:(void (^)())completion
|
andCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
|
if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
|
||||||
|
|
@ -217,95 +221,87 @@ static SlideNavigationController *singletonInstance;
|
||||||
[self closeMenuWithCompletion:completion];
|
[self closeMenuWithCompletion:completion];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void (^switchAndCallCompletion)(BOOL) = ^(BOOL closeMenuBeforeCallingCompletion) {
|
void (^switchAndCallCompletion)(BOOL) = ^(BOOL closeMenuBeforeCallingCompletion) {
|
||||||
if (poptype == PopTypeAll) {
|
if (poptype == PopTypeAll) {
|
||||||
[self setViewControllers:@[viewController]];
|
[self setViewControllers:@[viewController]];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[super popToRootViewControllerAnimated:NO];
|
[super popToRootViewControllerAnimated:NO];
|
||||||
[super pushViewController:viewController animated:NO];
|
[super pushViewController:viewController animated:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closeMenuBeforeCallingCompletion)
|
if (closeMenuBeforeCallingCompletion)
|
||||||
{
|
{
|
||||||
[self closeMenuWithCompletion:^{
|
[self closeMenuWithCompletion:^{
|
||||||
if (completion)
|
if (completion)
|
||||||
completion();
|
completion();
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (completion)
|
if (completion)
|
||||||
completion();
|
completion();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ([self isMenuOpen])
|
// if ([self isMenuOpen])
|
||||||
{
|
// {
|
||||||
if (slideOutAnimation)
|
// if (slideOutAnimation)
|
||||||
{
|
// {
|
||||||
[UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
|
// [UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
|
||||||
delay:0
|
// delay:0
|
||||||
options:self.menuRevealAnimationOption
|
// options:self.menuRevealAnimationOption
|
||||||
animations:^{
|
// animations:^{
|
||||||
CGFloat width = self.horizontalSize;
|
// CGFloat width = self.horizontalSize;
|
||||||
CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
|
// CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
|
||||||
[self moveHorizontallyToLocation:moveLocation];
|
// [self moveHorizontallyToLocation:moveLocation];
|
||||||
} completion:^(BOOL finished) {
|
// } completion:^(BOOL finished) {
|
||||||
switchAndCallCompletion(YES);
|
// switchAndCallCompletion(YES);
|
||||||
}];
|
// }];
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
switchAndCallCompletion(YES);
|
// switchAndCallCompletion(YES);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
switchAndCallCompletion(NO);
|
// switchAndCallCompletion(NO);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
switchAndCallCompletion([self isMenuOpen]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion
|
- (void)switchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeRoot andCompletion:completion];
|
[self switchToViewController:viewController popType:PopTypeRoot andCompletion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController
|
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController
|
||||||
withSlideOutAnimation:(BOOL)slideOutAnimation
|
withSlideOutAnimation:(BOOL)slideOutAnimation
|
||||||
andCompletion:(void (^)())completion
|
andCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self switchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeRoot andCompletion:completion];
|
[self switchToViewController:viewController popType:PopTypeRoot andCompletion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController
|
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController
|
||||||
withCompletion:(void (^)())completion
|
withCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeRoot andCompletion:completion];
|
[self switchToViewController:viewController popType:PopTypeRoot andCompletion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
|
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
|
||||||
withSlideOutAnimation:(BOOL)slideOutAnimation
|
withSlideOutAnimation:(BOOL)slideOutAnimation
|
||||||
andCompletion:(void (^)())completion
|
andCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self switchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeAll andCompletion:completion];
|
[self switchToViewController:viewController popType:PopTypeAll andCompletion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
|
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
|
||||||
withCompletion:(void (^)())completion
|
withCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeAll andCompletion:completion];
|
[self switchToViewController:viewController popType:PopTypeAll andCompletion:completion];
|
||||||
}
|
|
||||||
|
|
||||||
- (void)closeMenuWithCompletion:(void (^)())completion
|
|
||||||
{
|
|
||||||
[self closeMenuWithDuration:self.menuRevealAnimationDuration andCompletion:completion];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion
|
|
||||||
{
|
|
||||||
[self openMenu:menu withDuration:self.menuRevealAnimationDuration andCompletion:completion];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleLeftMenu
|
- (void)toggleLeftMenu
|
||||||
|
|
@ -472,8 +468,23 @@ static SlideNavigationController *singletonInstance;
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^)())completion
|
- (CGFloat)openingPart
|
||||||
{
|
{
|
||||||
|
CGFloat slideOffset = self.slideOffset;
|
||||||
|
CGFloat absHorizontalLocation = (CGFloat)fabs(self.horizontalLocation);
|
||||||
|
|
||||||
|
return MIN(1.f, absHorizontalLocation/slideOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion
|
||||||
|
{
|
||||||
|
[self openMenu:menu afterSwipe:NO withCompletion:completion];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)openMenu:(Menu)menu afterSwipe:(BOOL)afterSwipe withCompletion:(void (^)())completion
|
||||||
|
{
|
||||||
|
NSTimeInterval duration = self.menuOpenAnimationDuration * (1.f - [self openingPart]);
|
||||||
|
|
||||||
[self enableTapGestureToCloseMenu:YES];
|
[self enableTapGestureToCloseMenu:YES];
|
||||||
|
|
||||||
[self prepareMenuForReveal:menu];
|
[self prepareMenuForReveal:menu];
|
||||||
|
|
@ -491,12 +502,16 @@ static SlideNavigationController *singletonInstance;
|
||||||
if (completion)
|
if (completion)
|
||||||
completion();
|
completion();
|
||||||
|
|
||||||
[self postNotificationWithName:SlideNavigationControllerDidOpen forMenu:menu];
|
[self postNotificationWithName:SlideNavigationControllerDidOpen forMenu:menu withExtParams:@{
|
||||||
|
SlideMenuOpenAfterSwipeKey : @(afterSwipe)
|
||||||
|
}];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completion
|
- (void)closeMenuWithCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
|
NSTimeInterval duration = self.menuCloseAnimationDuration * [self openingPart];
|
||||||
|
|
||||||
[self enableTapGestureToCloseMenu:NO];
|
[self enableTapGestureToCloseMenu:NO];
|
||||||
|
|
||||||
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
|
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
|
||||||
|
|
@ -520,7 +535,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
- (void)moveHorizontallyToLocation:(CGFloat)location
|
- (void)moveHorizontallyToLocation:(CGFloat)location
|
||||||
{
|
{
|
||||||
CGRect rect = self.view.frame;
|
CGRect rect = self.view.frame;
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation = self.interfaceOrientation;
|
||||||
Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight;
|
Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight;
|
||||||
|
|
||||||
if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) {
|
if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) {
|
||||||
|
|
@ -534,14 +549,14 @@ static SlideNavigationController *singletonInstance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
rect.origin.x = 0;
|
rect.origin.x = 0;
|
||||||
rect.origin.y = (orientation == UIDeviceOrientationLandscapeRight) ? location : location*-1;
|
rect.origin.y = (orientation == UIInterfaceOrientationLandscapeRight) ? location : location*-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rect.origin.x = (orientation == UIDeviceOrientationPortrait) ? location : location*-1;
|
rect.origin.x = (orientation == UIInterfaceOrientationPortrait) ? location : location*-1;
|
||||||
rect.origin.y = 0;
|
rect.origin.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -570,18 +585,16 @@ static SlideNavigationController *singletonInstance;
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
|
||||||
|
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
|
||||||
{
|
{
|
||||||
// For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20
|
// For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20
|
||||||
rect.origin.x = (orientation == UIDeviceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT;
|
rect.origin.x = (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) ? 0 : STATUS_BAR_HEIGHT;
|
||||||
rect.size.width = self.view.frame.size.width-STATUS_BAR_HEIGHT;
|
rect.size.width = self.view.frame.size.width-STATUS_BAR_HEIGHT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20
|
// For some reasons in landscape below the status bar is considered y=0, but in portrait it's considered y=20
|
||||||
rect.origin.y = (orientation == UIDeviceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0;
|
rect.origin.y = (self.interfaceOrientation == UIInterfaceOrientationPortrait) ? STATUS_BAR_HEIGHT : 0;
|
||||||
rect.size.height = self.view.frame.size.height-STATUS_BAR_HEIGHT;
|
rect.size.height = self.view.frame.size.height-STATUS_BAR_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,7 +623,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
- (CGFloat)horizontalLocation
|
- (CGFloat)horizontalLocation
|
||||||
{
|
{
|
||||||
CGRect rect = self.view.frame;
|
CGRect rect = self.view.frame;
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation = self.interfaceOrientation;
|
||||||
|
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
||||||
{
|
{
|
||||||
|
|
@ -618,15 +631,15 @@ static SlideNavigationController *singletonInstance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
return (orientation == UIDeviceOrientationLandscapeRight)
|
return (orientation == UIInterfaceOrientationLandscapeRight)
|
||||||
? rect.origin.y
|
? rect.origin.y
|
||||||
: rect.origin.y*-1;
|
: rect.origin.y*-1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (orientation == UIDeviceOrientationPortrait)
|
return (orientation == UIInterfaceOrientationPortrait)
|
||||||
? rect.origin.x
|
? rect.origin.x
|
||||||
: rect.origin.x*-1;
|
: rect.origin.x*-1;
|
||||||
}
|
}
|
||||||
|
|
@ -636,7 +649,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
- (CGFloat)horizontalSize
|
- (CGFloat)horizontalSize
|
||||||
{
|
{
|
||||||
CGRect rect = self.view.frame;
|
CGRect rect = self.view.frame;
|
||||||
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
|
UIInterfaceOrientation orientation = self.interfaceOrientation;
|
||||||
|
|
||||||
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
|
||||||
{
|
{
|
||||||
|
|
@ -644,7 +657,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (UIDeviceOrientationIsLandscape(orientation))
|
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||||
{
|
{
|
||||||
return rect.size.height;
|
return rect.size.height;
|
||||||
}
|
}
|
||||||
|
|
@ -657,27 +670,22 @@ static SlideNavigationController *singletonInstance;
|
||||||
|
|
||||||
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu
|
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu
|
||||||
{
|
{
|
||||||
NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
|
[self postNotificationWithName:name forMenu:menu withExtParams:nil];
|
||||||
NSDictionary *userInfo = @{ NOTIFICATION_USER_INFO_MENU : menuString };
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - UINavigationControllerDelegate Methods -
|
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu withExtParams:(NSDictionary *)extParams
|
||||||
|
|
||||||
- (void)navigationController:(UINavigationController *)navigationController
|
|
||||||
willShowViewController:(UIViewController *)viewController
|
|
||||||
animated:(BOOL)animated
|
|
||||||
{
|
{
|
||||||
if ([self shouldDisplayMenu:MenuLeft forViewController:viewController])
|
NSMutableDictionary *userInfo = extParams ? [extParams mutableCopy] : [NSMutableDictionary dictionary];
|
||||||
viewController.navigationItem.leftBarButtonItem = [self barButtonItemForMenu:MenuLeft];
|
|
||||||
|
NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
|
||||||
if ([self shouldDisplayMenu:MenuRight forViewController:viewController])
|
userInfo[NOTIFICATION_USER_INFO_MENU] = menuString;
|
||||||
viewController.navigationItem.rightBarButtonItem = [self barButtonItemForMenu:MenuRight];
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:[userInfo copy]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)slideOffset
|
- (CGFloat)slideOffset
|
||||||
{
|
{
|
||||||
return (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
|
return (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
|
||||||
? self.landscapeSlideOffset
|
? self.landscapeSlideOffset
|
||||||
: self.portraitSlideOffset;
|
: self.portraitSlideOffset;
|
||||||
}
|
}
|
||||||
|
|
@ -735,8 +743,8 @@ static SlideNavigationController *singletonInstance;
|
||||||
else
|
else
|
||||||
currentMenu = (translation.x > 0) ? MenuLeft : MenuRight;
|
currentMenu = (translation.x > 0) ? MenuLeft : MenuRight;
|
||||||
|
|
||||||
if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
|
// if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
[self prepareMenuForReveal:currentMenu];
|
[self prepareMenuForReveal:currentMenu];
|
||||||
|
|
||||||
|
|
@ -773,11 +781,11 @@ static SlideNavigationController *singletonInstance;
|
||||||
if (currentX > 0)
|
if (currentX > 0)
|
||||||
{
|
{
|
||||||
if ([self shouldDisplayMenu:menu forViewController:self.visibleViewController])
|
if ([self shouldDisplayMenu:menu forViewController:self.visibleViewController])
|
||||||
[self openMenu:(velocity.x > 0) ? MenuLeft : MenuRight withDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
|
[self openMenu:(velocity.x > 0) ? MenuLeft : MenuRight afterSwipe:YES withCompletion:nil];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self closeMenuWithDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
|
[self closeMenuWithCompletion:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Moving Left
|
// Moving Left
|
||||||
|
|
@ -785,12 +793,12 @@ static SlideNavigationController *singletonInstance;
|
||||||
{
|
{
|
||||||
if (currentX > 0)
|
if (currentX > 0)
|
||||||
{
|
{
|
||||||
[self closeMenuWithDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
|
[self closeMenuWithCompletion:nil];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([self shouldDisplayMenu:menu forViewController:self.visibleViewController])
|
if ([self shouldDisplayMenu:menu forViewController:self.visibleViewController])
|
||||||
[self openMenu:(velocity.x > 0) ? MenuLeft : MenuRight withDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
|
[self openMenu:(velocity.x > 0) ? MenuLeft : MenuRight afterSwipe:YES withCompletion:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -799,7 +807,7 @@ static SlideNavigationController *singletonInstance;
|
||||||
if (currentXOffset < (self.horizontalSize - self.slideOffset)/2)
|
if (currentXOffset < (self.horizontalSize - self.slideOffset)/2)
|
||||||
[self closeMenuWithCompletion:nil];
|
[self closeMenuWithCompletion:nil];
|
||||||
else
|
else
|
||||||
[self openMenu:(currentX > 0) ? MenuLeft : MenuRight withCompletion:nil];
|
[self openMenu:(currentX > 0) ? MenuLeft : MenuRight afterSwipe:YES withCompletion:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue