Skip to content

Commit 8d331af

Browse files
committed
Merge remote-tracking branch 'origin/custom_animation'
* origin/custom_animation: - Cleanup - Fixed typo in property name renamed “leftbarButtonItem” to “leftBarButtonItem” - Fixed a bug where menu animation does not get completed when switching to another view controller because that viewController is not presenting the menu (delegate return NO or not implemented) - Some cleanup - Structured menu for a better presentation of slide menu features - Implemented clear for slide animation - Fixed an issue with scale animation - Separated all reveal animations from SlideNavigationController - Allowing a custom animation to be passed to slide menu and used for menu reveal animation - Added scale animation
2 parents 8979fde + 2b3be43 commit 8d331af

17 files changed

+715
-180
lines changed

SlideMenu.xcodeproj/project.pbxproj

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
15371F141728E3B400A508F4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15371F121728E3B400A508F4 /* InfoPlist.strings */; };
2525
15371F171728E3B400A508F4 /* SlideMenuTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 15371F161728E3B400A508F4 /* SlideMenuTests.m */; };
2626
15371F281728E44E00A508F4 /* SlideNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15371F271728E44E00A508F4 /* SlideNavigationController.m */; };
27+
15C9AC111895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */; };
28+
15C9AC141895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */; };
29+
15C9AC171895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */; };
30+
15C9AC1A1895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */; };
31+
15C9AC1D1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m in Sources */ = {isa = PBXBuildFile; fileRef = 15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */; };
2732
15CBD67C172A15F900F0C53E /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD677172A15F900F0C53E /* HomeViewController.m */; };
2833
15CBD67D172A15F900F0C53E /* MenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD679172A15F900F0C53E /* MenuViewController.m */; };
2934
15CBD67E172A15F900F0C53E /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 15CBD67B172A15F900F0C53E /* ProfileViewController.m */; };
@@ -68,6 +73,17 @@
6873
15371F161728E3B400A508F4 /* SlideMenuTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SlideMenuTests.m; sourceTree = "<group>"; };
6974
15371F261728E44E00A508F4 /* SlideNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationController.h; sourceTree = "<group>"; };
7075
15371F271728E44E00A508F4 /* SlideNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationController.m; sourceTree = "<group>"; };
76+
15C9AC0F1895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorSlide.h; sourceTree = "<group>"; };
77+
15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorSlide.m; sourceTree = "<group>"; };
78+
15C9AC121895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorFade.h; sourceTree = "<group>"; };
79+
15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorFade.m; sourceTree = "<group>"; };
80+
15C9AC151895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorSlideAndFade.h; sourceTree = "<group>"; };
81+
15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorSlideAndFade.m; sourceTree = "<group>"; };
82+
15C9AC181895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorScale.h; sourceTree = "<group>"; };
83+
15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorScale.m; sourceTree = "<group>"; };
84+
15C9AC1B1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimatorScaleAndFade.h; sourceTree = "<group>"; };
85+
15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SlideNavigationContorllerAnimatorScaleAndFade.m; sourceTree = "<group>"; };
86+
15C9AC1E1895A832006E6F27 /* SlideNavigationContorllerAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlideNavigationContorllerAnimator.h; sourceTree = "<group>"; };
7187
15CBD676172A15F900F0C53E /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; };
7288
15CBD677172A15F900F0C53E /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
7389
15CBD678172A15F900F0C53E /* MenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuViewController.h; sourceTree = "<group>"; };
@@ -189,13 +205,32 @@
189205
15371F241728E43600A508F4 /* Source */ = {
190206
isa = PBXGroup;
191207
children = (
208+
15C9AC0E1895A79A006E6F27 /* Animations */,
192209
15CBD681172A209500F0C53E /* Assets */,
193210
15371F261728E44E00A508F4 /* SlideNavigationController.h */,
194211
15371F271728E44E00A508F4 /* SlideNavigationController.m */,
195212
);
196213
path = Source;
197214
sourceTree = "<group>";
198215
};
216+
15C9AC0E1895A79A006E6F27 /* Animations */ = {
217+
isa = PBXGroup;
218+
children = (
219+
15C9AC0F1895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.h */,
220+
15C9AC101895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m */,
221+
15C9AC121895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.h */,
222+
15C9AC131895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m */,
223+
15C9AC151895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.h */,
224+
15C9AC161895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m */,
225+
15C9AC181895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.h */,
226+
15C9AC191895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m */,
227+
15C9AC1B1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.h */,
228+
15C9AC1C1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m */,
229+
15C9AC1E1895A832006E6F27 /* SlideNavigationContorllerAnimator.h */,
230+
);
231+
path = Animations;
232+
sourceTree = "<group>";
233+
};
199234
15CBD675172A15F900F0C53E /* Helper Classes */ = {
200235
isa = PBXGroup;
201236
children = (
@@ -335,12 +370,17 @@
335370
isa = PBXSourcesBuildPhase;
336371
buildActionMask = 2147483647;
337372
files = (
373+
15C9AC1D1895A81D006E6F27 /* SlideNavigationContorllerAnimatorScaleAndFade.m in Sources */,
374+
15C9AC171895A7E7006E6F27 /* SlideNavigationContorllerAnimatorSlideAndFade.m in Sources */,
338375
15371EEF1728E3B400A508F4 /* main.m in Sources */,
339376
15371EF31728E3B400A508F4 /* AppDelegate.m in Sources */,
377+
15C9AC141895A7D7006E6F27 /* SlideNavigationContorllerAnimatorFade.m in Sources */,
340378
15371F281728E44E00A508F4 /* SlideNavigationController.m in Sources */,
379+
15C9AC111895A7BF006E6F27 /* SlideNavigationContorllerAnimatorSlide.m in Sources */,
341380
15CBD67C172A15F900F0C53E /* HomeViewController.m in Sources */,
342381
997929E2187336AA00716C77 /* FriendsViewController.m in Sources */,
343382
15CBD67D172A15F900F0C53E /* MenuViewController.m in Sources */,
383+
15C9AC1A1895A80E006E6F27 /* SlideNavigationContorllerAnimatorScale.m in Sources */,
344384
15CBD67E172A15F900F0C53E /* ProfileViewController.m in Sources */,
345385
15CBD689172A22B700F0C53E /* ProfileDetailViewController.m in Sources */,
346386
);

SlideMenu/Helper Classes/MenuViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <UIKit/UIKit.h>
1010
#import "SlideNavigationController.h"
1111

12-
@interface MenuViewController : UIViewController <UITableViewDelegate>
12+
@interface MenuViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
1313

1414
@property (nonatomic, strong) NSString *cellIdentifier;
1515

SlideMenu/Helper Classes/MenuViewController.m

Lines changed: 126 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,85 @@
77
//
88

99
#import "MenuViewController.h"
10+
#import "SlideNavigationContorllerAnimatorFade.h"
11+
#import "SlideNavigationContorllerAnimatorSlide.h"
12+
#import "SlideNavigationContorllerAnimatorScale.h"
13+
#import "SlideNavigationContorllerAnimatorScaleAndFade.h"
14+
#import "SlideNavigationContorllerAnimatorSlideAndFade.h"
1015

1116
@implementation MenuViewController
1217
@synthesize cellIdentifier;
1318

1419
#pragma mark - UITableView Delegate & Datasrouce -
1520

21+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
22+
{
23+
return 2;
24+
}
25+
1626
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
1727
{
18-
return 15;
28+
return (section == 0) ? 4 : 6;
29+
}
30+
31+
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
32+
{
33+
return (section == 0) ? @"Navigation" : @"Menu Animation";
1934
}
2035

2136
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
2237
{
2338
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier];
2439

25-
switch (indexPath.row)
40+
if (indexPath.section == 0)
2641
{
27-
case 0:
28-
cell.textLabel.text = @"Home";
29-
break;
30-
31-
case 1:
32-
cell.textLabel.text = @"Profile";
33-
break;
34-
35-
case 2:
36-
cell.textLabel.text = @"Friends";
37-
break;
38-
39-
case 3:
40-
cell.textLabel.text = @"Sign Out";
41-
break;
42-
43-
default:
44-
cell.textLabel.text = @"Random Cell";
45-
break;
42+
switch (indexPath.row)
43+
{
44+
case 0:
45+
cell.textLabel.text = @"Home";
46+
break;
47+
48+
case 1:
49+
cell.textLabel.text = @"Profile";
50+
break;
51+
52+
case 2:
53+
cell.textLabel.text = @"Friends";
54+
break;
55+
56+
case 3:
57+
cell.textLabel.text = @"Sign Out";
58+
break;
59+
}
60+
}
61+
else
62+
{
63+
switch (indexPath.row)
64+
{
65+
case 0:
66+
cell.textLabel.text = @"No Animation";
67+
break;
68+
69+
case 1:
70+
cell.textLabel.text = @"Slide Animation";
71+
break;
72+
73+
case 2:
74+
cell.textLabel.text = @"Fade Animation";
75+
break;
76+
77+
case 3:
78+
cell.textLabel.text = @"Slide And Fade Animation";
79+
break;
80+
81+
case 4:
82+
cell.textLabel.text = @"Scale Animation";
83+
break;
84+
85+
case 5:
86+
cell.textLabel.text = @"Scale And Fade Animation";
87+
break;
88+
}
4689
}
4790

4891
return cell;
@@ -53,32 +96,70 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
5396
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
5497
bundle: nil];
5598

56-
UIViewController *vc ;
57-
58-
switch (indexPath.row)
99+
if (indexPath.section == 0)
59100
{
60-
case 0:
61-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
62-
break;
63-
64-
case 1:
65-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"];
66-
break;
67-
68-
case 2:
69-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"];
70-
break;
71-
72-
case 3:
73-
[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];
74-
return;
75-
break;
76-
77-
default:
78-
return;
101+
UIViewController *vc ;
102+
103+
switch (indexPath.row)
104+
{
105+
case 0:
106+
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
107+
break;
108+
109+
case 1:
110+
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"];
111+
break;
112+
113+
case 2:
114+
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"];
115+
break;
116+
117+
case 3:
118+
[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];
119+
return;
120+
break;
121+
}
122+
123+
[[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil];
124+
}
125+
else
126+
{
127+
id <SlideNavigationContorllerAnimator> revealAnimator;
128+
129+
switch (indexPath.row)
130+
{
131+
case 0:
132+
revealAnimator = nil;
133+
break;
134+
135+
case 1:
136+
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
137+
break;
138+
139+
case 2:
140+
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
141+
break;
142+
143+
case 3:
144+
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] initWithMaximumFadeAlpha:.7 fadeColor:[UIColor purpleColor] andSlideMovement:100];
145+
break;
146+
147+
case 4:
148+
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
149+
break;
150+
151+
case 5:
152+
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] initWithMaximumFadeAlpha:.6 fadeColor:[UIColor blueColor] andMinimumScale:.7];
153+
break;
154+
155+
default:
156+
return;
157+
}
158+
159+
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
160+
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
161+
}];
79162
}
80-
81-
[[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil];
82163
}
83164

