Compare commits

...

19 Commits

Author SHA1 Message Date
Anton d48909d9c4 Remove excess method 2015-10-30 03:45:46 +03:00
Anton 71eb343abe Slide menu open/close animation depends on currently opening part 2015-10-29 23:55:01 +03:00
Anton 95f692c225 Slide menu notifications extends params added 2015-10-23 17:19:45 +03:00
Nikolai Ashanin 42e62a4dbd Update SlideNavigationController.m
remove reverse when menu did end close
2015-10-07 18:30:01 +03:00
Nikolai Ashanin 2ed9400c82 Update SlideNavigationController.m
slide menu open/close different durations
2015-10-07 18:08:40 +03:00
Anton 06deaf308c View controller is opening when menu is starting to close 2015-10-06 14:21:09 +03:00
Anton f3b60362da Add duration on opening and closing animations
Some refactoring
2015-08-28 17:38:25 +03:00
Anton 9550d4719b Slide menu show new controller after menu closing 2015-08-27 17:11:42 +03:00
Anton d088879c28 Remove tap gesture recognizer disabling on viewWllLayoutSubview event 2015-07-30 19:26:21 +03:00
iON1k 5ef5a8d832 Merge pull request #1 from TouchInstinct/feature/swipeMenuBeginEvent
Feature/swipe menu begin event
2015-07-01 16:18:29 +03:00
Павел Круглов 0da57dfd53 Fixed orientation issues. 2015-07-01 15:58:20 +03:00
Павел Круглов 240684c788 Hook point for swipe menu begin. 2015-06-30 18:18:37 +03:00
Павел Круглов c6c729bb52 Merge commit '7fb3ec03e919a6d4a5c622f224c2277ace85c61f' into feature/swipeMenuBeginEvent 2015-06-30 18:10:29 +03:00
Aryan Ghassemi 7fb3ec03e9 Fixed is landscape issues #138 2015-04-22 20:25:52 -07:00
Aryan Ghassemi a9ca4b49b0 Update README.md 2015-04-20 14:48:26 -07:00
Aryan Ghassemi 363306a5c7 Merge pull request #127 from aryaxt/FixInterfaceOrientationWarning
Fixed interfaceOrientation deprecated warning
2015-04-11 10:51:47 -07:00
Aryan Ghassemi 4ce138d4e9 Update pod spec for version 1.4.6 2015-04-11 10:49:22 -07:00
Aryan Ghassemi 43cb763d79 Fixed interfaceOrientation deprecated warning 2015-04-11 10:43:38 -07:00
Aryan Ghassemi 8681050dd0 Update README.md 2015-03-11 21:48:41 -07:00
6 changed files with 118 additions and 96 deletions

View File

@ -525,6 +525,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@ -536,6 +537,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
INFOPLIST_FILE = "SlideMenu/SlideMenu-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};

View File

@ -42,6 +42,11 @@
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) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Revealed %@", menu);

View File

@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.aryaxt.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.aryaxt.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -48,6 +48,8 @@ extern NSString * const SlideNavigationControllerDidOpen;
extern NSString *const SlideNavigationControllerDidClose;
extern NSString *const SlideNavigationControllerDidReveal;
extern NSString *const SlideMenuOpenAfterSwipeKey;
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
@property (nonatomic, assign) BOOL enableSwipeGesture;
@property (nonatomic, assign) BOOL enableShadow;
@ -58,7 +60,8 @@ extern NSString *const SlideNavigationControllerDidReveal;
@property (nonatomic, assign) CGFloat portraitSlideOffset;
@property (nonatomic, assign) CGFloat landscapeSlideOffset;
@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, strong) id <SlideNavigationContorllerAnimator> menuRevealAnimator;
@ -75,4 +78,6 @@ extern NSString *const SlideNavigationControllerDidReveal;
- (void)toggleRightMenu;
- (BOOL)isMenuOpen;
- (void)prepareMenuForReveal:(Menu)menu;
@end

View File

