Skip to content

Commit 8137873

Browse files
committed
Merge pull request #73 from aryaxt/Develop
Posting Notifications for menu state open/close/reveal
2 parents da97bae + eca1362 commit 8137873

File tree

8 files changed

+59
-17
lines changed

8 files changed

+59
-17
lines changed

SlideMenu.xcodeproj/project.pbxproj

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
15371EF91728E3B400A508F4 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 15371EF81728E3B400A508F4 /* [email protected] */; };
1919
15371EFC1728E3B400A508F4 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15371EFA1728E3B400A508F4 /* MainStoryboard_iPhone.storyboard */; };
2020
15371EFF1728E3B400A508F4 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 15371EFD1728E3B400A508F4 /* MainStoryboard_iPad.storyboard */; };
21-
15371F0A1728E3B400A508F4 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371F091728E3B400A508F4 /* SenTestingKit.framework */; };
2221
15371F0B1728E3B400A508F4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371EE21728E3B400A508F4 /* UIKit.framework */; };
2322
15371F0C1728E3B400A508F4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15371EE41728E3B400A508F4 /* Foundation.framework */; };
2423
15371F141728E3B400A508F4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15371F121728E3B400A508F4 /* InfoPlist.strings */; };
@@ -70,8 +69,7 @@
7069
15371EF81728E3B400A508F4 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
7170
15371EFB1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
7271
15371EFE1728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
73-
15371F081728E3B400A508F4 /* SlideMenuTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
74-
15371F091728E3B400A508F4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
72+
15371F081728E3B400A508F4 /* SlideMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlideMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7573
15371F111728E3B400A508F4 /* SlideMenuTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SlideMenuTests-Info.plist"; sourceTree = "<group>"; };
7674
15371F131728E3B400A508F4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
7775
15371F151728E3B400A508F4 /* SlideMenuTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlideMenuTests.h; sourceTree = "<group>"; };
@@ -126,7 +124,6 @@
126124
isa = PBXFrameworksBuildPhase;
127125
buildActionMask = 2147483647;
128126
files = (
129-
15371F0A1728E3B400A508F4 /* SenTestingKit.framework in Frameworks */,
130127
15371F0B1728E3B400A508F4 /* UIKit.framework in Frameworks */,
131128
15371F0C1728E3B400A508F4 /* Foundation.framework in Frameworks */,
132129
);
@@ -149,7 +146,7 @@
149146
isa = PBXGroup;
150147
children = (
151148
15371EDE1728E3B400A508F4 /* SlideMenu.app */,
152-
15371F081728E3B400A508F4 /* SlideMenuTests.octest */,
149+
15371F081728E3B400A508F4 /* SlideMenuTests.xctest */,
153150
);
154151
name = Products;
155152
sourceTree = "<group>";
@@ -161,7 +158,6 @@
161158
15371EE21728E3B400A508F4 /* UIKit.framework */,
162159
15371EE41728E3B400A508F4 /* Foundation.framework */,
163160
15371EE61728E3B400A508F4 /* CoreGraphics.framework */,
164-
15371F091728E3B400A508F4 /* SenTestingKit.framework */,
165161
);
166162
name = Frameworks;
167163
sourceTree = "<group>";
@@ -318,15 +314,16 @@
318314
);
319315
name = SlideMenuTests;
320316
productName = SlideMenuTests;
321-
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.octest */;
322-
productType = "com.apple.product-type.bundle";
317+
productReference = 15371F081728E3B400A508F4 /* SlideMenuTests.xctest */;
318+
productType = "com.apple.product-type.bundle.unit-test";
323319
};
324320
/* End PBXNativeTarget section */
325321