84165
@end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// SlideNavigationContorllerAnimation.h
3+
// SlideMenu
4+
//
5+
// Created by Aryan Gh on 1/26/14.
6+
// Copyright (c) 2014 Aryan Ghassemi. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "SlideNavigationController.h"
11+
12+
@protocol SlideNavigationContorllerAnimator <NSObject>
13+
14+
// Initial state of the view before animation starts
15+
// This gets called right before the menu is about to reveal
16+
- (void)prepareMenuForAnimation:(Menu)menu;
17+
18+
// Animate the view based on the progress (progress is between 0 and 1)
19+
- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress;
20+
21+
// Gets called ff for any the instance of animator is being change
22+
// You should make any cleanup that is needed
23+
- (void)clear;
24+
25+
@end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// SlideNavigationContorllerAnimationFade.h
3+
// SlideMenu
4+
//
5+
// Created by Aryan Gh on 1/26/14.
6+
// Copyright (c) 2014 Aryan Ghassemi. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "SlideNavigationContorllerAnimator.h"
11+
12+
@interface SlideNavigationContorllerAnimatorFade : NSObject <SlideNavigationContorllerAnimator>
13+
14+
@property (nonatomic, assign) CGFloat maximumFadeAlpha;
15+
@property (nonatomic, strong) UIColor *fadeColor;
16+
17+
- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha andFadeColor:(UIColor *)fadeColor;
18+
19+
@end

0 commit comments

Comments
 (0)