Compare commits
35 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
d48909d9c4 | |
|
|
71eb343abe | |
|
|
95f692c225 | |
|
|
42e62a4dbd | |
|
|
2ed9400c82 | |
|
|
06deaf308c | |
|
|
f3b60362da | |
|
|
9550d4719b | |
|
|
d088879c28 | |
|
|
5ef5a8d832 | |
|
|
0da57dfd53 | |
|
|
240684c788 | |
|
|
c6c729bb52 | |
|
|
7fb3ec03e9 | |
|
|
a9ca4b49b0 | |
|
|
363306a5c7 | |
|
|
4ce138d4e9 | |
|
|
43cb763d79 | |
|
|
8681050dd0 | |
|
|
98591515e6 | |
|
|
1a1b8523ec | |
|
|
3c1b09fe74 | |
|
|
6a9333e81b | |
|
|
07e14208be | |
|
|
22c03d987e | |
|
|
0e1ac70eeb | |
|
|
2cf2b31c62 | |
|
|
f9909b669f | |
|
|
792fb82d6b | |
|
|
eb2de83daf | |
|
|
2786733c82 | |
|
|
9d38ca4c76 | |
|
|
c2638e8935 | |
|
|
907eee38e8 | |
|
|
4c66f6c25c |
|
|
@ -33,9 +33,9 @@ Setup
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||||
{
|
{
|
||||||
LeftMenuViewController *leftMenu = [[LeftMenuViewController alloc] init];
|
LeftMenuViewController *leftMenu = [[LeftMenuViewController alloc] init];
|
||||||
RightMenuViewController *righMenu = [[RightMenuViewController alloc] init];
|
RightMenuViewController *rightMenu = [[RightMenuViewController alloc] init];
|
||||||
|
|
||||||
[SlideNavigationController sharedInstance].righMenu = rightMenu;
|
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
|
||||||
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
|
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
|
||||||
|
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
|
|
@ -96,6 +96,10 @@ Behaves exactly the same as leftbarButtonItem, but it's used as the right button
|
||||||
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in portrait mode
|
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in portrait mode
|
||||||
###### landscapeSlideOffset
|
###### landscapeSlideOffset
|
||||||
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in landscape mode
|
Default value of portraitSlideOffset is 60. This means when the menu is open, the width of the visible portion of the navigation controller is 60 pixels in landscape mode
|
||||||
|
###### menuRevealAnimationDuration
|
||||||
|
Default value of animation duration is .3, this property allows configuring animation duration
|
||||||
|
###### menuRevealAnimationOption
|
||||||
|
Defaults to UIViewAnimationOptionCurveEaseOut, you can change this property to configure animation options
|
||||||
###### menuRevealAnimator
|
###### menuRevealAnimator
|
||||||
menuRevealAnimator is used to animate the left/right menu during reveal. The default value is nil, that means no animations occure when opening/closing the menu.
|
menuRevealAnimator is used to animate the left/right menu during reveal. The default value is nil, that means no animations occure when opening/closing the menu.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,7 @@
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
|
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
|
||||||
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
|
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
WRAPPER_EXTENSION = app;
|
WRAPPER_EXTENSION = app;
|
||||||
};
|
};
|
||||||
|
|
@ -536,6 +537,7 @@
|
||||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||||
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
|
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
|
||||||
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
|
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
WRAPPER_EXTENSION = app;
|
WRAPPER_EXTENSION = app;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
|
[SlideNavigationController sharedInstance].rightMenu = rightMenu;
|
||||||
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
|
[SlideNavigationController sharedInstance].leftMenu = leftMenu;
|
||||||
|
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
|
||||||
|
|
||||||
// Creating a custom bar button for right menu
|
// Creating a custom bar button for right menu
|
||||||
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
|
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
|
||||||
|
|
@ -41,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);
|
||||||
|
|
|
||||||
|
|
@ -80,31 +80,38 @@
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
id <SlideNavigationContorllerAnimator> revealAnimator;
|
id <SlideNavigationContorllerAnimator> revealAnimator;
|
||||||
|
CGFloat animationDuration = 0;
|
||||||
|
|
||||||
switch (indexPath.row)
|
switch (indexPath.row)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
revealAnimator = nil;
|
revealAnimator = nil;
|
||||||
|
animationDuration = .19;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
|
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
|
||||||
|
animationDuration = .19;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
|
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
|
||||||
|
animationDuration = .18;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100];
|
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.8 fadeColor:[UIColor blackColor] andSlideMovement:100];
|
||||||
|
animationDuration = .19;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
|
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
|
||||||
|
animationDuration = .22;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blackColor] andMinimumScale:.8];
|
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blackColor] andMinimumScale:.8];
|
||||||
|
animationDuration = .22;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -112,6 +119,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
|
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
|
||||||
|
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = animationDuration;
|
||||||
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
|
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>${EXECUTABLE_NAME}</string>
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>com.aryaxt.${PRODUCT_NAME:rfc1034identifier}</string>
|
<string>com.aryaxt.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
|
|
|
||||||
|
|
@ -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,6 +60,9 @@ 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 menuOpenAnimationDuration;
|
||||||
|
@property (nonatomic, assign) CGFloat menuCloseAnimationDuration;
|
||||||
|
@property (nonatomic, assign) UIViewAnimationOptions menuRevealAnimationOption;
|
||||||
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
|
@property (nonatomic, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
|
||||||
|
|
||||||
+ (SlideNavigationController *)sharedInstance;
|
+ (SlideNavigationController *)sharedInstance;
|
||||||
|
|
@ -73,4 +78,6 @@ extern NSString *const SlideNavigationControllerDidReveal;
|
||||||
- (void)toggleRightMenu;
|
- (void)toggleRightMenu;
|
||||||
- (BOOL)isMenuOpen;
|
- (BOOL)isMenuOpen;
|
||||||
|
|
||||||
|
- (void)prepareMenuForReveal:(Menu)menu;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -47,7 +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_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
|
||||||
|
|
@ -101,6 +106,16 @@ static SlideNavigationController *singletonInstance;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id)initWithNavigationBarClass:(Class)navigationBarClass toolbarClass:(Class)toolbarClass
|
||||||
|
{
|
||||||
|
if (self = [super initWithNavigationBarClass:navigationBarClass toolbarClass:toolbarClass])
|
||||||
|
{
|
||||||
|
[self setup];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setup
|
- (void)setup
|
||||||
{
|
{
|
||||||
if (singletonInstance)
|
if (singletonInstance)
|
||||||
|
|
@ -108,6 +123,9 @@ static SlideNavigationController *singletonInstance;
|
||||||
|
|
||||||
singletonInstance = self;
|
singletonInstance = self;
|
||||||
|
|
||||||
|
self.menuOpenAnimationDuration = MENU_SLIDE_OPEN_ANIMATION_DURATION;
|
||||||
|
self.menuCloseAnimationDuration = MENU_SLIDE_CLOSE_ANIMATION_DURATION;
|
||||||
|
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;
|
||||||
self.panGestureSideOffset = 0;
|
self.panGestureSideOffset = 0;
|
||||||
|
|
@ -127,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)
|
||||||
{
|
{
|
||||||
|
|
@ -138,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;
|
||||||
|
|
@ -147,6 +165,8 @@ static SlideNavigationController *singletonInstance;
|
||||||
|
|
||||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
||||||
{
|
{
|
||||||
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||||
|
|
||||||
self.menuNeedsLayout = YES;
|
self.menuNeedsLayout = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,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])
|
||||||
|
|
@ -202,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) ? MENU_SLIDE_ANIMATION_DURATION : 0
|
// [UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
|
||||||
delay:0
|
// delay:0
|
||||||
options:UIViewAnimationOptionCurveEaseOut
|
// 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:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion
|
|
||||||
{
|
|
||||||
[self openMenu:menu withDuration:MENU_SLIDE_ANIMATION_DURATION andCompletion:completion];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleLeftMenu
|
- (void)toggleLeftMenu
|
||||||
|
|
@ -457,15 +468,30 @@ 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];
|
||||||
|
|
||||||
[UIView animateWithDuration:duration
|
[UIView animateWithDuration:duration
|
||||||
delay:0
|
delay:0
|
||||||
options:UIViewAnimationOptionCurveEaseOut
|
options:self.menuRevealAnimationOption
|
||||||
animations:^{
|
animations:^{
|
||||||
CGRect rect = self.view.frame;
|
CGRect rect = self.view.frame;
|
||||||
CGFloat width = self.horizontalSize;
|
CGFloat width = self.horizontalSize;
|
||||||
|
|
@ -476,19 +502,23 @@ 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;
|
||||||
|
|
||||||
[UIView animateWithDuration:duration
|
[UIView animateWithDuration:duration
|
||||||
delay:0
|
delay:0
|
||||||
options:UIViewAnimationOptionCurveEaseOut
|
options:self.menuRevealAnimationOption
|
||||||
animations:^{
|
animations:^{
|
||||||
CGRect rect = self.view.frame;
|
CGRect rect = self.view.frame;
|
||||||
rect.origin.x = 0;
|
rect.origin.x = 0;
|
||||||
|
|
@ -640,22 +670,17 @@ 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
|
||||||
|
|
@ -718,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];
|
||||||
|
|
||||||
|
|
@ -756,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
|
||||||
|
|
@ -768,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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -782,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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'iOS-Slide-Menu'
|
s.name = 'iOS-Slide-Menu'
|
||||||
s.version = '1.4.4'
|
s.version = '1.4.6'
|
||||||
s.summary = 'A Slide Menu for iOS'
|
s.summary = 'A Slide Menu for iOS'
|
||||||
s.homepage = 'https://github.com/aryaxt/iOS-Slide-Menu'
|
s.homepage = 'https://github.com/aryaxt/iOS-Slide-Menu'
|
||||||
s.license = {
|
s.license = {
|
||||||
|
|
@ -8,9 +8,9 @@ Pod::Spec.new do |s|
|
||||||
:file => 'License.txt'
|
:file => 'License.txt'
|
||||||
}
|
}
|
||||||
s.author = {'Aryan Ghassemi' => 'https://github.com/aryaxt/iOS-Slide-Menu'}
|
s.author = {'Aryan Ghassemi' => 'https://github.com/aryaxt/iOS-Slide-Menu'}
|
||||||
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.4'}
|
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.6'}
|
||||||
s.platform = :ios, '6.0'
|
s.platform = :ios, '6.0'
|
||||||
s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}', 'SlideMenu/Source/Assets/*.{png}'
|
s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}'
|
||||||
s.resources = ['SlideMenu/Source/Assets/**/*']
|
s.resources = ['SlideMenu/Source/Assets/**/*']
|
||||||
s.framework = 'Foundation', 'UIKit'
|
s.framework = 'Foundation', 'UIKit'
|
||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue