Skip to content

Commit f1025d7

Browse files
committed
- Some cleanup
- Structured menu for a better presentation of slide menu features
1 parent 93b7afc commit f1025d7

File tree

4 files changed

+122
-94
lines changed

4 files changed

+122
-94
lines changed

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: 117 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,74 @@ @implementation MenuViewController
1818

1919
#pragma mark - UITableView Delegate & Datasrouce -
2020

21+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
22+
{
23+
return 2;
24+
}
25+
2126
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
2227
{
23-
return 10;
28+
return (section == 0) ? 4 : 6;
29+
}
30+
31+
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
32+
{
33+
return (section == 0) ? @"Navigation" : @"Menu Animation";
2434
}
2535

2636
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
2737
{
2838
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellIdentifier];
2939

30-
switch (indexPath.row)
40+
if (indexPath.section == 0)
3141
{
32-
case 0:
33-
cell.textLabel.text = @"Home";
34-
break;
35-
36-
case 1:
37-
cell.textLabel.text = @"Profile";
38-
break;
39-
40-
case 2:
41-
cell.textLabel.text = @"Friends";
42-
break;
43-
44-
case 3:
45-
cell.textLabel.text = @"Sign Out";
46-
break;
47-
48-
case 4:
49-
cell.textLabel.text = @"No Animation";
50-
break;
51-
52-
case 5:
53-
cell.textLabel.text = @"Slide Animation";
54-
break;
55-
56-
case 6:
57-
cell.textLabel.text = @"Fade Animation";
58-
break;
59-
60-
case 7:
61-
cell.textLabel.text = @"Slide And Fade Animation";
62-
break;
63-
64-
case 8:
65-
cell.textLabel.text = @"Scale Animation";
66-
break;
67-
68-
case 9:
69-
cell.textLabel.text = @"Scale And Fade Animation";
70-
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+
}
7189
}
7290

7391
return cell;
@@ -78,62 +96,70 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
7896
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
7997
bundle: nil];
8098

81-
UIViewController *vc ;
82-
id <SlideNavigationContorllerAnimator> revealAnimator;
83-
84-
switch (indexPath.row)
99+
if (indexPath.section == 0)
85100
{
86-
case 0:
87-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
88-
break;
89-
90-
case 1:
91-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"ProfileViewController"];
92-
break;
93-
94-
case 2:
95-
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"FriendsViewController"];
96-
break;
97-
98-
case 3:
99-
[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];
100-
return;
101-
break;
102-
103-
case 4:
104-
revealAnimator = nil;
105-
break;
106-
107-
case 5:
108-
revealAnimator = [[SlideNavigationContorllerAnimatorSlide alloc] init];
109-
break;
110-
111-
case 6:
112-
revealAnimator = [[SlideNavigationContorllerAnimatorFade alloc] init];
113-
break;
114-
115-
case 7:
116-
revealAnimator = [[SlideNavigationContorllerAnimatorSlideAndFade alloc] init];
117-
break;
118-
119-
case 8:
120-
revealAnimator = [[SlideNavigationContorllerAnimatorScale alloc] init];
121-
break;
122-
123-
case 9:
124-
revealAnimator = [[SlideNavigationContorllerAnimatorScaleAndFade alloc] init];
125-
break;
126-
127-
default:
128-
return;
129-
}
130-
131-
if (vc)
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+
132123
[[SlideNavigationController sharedInstance] switchToViewController:vc withCompletion:nil];
124+
}
133125
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+
134159
[[SlideNavigationController sharedInstance] closeMenuWithCompletion:^{
135160
[SlideNavigationController sharedInstance].menuRevealAnimator = revealAnimator;
136161
}];
162+
}
137163
}
138164

139165
@end

SlideMenu/Source/Animations/SlideNavigationContorllerAnimatorScaleAndFade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111

1212
@interface SlideNavigationContorllerAnimatorScaleAndFade : NSObject <SlideNavigationContorllerAnimator>
1313

14+
- (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fadeColor andMinimumScale:(CGFloat)minimumScale;
1415

1516
@end

SlideMenu/en.lproj/MainStoryboard_iPhone.storyboard

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
1515
<subviews>
1616
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="T7T-Ke-Ksy">
17-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
18-
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
17+
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
1919
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
20+
<inset key="insetFor6xAndEarlier" minX="0.0" minY="20" maxX="0.0" maxY="0.0"/>
2021
<prototypes>
2122
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="rightMenuCell" textLabel="69X-Zn-twq" style="IBUITableViewCellStyleDefault" id="Pb7-aS-2IS">
2223
<rect key="frame" x="0.0" y="22" width="320" height="44"/>

0 commit comments

Comments
 (0)