@ -47,8 +47,12 @@ NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerD
NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose";
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
NSString *const SlideMenuOpenAfterSwipeKey = @"SlideMenuOpenAfterSwipeKey";
#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_IMAGE @"menu-button"
#define MENU_SHADOW_RADIUS 10
@ -119,7 +123,8 @@ static SlideNavigationController *singletonInstance;
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.landscapeSlideOffset = 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 rotates we want to make sure that userInteraction is enabled again
[self enableTapGestureToCloseMenu:NO];
//[self enableTapGestureToCloseMenu:NO];
if (self.menuNeedsLayout)
{
@ -151,7 +156,7 @@ static SlideNavigationController *singletonInstance;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") && [self isMenuOpen])
{
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
[self openMenu:menu withDuration:0 andCompletion:nil];
[self openMenu:menu withCompletion:nil];
}
self.menuNeedsLayout = NO;
@ -208,8 +213,7 @@ static SlideNavigationController *singletonInstance;
}
- (void)switchToViewController:(UIViewController *)viewController
withSlideOutAnimation:(BOOL)slideOutAnimation
popType:(PopType)poptype
popType:(PopType)poptype
andCompletion:(void (^)())completion
{
if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
@ -217,95 +221,87 @@ static SlideNavigationController *singletonInstance;
[self closeMenuWithCompletion:completion];
return;
}
void (^switchAndCallCompletion)(BOOL) = ^(BOOL closeMenuBeforeCallingCompletion) {
if (poptype == PopTypeAll) {
[self setViewControllers:@[viewController]];
}
else {
[super popToRootViewControllerAnimated:NO];
[super pushViewController:viewController animated:NO];
}
if (closeMenuBeforeCallingCompletion)
{
[self closeMenuWithCompletion:^{
if (completion)
completion();
}];
}
else
{
if (completion)
completion();
}
};
if ([self isMenuOpen])
{
if (slideOutAnimation)
{
[UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
delay:0
options:self.menuRevealAnimationOption
animations:^{
CGFloat width = self.horizontalSize;
CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
[self moveHorizontallyToLocation:moveLocation];
} completion:^(BOOL finished) {
switchAndCallCompletion(YES);
}];
}
else
{
switchAndCallCompletion(YES);
}
}
else
{
switchAndCallCompletion(NO);
}
void (^switchAndCallCompletion)(BOOL) = ^(BOOL closeMenuBeforeCallingCompletion) {
if (poptype == PopTypeAll) {
[self setViewControllers:@[viewController]];
}
else {
[super popToRootViewControllerAnimated:NO];
[super pushViewController:viewController animated:NO];
}
if (closeMenuBeforeCallingCompletion)
{
[self closeMenuWithCompletion:^{
if (completion)
completion();
}];
}
else
{
if (completion)
completion();
}
};
// if ([self isMenuOpen])
// {
// if (slideOutAnimation)
// {
// [UIView animateWithDuration:(slideOutAnimation) ? self.menuRevealAnimationDuration : 0
// delay:0
// options:self.menuRevealAnimationOption
// animations:^{
// CGFloat width = self.horizontalSize;
// CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
// [self moveHorizontallyToLocation:moveLocation];
// } completion:^(BOOL finished) {
// switchAndCallCompletion(YES);
// }];
// }
// else
// {
// switchAndCallCompletion(YES);
// }
// }
// else
// {
// switchAndCallCompletion(NO);
// }
switchAndCallCompletion([self isMenuOpen]);
}
- (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
withSlideOutAnimation:(BOOL)slideOutAnimation
andCompletion:(void (^)())completion
{
[self switchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeRoot andCompletion:completion];
[self switchToViewController:viewController popType:PopTypeRoot andCompletion:completion];
}
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController
withCompletion:(void (^)())completion
{
[self switchToViewController:viewController withSlideOutAnimation:YES popType:PopTypeRoot andCompletion:completion];
[self switchToViewController:viewController popType:PopTypeRoot andCompletion:completion];
}
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
withSlideOutAnimation:(BOOL)slideOutAnimation
andCompletion:(void (^)())completion
{
[self switchToViewController:viewController withSlideOutAnimation:slideOutAnimation popType:PopTypeAll andCompletion:completion];
[self switchToViewController:viewController popType:PopTypeAll andCompletion:completion];
}
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController
withCompletion:(void (^)())completion
{
[self switchToViewController:viewController withSlideOutAnimation:YES 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];
[self switchToViewController:viewController popType:PopTypeAll andCompletion:completion];
}
- (void)toggleLeftMenu
@ -472,8 +468,23 @@ static SlideNavigationController *singletonInstance;
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 prepareMenuForReveal:menu];
@ -491,12 +502,16 @@ static SlideNavigationController *singletonInstance;
if (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];
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
@ -655,22 +670,17 @@ static SlideNavigationController *singletonInstance;
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu
{
NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
NSDictionary *userInfo = @{ NOTIFICATION_USER_INFO_MENU : menuString };
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo];
[self postNotificationWithName:name forMenu:menu withExtParams:nil];
}
#pragma mark - UINavigationControllerDelegate Methods -
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu withExtParams:(NSDictionary *)extParams
{
if ([self shouldDisplayMenu:MenuLeft forViewController:viewController])
viewController.navigationItem.leftBarButtonItem = [self barButtonItemForMenu:MenuLeft];
if ([self shouldDisplayMenu:MenuRight forViewController:viewController])
viewController.navigationItem.rightBarButtonItem = [self barButtonItemForMenu:MenuRight];
NSMutableDictionary *userInfo = extParams ? [extParams mutableCopy] : [NSMutableDictionary dictionary];
NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
userInfo[NOTIFICATION_USER_INFO_MENU] = menuString;
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:[userInfo copy]];
}
- (CGFloat)slideOffset
@ -733,8 +743,8 @@ static SlideNavigationController *singletonInstance;
else
currentMenu = (translation.x > 0) ? MenuLeft : MenuRight;
if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
return;
// if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
// return;
[self prepareMenuForReveal:currentMenu];
@ -771,11 +781,11 @@ static SlideNavigationController *singletonInstance;
if (currentX > 0)
{
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
{
[self closeMenuWithDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
[self closeMenuWithCompletion:nil];
}
}
// Moving Left
@ -783,12 +793,12 @@ static SlideNavigationController *singletonInstance;
{
if (currentX > 0)
{
[self closeMenuWithDuration:MENU_QUICK_SLIDE_ANIMATION_DURATION andCompletion:nil];
[self closeMenuWithCompletion:nil];
}
else
{
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];
}
}
}
@ -797,7 +807,7 @@ static SlideNavigationController *singletonInstance;
if (currentXOffset < (self.horizontalSize - self.slideOffset)/2)
[self closeMenuWithCompletion:nil];
else
[self openMenu:(currentX > 0) ? MenuLeft : MenuRight withCompletion:nil];
[self openMenu:(currentX > 0) ? MenuLeft : MenuRight afterSwipe:YES withCompletion:nil];
}
}
}

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'iOS-Slide-Menu'
s.version = '1.4.5'
s.version = '1.4.6'
s.summary = 'A Slide Menu for iOS'
s.homepage = 'https://github.com/aryaxt/iOS-Slide-Menu'
s.license = {
@ -8,7 +8,7 @@ Pod::Spec.new do |s|
:file => 'License.txt'
}
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.5'}
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.6'}
s.platform = :ios, '6.0'
s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}'
s.resources = ['SlideMenu/Source/Assets/**/*']