Added Notifications for closing/opening/revealing menu #32
This commit is contained in:
parent
3513ce023a
commit
eca136202c
|
|
@ -69,7 +69,7 @@
|
|||
15371EF81728E3B400A508F4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||
15371EFB1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
|
||||
15371EFE1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
|
||||
15371F081728E3B400A508F4 /* SlideMenuTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
15371F081728E3B400A508F4 /* SlideMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
15371F111728E3B400A508F4 /* SlideMenuTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SlideMenuTests-Info.plist"; sourceTree = "<group>"; };
|
||||
15371F131728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
15371F151728E3B400A508F4 /* SlideMenuTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlideMenuTests.h; sourceTree = "<group>"; };
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
15371EDE1728E3B400A508F4 /* SlideMenu.app */,
|
||||
15371F081728E3B400A508F4 /* SlideMenuTests.octest */,
|
||||
15371F081728E3B400A508F4 /* SlideMenuTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -314,7 +314,7 @@
|
|||
);
|
||||
name = SlideMenuTests;
|
||||
productName = SlideMenuTests;
|
||||
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.octest */;
|
||||
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
|
|
|||
|
|
@ -30,6 +30,21 @@
|
|||
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
|
||||
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
|
||||
[SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||
NSString *menu = note.userInfo[@"menu"];
|
||||
NSLog(@"Closed %@", menu);
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||
NSString *menu = note.userInfo[@"menu"];
|
||||
NSLog(@"Opened %@", menu);
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
|
||||
NSString *menu = note.userInfo[@"menu"];
|
||||
NSLog(@"Revealed %@", menu);
|
||||
}];
|
||||
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ typedef enum{
|
|||
@protocol SlideNavigationContorllerAnimator;
|
||||
@interface SlideNavigationController : UINavigationController <UINavigationControllerDelegate>
|
||||
|
||||
extern NSString * const SlideNavigationControllerDidOpen;
|
||||
extern NSString *const SlideNavigationControllerDidClose;
|
||||
extern NSString *const SlideNavigationControllerDidReveal;
|
||||
|
||||
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
|
||||
@property (nonatomic, assign) BOOL enableSwipeGesture;
|
||||
@property (nonatomic, assign) BOOL enableShadow;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ typedef enum {
|
|||
|
||||
@implementation SlideNavigationController
|
||||
|
||||
NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerDidOpen";
|
||||
NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose";
|
||||
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
|
||||
|
||||
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
||||
#define MENU_SLIDE_ANIMATION_DURATION .3
|
||||
#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
|
||||
|
|
@ -51,6 +55,9 @@ typedef enum {
|
|||
#define MENU_DEFAULT_SLIDE_OFFSET 60
|
||||
#define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200
|
||||
#define STATUS_BAR_HEIGHT 20
|
||||
#define NOTIFICATION_USER_INFO_MENU_LEFT @"left"
|
||||
#define NOTIFICATION_USER_INFO_MENU_RIGHT @"right"
|
||||
#define NOTIFICATION_USER_INFO_MENU @"menu"
|
||||
|
||||
static SlideNavigationController *singletonInstance;
|
||||
|
||||
|
|
@ -462,12 +469,16 @@ static SlideNavigationController *singletonInstance;
|
|||
completion:^(BOOL finished) {
|
||||
if (completion)
|
||||
completion();
|
||||
|
||||
[self postNotificationWithName:SlideNavigationControllerDidOpen forMenu:menu];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completion
|
||||
{
|
||||
[self enableTapGestureToCloseMenu:NO];
|
||||
|
||||
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
|
||||
|
||||
[UIView animateWithDuration:duration
|
||||
delay:0
|
||||
|
|
@ -480,6 +491,8 @@ static SlideNavigationController *singletonInstance;
|
|||
completion:^(BOOL finished) {
|
||||
if (completion)
|
||||
completion();
|
||||
|
||||
[self postNotificationWithName:SlideNavigationControllerDidClose forMenu:menu];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
@ -488,6 +501,10 @@ static SlideNavigationController *singletonInstance;
|
|||
CGRect rect = self.view.frame;
|
||||
UIInterfaceOrientation orientation = self.interfaceOrientation;
|
||||
Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight;
|
||||
|
||||
if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) {
|
||||
[self postNotificationWithName:SlideNavigationControllerDidReveal forMenu:(location > 0) ? MenuLeft : MenuRight];
|
||||
}
|
||||
|
||||
if (UIInterfaceOrientationIsLandscape(orientation))
|
||||
{
|
||||
|
|
@ -596,6 +613,13 @@ 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];
|
||||
}
|
||||
|
||||
#pragma mark - UINavigationControllerDelegate Methods -
|
||||
|
||||
- (void)navigationController:(UINavigationController *)navigationController
|
||||
|
|
@ -624,7 +648,6 @@ static SlideNavigationController *singletonInstance;
|
|||
[self closeMenuWithCompletion:nil];
|
||||
else
|
||||
[self openMenu:MenuLeft withCompletion:nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)righttMenuSelected:(id)sender
|
||||
|
|
@ -670,6 +693,9 @@ static SlideNavigationController *singletonInstance;
|
|||
else
|
||||
currentMenu = (translation.x > 0) ? MenuLeft : MenuRight;
|
||||
|
||||
if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
|
||||
return;
|
||||
|
||||
[self prepareMenuForReveal:currentMenu];
|
||||
|
||||
if (aPanRecognizer.state == UIGestureRecognizerStateBegan)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'iOS-Slide-Menu'
|
||||
s.version = '1.4.1'
|
||||
s.version = '1.4.2'
|
||||
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 Gh' => 'https://github.com/aryaxt/iOS-Slide-Menu'}
|
||||
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.1'}
|
||||
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.2'}
|
||||
s.platform = :ios, '6.0'
|
||||
s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}', 'SlideMenu/Source/Assets/*.{png}'
|
||||
s.resources = ['SlideMenu/Source/Assets/**/*']
|
||||
|
|
|
|||
Loading…
Reference in New Issue