326322
/* Begin PBXProject section */
327323
15371ED51728E3B400A508F4 /* Project object */ = {
328324
isa = PBXProject;
329325
attributes = {
326+
LastTestingUpgradeCheck = 0600;
330327
LastUpgradeCheck = 0500;
331328
ORGANIZATIONNAME = "Aryan Ghassemi";
332329
};
@@ -551,13 +548,13 @@
551548
FRAMEWORK_SEARCH_PATHS = (
552549
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
553550
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
551+
"$(inherited)",
554552
);
555553
GCC_PRECOMPILE_PREFIX_HEADER = YES;
556554
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
557555
INFOPLIST_FILE = "SlideMenuTests/SlideMenuTests-Info.plist";
558556
PRODUCT_NAME = "$(TARGET_NAME)";
559557
TEST_HOST = "$(BUNDLE_LOADER)";
560-
WRAPPER_EXTENSION = octest;
561558
};
562559
name = Debug;
563560
};
@@ -568,13 +565,13 @@
568565
FRAMEWORK_SEARCH_PATHS = (
569566
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
570567
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
568+
"$(inherited)",
571569
);
572570
GCC_PRECOMPILE_PREFIX_HEADER = YES;
573571
GCC_PREFIX_HEADER = "SlideMenu/SlideMenu-Prefix.pch";
574572
INFOPLIST_FILE = "SlideMenuTests/SlideMenuTests-Info.plist";
575573
PRODUCT_NAME = "$(TARGET_NAME)";
576574
TEST_HOST = "$(BUNDLE_LOADER)";
577-
WRAPPER_EXTENSION = octest;
578575
};
579576
name = Release;
580577
};

SlideMenu/AppDelegate.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3030
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
3131
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
3232
[SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem;
33+
34+
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
35+
NSString *menu = note.userInfo[@"menu"];
36+
NSLog(@"Closed %@", menu);
37+
}];
38+
39+
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
40+
NSString *menu = note.userInfo[@"menu"];
41+
NSLog(@"Opened %@", menu);
42+
}];
43+
44+
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
45+
NSString *menu = note.userInfo[@"menu"];
46+
NSLog(@"Revealed %@", menu);
47+
}];
3348

3449

3550
// Override point for customization after application launch.

SlideMenu/Helper Classes/FriendsViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
3333
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
3434
{
3535
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"friendCell"];
36-
cell.textLabel.text = [NSString stringWithFormat:@"Friend %d", indexPath.row];
36+
cell.textLabel.text = [NSString stringWithFormat:@"Friend %ld", (long)indexPath.row];
3737
return cell;
3838
}
3939

SlideMenu/Source/SlideNavigationController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ typedef enum{
4242
@protocol SlideNavigationContorllerAnimator;
4343
@interface SlideNavigationController : UINavigationController <UINavigationControllerDelegate>
4444

45+
extern NSString * const SlideNavigationControllerDidOpen;
46+
extern NSString *const SlideNavigationControllerDidClose;
47+
extern NSString *const SlideNavigationControllerDidReveal;
48+
4549
@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController;
4650
@property (nonatomic, assign) BOOL enableSwipeGesture;
4751
@property (nonatomic, assign) BOOL enableShadow;

SlideMenu/Source/SlideNavigationController.m

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ @interface SlideNavigationController() <UIGestureRecognizerDelegate>
4242

4343
@implementation SlideNavigationController
4444

45+
NSString * const SlideNavigationControllerDidOpen = @"SlideNavigationControllerDidOpen";
46+
NSString * const SlideNavigationControllerDidClose = @"SlideNavigationControllerDidClose";
47+
NSString *const SlideNavigationControllerDidReveal = @"SlideNavigationControllerDidReveal";
48+
4549
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
4650
#define MENU_SLIDE_ANIMATION_DURATION .3
4751
#define MENU_QUICK_SLIDE_ANIMATION_DURATION .18
@@ -51,6 +55,9 @@ @implementation SlideNavigationController
5155
#define MENU_DEFAULT_SLIDE_OFFSET 60
5256
#define MENU_FAST_VELOCITY_FOR_SWIPE_FOLLOW_DIRECTION 1200
5357
#define STATUS_BAR_HEIGHT 20
58+
#define NOTIFICATION_USER_INFO_MENU_LEFT @"left"
59+
#define NOTIFICATION_USER_INFO_MENU_RIGHT @"right"
60+
#define NOTIFICATION_USER_INFO_MENU @"menu"
5461

5562
static SlideNavigationController *singletonInstance;
5663

@@ -462,12 +469,16 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^)
462469
completion:^(BOOL finished) {
463470
if (completion)
464471
completion();
472+
473+
[self postNotificationWithName:SlideNavigationControllerDidOpen forMenu:menu];
465474
}];
466475
}
467476

