diff --git a/SlideMenu.xcodeproj/project.pbxproj b/SlideMenu.xcodeproj/project.pbxproj index 5b91972..5006a3d 100755 --- a/SlideMenu.xcodeproj/project.pbxproj +++ b/SlideMenu.xcodeproj/project.pbxproj @@ -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 = ""; }; 15371EFB1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = ""; }; 15371EFE1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = ""; }; - 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 = ""; }; 15371F131728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 15371F151728E3B400A508F4 /* SlideMenuTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlideMenuTests.h; sourceTree = ""; }; @@ -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 = ""; @@ -161,7 +158,6 @@ 15371EE21728E3B400A508F4 /* UIKit.framework */, 15371EE41728E3B400A508F4 /* Foundation.framework */, 15371EE61728E3B400A508F4 /* CoreGraphics.framework */, - 15371F091728E3B400A508F4 /* SenTestingKit.framework */, ); name = Frameworks; sourceTree = ""; @@ -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; }; diff --git a/SlideMenu/AppDelegate.m b/SlideMenu/AppDelegate.m index c49d7b0..e48a2ea 100644 --- a/SlideMenu/AppDelegate.m +++ b/SlideMenu/AppDelegate.m @@ -30,6 +30,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [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. diff --git a/SlideMenu/Helper Classes/FriendsViewController.m b/SlideMenu/Helper Classes/FriendsViewController.m index 38bc9a6..ac1b1d7 100644 --- a/SlideMenu/Helper Classes/FriendsViewController.m +++ b/SlideMenu/Helper Classes/FriendsViewController.m @@ -33,7 +33,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (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; } diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index f7bc2ac..2a44a54 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -42,6 +42,10 @@ typedef enum{ @protocol SlideNavigationContorllerAnimator; @interface SlideNavigationController : UINavigationController +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; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index 0c23e66..280160d 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -42,6 +42,10 @@ @interface SlideNavigationController() @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 @@ @implementation SlideNavigationController #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 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^) 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 @@ - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completi completion:^(BOOL finished) { if (completion) completion(); + + [self postNotificationWithName:SlideNavigationControllerDidClose forMenu:menu]; }]; } @@ -488,6 +501,10 @@ - (void)moveHorizontallyToLocation:(CGFloat)location 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 @@ - (CGFloat)horizontalSize } } +- (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 @@ - (void)leftMenuSelected:(id)sender [self closeMenuWithCompletion:nil]; else [self openMenu:MenuLeft withCompletion:nil]; - } - (void)righttMenuSelected:(id)sender @@ -670,6 +693,9 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer else currentMenu = (translation.x > 0) ? MenuLeft : MenuRight; + if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController]) + return; + [self prepareMenuForReveal:currentMenu]; if (aPanRecognizer.state == UIGestureRecognizerStateBegan) diff --git a/SlideMenuTests/SlideMenuTests.h b/SlideMenuTests/SlideMenuTests.h index 57c6595..f1f0ec8 100644 --- a/SlideMenuTests/SlideMenuTests.h +++ b/SlideMenuTests/SlideMenuTests.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 Aryan Ghassemi. All rights reserved. // -#import +#import -@interface SlideMenuTests : SenTestCase +@interface SlideMenuTests : XCTestCase @end diff --git a/SlideMenuTests/SlideMenuTests.m b/SlideMenuTests/SlideMenuTests.m index 4b01af2..096549d 100644 --- a/SlideMenuTests/SlideMenuTests.m +++ b/SlideMenuTests/SlideMenuTests.m @@ -26,7 +26,7 @@ - (void)tearDown - (void)testExample { - STFail(@"Unit tests are not implemented yet in SlideMenuTests"); + XCTFail(@"Unit tests are not implemented yet in SlideMenuTests"); } @end diff --git a/iOS-Slide-Menu.podspec b/iOS-Slide-Menu.podspec index ab82d90..be18826 100644 --- a/iOS-Slide-Menu.podspec +++ b/iOS-Slide-Menu.podspec @@ -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/**/*']