Merge pull request #73 from aryaxt/Develop

Posting Notifications for menu state open/close/reveal
This commit is contained in:
Aryan Ghassemi 2014-09-06 13:46:34 -07:00
commit 81378731d9
8 changed files with 59 additions and 17 deletions

View File

@ -18,7 +18,6 @@
15371EF91728E3B400A508F4 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 15371EF81728E3B400A508F4 /* Default-568h@2x.png */; };
15371EFC1728E3B400A508F4 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15371EFA1728E3B400A508F4 /* MainStoryboard_iPhone.storyboard */; };
15371EFF1728E3B400A508F4 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15371EFD1728E3B400A508F4 /* MainStoryboard_iPad.storyboard */; };
15371F0A1728E3B400A508F4 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371F091728E3B400A508F4 /* SenTestingKit.framework */; };
15371F0B1728E3B400A508F4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371EE21728E3B400A508F4 /* UIKit.framework */; };
15371F0C1728E3B400A508F4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371EE41728E3B400A508F4 /* Foundation.framework */; };
15371F141728E3B400A508F4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15371F121728E3B400A508F4 /* InfoPlist.strings */; };
@ -70,8 +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; };
15371F091728E3B400A508F4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_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>"; };
@ -126,7 +124,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
15371F0A1728E3B400A508F4 /* SenTestingKit.framework in Frameworks */,
15371F0B1728E3B400A508F4 /* UIKit.framework in Frameworks */,
15371F0C1728E3B400A508F4 /* Foundation.framework in Frameworks */,
);
@ -149,7 +146,7 @@
isa = PBXGroup;
children = (
15371EDE1728E3B400A508F4 /* SlideMenu.app */,
15371F081728E3B400A508F4 /* SlideMenuTests.octest */,
15371F081728E3B400A508F4 /* SlideMenuTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@ -161,7 +158,6 @@
15371EE21728E3B400A508F4 /* UIKit.framework */,
15371EE41728E3B400A508F4 /* Foundation.framework */,
15371EE61728E3B400A508F4 /* CoreGraphics.framework */,
15371F091728E3B400A508F4 /* SenTestingKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@ -318,8 +314,8 @@
);
name = SlideMenuTests;
productName = SlideMenuTests;
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.octest */;
productType = "com.apple.product-type.bundle";
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
@ -327,6 +323,7 @@
15371ED51728E3B400A508F4 /* Project object */ = {
isa = PBXProject;
attributes = {
LastTestingUpgradeCheck = 0600;
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = "Aryan Ghassemi";
};
@ -551,13 +548,13 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
INFOPLIST_FILE = "SlideMenuTests/SlideMenuTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = Debug;
};
@ -568,13 +565,13 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
INFOPLIST_FILE = "SlideMenuTests/SlideMenuTests-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
WRAPPER_EXTENSION = octest;
};
name = Release;
};

View File

@ -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.

View File

@ -33,7 +33,7 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"friendCell"];
cell.textLabel.text = [NSString stringWithFormat:@"Friend %d", indexPath.row];
cell.textLabel.text = [NSString stringWithFormat:@"Friend %ld", (long)indexPath.row];
return cell;
}

View File

@ -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;

View File

@ -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)

View File

@ -6,8 +6,8 @@
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
#import <XCTest/XCTest.h>
@interface SlideMenuTests : SenTestCase
@interface SlideMenuTests : XCTestCase
@end

View File

@ -26,7 +26,7 @@
- (void)testExample
{
STFail(@"Unit tests are not implemented yet in SlideMenuTests");
XCTFail(@"Unit tests are not implemented yet in SlideMenuTests");
}
@end

View File

@ -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/**/*']