468477
- (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completion
469478
{
470479
[self enableTapGestureToCloseMenu:NO];
480+
481+
Menu menu = (self.horizontalLocation > 0) ? MenuLeft : MenuRight;
471482

472483
[UIView animateWithDuration:duration
473484
delay:0
@@ -480,6 +491,8 @@ - (void)closeMenuWithDuration:(float)duration andCompletion:(void (^)())completi
480491
completion:^(BOOL finished) {
481492
if (completion)
482493
completion();
494+
495+
[self postNotificationWithName:SlideNavigationControllerDidClose forMenu:menu];
483496
}];
484497
}
485498

@@ -488,6 +501,10 @@ - (void)moveHorizontallyToLocation:(CGFloat)location
488501
CGRect rect = self.view.frame;
489502
UIInterfaceOrientation orientation = self.interfaceOrientation;
490503
Menu menu = (self.horizontalLocation >= 0 && location >= 0) ? MenuLeft : MenuRight;
504+
505+
if ((location > 0 && self.horizontalLocation <= 0) || (location < 0 && self.horizontalLocation >= 0)) {
506+
[self postNotificationWithName:SlideNavigationControllerDidReveal forMenu:(location > 0) ? MenuLeft : MenuRight];
507+
}
491508

492509
if (UIInterfaceOrientationIsLandscape(orientation))
493510
{
@@ -596,6 +613,13 @@ - (CGFloat)horizontalSize
596613
}
597614
}
598615

616+
- (void)postNotificationWithName:(NSString *)name forMenu:(Menu)menu
617+
{
618+
NSString *menuString = (menu == MenuLeft) ? NOTIFICATION_USER_INFO_MENU_LEFT : NOTIFICATION_USER_INFO_MENU_RIGHT;
619+
NSDictionary *userInfo = @{ NOTIFICATION_USER_INFO_MENU : menuString };
620+
[[NSNotificationCenter defaultCenter] postNotificationName:name object:nil userInfo:userInfo];
621+
}
622+
599623
#pragma mark - UINavigationControllerDelegate Methods -
600624

601625
- (void)navigationController:(UINavigationController *)navigationController
@@ -624,7 +648,6 @@ - (void)leftMenuSelected:(id)sender
624648
[self closeMenuWithCompletion:nil];
625649
else
626650
[self openMenu:MenuLeft withCompletion:nil];
627-
628651
}
629652

630653
- (void)righttMenuSelected:(id)sender
@@ -670,6 +693,9 @@ - (void)panDetected:(UIPanGestureRecognizer *)aPanRecognizer
670693
else
671694
currentMenu = (translation.x > 0) ? MenuLeft : MenuRight;
672695

696+
if (![self shouldDisplayMenu:currentMenu forViewController:self.topViewController])
697+
return;
698+
673699
[self prepareMenuForReveal:currentMenu];
674700

675701
if (aPanRecognizer.state == UIGestureRecognizerStateBegan)

SlideMenuTests/SlideMenuTests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright (c) 2013 Aryan Ghassemi. All rights reserved.
77
//
88

9-
#import <SenTestingKit/SenTestingKit.h>
9+
#import <XCTest/XCTest.h>
1010

11-
@interface SlideMenuTests : SenTestCase
11+
@interface SlideMenuTests : XCTestCase
1212

1313
@end

SlideMenuTests/SlideMenuTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ - (void)tearDown
2626

2727
- (void)testExample
2828
{
29-
STFail(@"Unit tests are not implemented yet in SlideMenuTests");
29+
XCTFail(@"Unit tests are not implemented yet in SlideMenuTests");
3030
}
3131

3232
@end

iOS-Slide-Menu.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Pod::Spec.new do |s|
22
s.name = 'iOS-Slide-Menu'
3-
s.version = '1.4.1'
3+
s.version = '1.4.2'
44
s.summary = 'A Slide Menu for iOS'
55
s.homepage = 'https://github.com/aryaxt/iOS-Slide-Menu'
66
s.license = {
77
:type => 'MIT',
88
:file => 'License.txt'
99
}
1010
s.author = {'Aryan Gh' => 'https://github.com/aryaxt/iOS-Slide-Menu'}
11-
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.1'}
11+
s.source = {:git => 'https://github.com/aryaxt/iOS-Slide-Menu.git', :tag => '1.4.2'}
1212
s.platform = :ios, '6.0'
1313
s.source_files = 'SlideMenu/Source/*.{h,m}', 'SlideMenu/Source/Animations/*.{h,m}', 'SlideMenu/Source/Assets/*.{png}'
1414
s.resources = ['SlideMenu/Source/Assets/**/*']

0 commit comments

Comments
 (0)