Browse Source

added side menu - not completed

Ran Greenberg 7 years ago
parent
commit
cb18bbcb35
47 changed files with 5693 additions and 28 deletions
  1. 5
    3
      ios/RNNControllerFactory.h
  2. 91
    10
      ios/RNNControllerFactory.m
  3. 4
    0
      ios/RNNReactRootViewCreator.m
  4. 77
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerBarButtonItem.h
  5. 302
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerBarButtonItem.m
  6. 111
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerController+Subclass.h
  7. 480
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerController.h
  8. 1529
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerController.m
  9. 61
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerVisualState.h
  10. 150
    0
      ios/RNNSideMenu/MMDrawerController/MMDrawerVisualState.m
  11. 42
    0
      ios/RNNSideMenu/MMDrawerController/MMExampleDrawerVisualStateManager.h
  12. 97
    0
      ios/RNNSideMenu/MMDrawerController/MMExampleDrawerVisualStateManager.m
  13. 45
    0
      ios/RNNSideMenu/MMDrawerController/UIViewController+MMDrawerController.h
  14. 64
    0
      ios/RNNSideMenu/MMDrawerController/UIViewController+MMDrawerController.m
  15. 10
    0
      ios/RNNSideMenu/RCCDrawerController.h
  16. 154
    0
      ios/RNNSideMenu/RCCDrawerController.m
  17. 35
    0
      ios/RNNSideMenu/RCCDrawerHelper.h
  18. 96
    0
      ios/RNNSideMenu/RCCDrawerHelper.m
  19. 24
    0
      ios/RNNSideMenu/RCCDrawerProtocol.h
  20. 22
    0
      ios/RNNSideMenu/RCCTheSideBarManagerViewController.h
  21. 258
    0
      ios/RNNSideMenu/RCCTheSideBarManagerViewController.m
  22. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarAirbnbAnimation.h
  23. 135
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarAirbnbAnimation.m
  24. 80
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarAnimation.h
  25. 101
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarAnimation.m
  26. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFacebookAnimation.h
  27. 83
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFacebookAnimation.m
  28. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFeedlyAnimation.h
  29. 89
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFeedlyAnimation.m
  30. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFlipboardAnimation.h
  31. 99
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarFlipboardAnimation.m
  32. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarLuvocracyAnimation.h
  33. 111
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarLuvocracyAnimation.m
  34. 28
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarWunderlistAnimation.h
  35. 103
    0
      ios/RNNSideMenu/TheSidebarController/Animations/SidebarWunderlistAnimation.m
  36. 91
    0
      ios/RNNSideMenu/TheSidebarController/TheSidebarController.h
  37. 414
    0
      ios/RNNSideMenu/TheSidebarController/TheSidebarController.m
  38. 17
    0
      ios/RNNSideMenuCenterVC.h
  39. 24
    0
      ios/RNNSideMenuCenterVC.m
  40. 22
    0
      ios/RNNSideMenuController.h
  41. 49
    0
      ios/RNNSideMenuController.m
  42. 17
    0
      ios/RNNSideMenuLeftVC.h
  43. 28
    0
      ios/RNNSideMenuLeftVC.m
  44. 17
    0
      ios/RNNSideMenuRightVC.h
  45. 26
    0
      ios/RNNSideMenuRightVC.m
  46. 200
    0
      ios/ReactNativeNavigation.xcodeproj/project.pbxproj
  47. 162
    15
      playground/ios/playgroundTests/RNNControllerFactoryTest.m

+ 5
- 3
ios/RNNControllerFactory.h View File

@@ -2,9 +2,11 @@
2 2
 #import <Foundation/Foundation.h>
3 3
 #import <UIKit/UIKit.h>
4 4
 #import "RNNRootViewCreator.h"
5
-
6
-
7
-
5
+#import "RNNRootViewController.h"
6
+#import "RNNSideMenuController.h"
7
+#import "RNNSideMenuCenterVC.h"
8
+#import "RNNSideMenuLeftVC.h"
9
+#import "RNNSideMenuRightVC.h"
8 10
 
9 11
 @interface RNNControllerFactory : NSObject
10 12
 

+ 91
- 10
ios/RNNControllerFactory.m View File

@@ -1,7 +1,8 @@
1 1
 
2 2
 #import "RNNControllerFactory.h"
3 3
 #import "RNNLayoutNode.h"
4
-#import "RNNRootViewController.h"
4
+
5
+
5 6
 
6 7
 @interface RNNControllerFactory ()
7 8
 
@@ -18,7 +19,7 @@
18 19
 	
19 20
 	self = [super init];
20 21
 	self.creator = creator;
21
-
22
+	
22 23
 	return self;
23 24
 }
24 25
 
@@ -33,21 +34,38 @@
33 34
 {
34 35
 	RNNLayoutNode* node = [RNNLayoutNode create:json];
35 36
 	
36
-	if (node.isContainer)
37
-	{
37
+	if ( node.isContainer) {
38
+		
38 39
 		return [self createContainer:node];
39
-	} else if (node.isContainerStack)
40
-	{
40
+	}
41
+	
42
+	else if (node.isContainerStack)	{
41 43
 		return [self createContainerStack:node];
42
-	} else if (node.isTabs)
43
-	{
44
+	}
45
+	
46
+	else if (node.isTabs) {
44 47
 		return [self createTabs:node];
45 48
 	}
46 49
 	
50
+	else if (node.isSideMenuRoot) {
51
+		return [self createSideMenu:node];
52
+	}
53
+	
54
+	else if (node.isSideMenuCenter) {
55
+		return [self createSideMenuCenter:node];
56
+	}
57
+	
58
+	else if (node.isSideMenuLeft) {
59
+		return [self createSideMenuLeft:node];
60
+	}
61
+	else if (node.isSideMenuRight) {
62
+		return [self createSideMenuRight:node];
63
+	}
64
+	
47 65
 	@throw [NSException exceptionWithName:@"UnknownControllerType" reason:[@"Unknown controller type " stringByAppendingString:node.type] userInfo:nil];
48 66
 }
49 67
 
50
--(UIViewController*)createContainer:(RNNLayoutNode*)node
68
+-(RNNRootViewController*)createContainer:(RNNLayoutNode*)node
51 69
 {
52 70
 	return [[RNNRootViewController alloc] initWithNode:node rootViewCreator:self.creator];
53 71
 }
@@ -70,7 +88,7 @@
70 88
 	UITabBarController* vc = [[UITabBarController alloc] init];
71 89
 	
72 90
 	NSMutableArray* controllers = [NSMutableArray new];
73
-	for (NSDictionary* child in node.children) {
91
+	for (NSDictionary *child in node.children) {
74 92
 		UIViewController* childVc = [self fromTree:child];
75 93
 		
76 94
 		UITabBarItem* item = [[UITabBarItem alloc] initWithTitle:@"A Tab" image:nil tag:1];
@@ -82,4 +100,67 @@
82 100
 	return vc;
83 101
 }
84 102
 
103
+-(UIViewController*)createSideMenu:(RNNLayoutNode*)node
104
+{
105
+	//	NSArray *childern = node.children;
106
+	//	id center, left, right;
107
+	
108
+	//	for (NSDictionary *child in childern) {
109
+	//		RNNLayoutNode *childNode = [RNNLayoutNode create:child];
110
+	//		UIViewController *vc = [self fromTree:child];
111
+	//
112
+	//		if ([childNode isSideMenuLeft]) {
113
+	//			left = vc;
114
+	//		}
115
+	//		else if ([childNode isSideMenuCenter]) {
116
+	//			center = vc;
117
+	//		}
118
+	//		else if ([childNode isSideMenuRight]) {
119
+	//			right = [self fromTree:child];
120
+	//		}
121
+	//		else {
122
+	//			@throw [NSException exceptionWithName:@"UnknownSideMenuType" reason:[@"Unknown side menu type for side menu root node " stringByAppendingString:childNode.type] userInfo:nil];
123
+	//		}
124
+	//	}
125
+	
126
+	//	if (!center) {
127
+	//		@throw [NSException exceptionWithName:@"WrongSideMenuDefinition" reason:@"Side menu without center is illigal" userInfo:nil];
128
+	//	}
129
+	//
130
+	//	MMDrawerController *sideMenu = [[MMDrawerController alloc] initWithCenterViewController:center leftDrawerViewController:left rightDrawerViewController:right];
131
+	
132
+	NSMutableArray* childrenVCs = [NSMutableArray new];
133
+	
134
+	
135
+	for (NSDictionary *child in node.children) {
136
+		UIViewController *vc = [self fromTree:child];
137
+		[childrenVCs addObject:vc];
138
+	}
139
+	
140
+	RNNSideMenuController *sideMenu = [[RNNSideMenuController alloc] initWithControllers:childrenVCs];
141
+	return sideMenu;
142
+}
143
+
144
+-(UIViewController*)createSideMenuCenter:(RNNLayoutNode*)node {
145
+	UIViewController* child = [self fromTree:node.children[0]];
146
+	RNNSideMenuCenterVC *center = [[RNNSideMenuCenterVC alloc] initWithChild: child];
147
+	return center;
148
+}
149
+
150
+-(UIViewController*)createSideMenuLeft:(RNNLayoutNode*)node {
151
+	UIViewController* child = [self fromTree:node.children[0]];
152
+	RNNSideMenuLeftVC *left = [[RNNSideMenuLeftVC alloc] initWithChild:child];
153
+	
154
+	return left;
155
+}
156
+
157
+-(UIViewController*)createSideMenuRight:(RNNLayoutNode*)node {
158
+	UIViewController* child = [self fromTree:node.children[0]];
159
+	RNNSideMenuRightVC *right = [[RNNSideMenuRightVC alloc] initWithChild:child];
160
+	
161
+	return right;
162
+
163
+}
164
+
165
+
85 166
 @end

+ 4
- 0
ios/RNNReactRootViewCreator.m View File

@@ -15,6 +15,10 @@
15 15
  - (UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId
16 16
 {
17 17
 	
18
+	if (!rootViewId) {
19
+		@throw [NSException exceptionWithName:@"MissingViewId" reason:@"Missing view id" userInfo:nil];
20
+	}
21
+	
18 22
 	UIView *view = [[RCTRootView alloc] initWithBridge:[RNN instance].bridge
19 23
 										 moduleName:name
20 24
 								  initialProperties:@{@"id": rootViewId}];

+ 77
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerBarButtonItem.h View File

@@ -0,0 +1,77 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+#import <UIKit/UIKit.h>
22
+
23
+/**
24
+  `MMDrawerBarButtonItem` provides convenience methods to create `UIBarButtonItems` with a default hamburger-menu asset.
25
+ */
26
+
27
+@interface MMDrawerBarButtonItem : UIBarButtonItem
28
+
29
+///---------------------------------------
30
+/// @name Initializing a `MMDrawerBarButtonItem`
31
+///---------------------------------------
32
+
33
+/**
34
+ Creates and initializes an `MMDrawerBarButtonItem` without a border.
35
+ 
36
+ @param target The target to forward the `action` to when the button is pressed.
37
+ @param action The action to call when the button is pressed.
38
+ 
39
+ @return The newly-initialized bar button item.
40
+ */
41
+-(instancetype)initWithTarget:(id)target action:(SEL)action;
42
+
43
+/**
44
+ Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead.
45
+ 
46
+ @param state The UIControl state that the color is being requested for.
47
+ 
48
+ @return The menu button color for the requested state.
49
+ */
50
+-(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
51
+
52
+/**
53
+ Sets the color of the menu button for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. Use `tintColor` instead.
54
+ 
55
+ @param color The color to set.
56
+ @param state The state to set the color for.
57
+ */
58
+-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead")));
59
+
60
+/**
61
+ Returns the current color of the shadow for the state requested. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow.
62
+ 
63
+ @param state The UIControl state that the color is being requested for.
64
+ 
65
+ @return The menu button color for the requested state.
66
+ */
67
+-(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
68
+
69
+/**
70
+ Sets the color of the shadow for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow.
71
+ 
72
+ @param color The color to set.
73
+ @param state The state to set the color for.
74
+ */
75
+-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported")));
76
+
77
+@end

+ 302
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerBarButtonItem.m View File

@@ -0,0 +1,302 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import "MMDrawerBarButtonItem.h"
23
+
24
+@interface MMDrawerMenuButtonView : UIButton
25
+@property (nonatomic,strong) UIColor * menuButtonNormalColor;
26
+@property (nonatomic,strong) UIColor * menuButtonHighlightedColor;
27
+
28
+@property (nonatomic,strong) UIColor * shadowNormalColor;
29
+@property (nonatomic,strong) UIColor * shadowHighlightedColor;
30
+
31
+-(UIColor *)menuButtonColorForState:(UIControlState)state;
32
+-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state;
33
+
34
+-(UIColor *)shadowColorForState:(UIControlState)state;
35
+-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state;
36
+
37
+@end
38
+
39
+@implementation MMDrawerMenuButtonView
40
+
41
+-(instancetype)initWithFrame:(CGRect)frame{
42
+    self = [super initWithFrame:frame];
43
+    if(self){
44
+        [self setMenuButtonNormalColor:[[UIColor whiteColor] colorWithAlphaComponent:0.9f]];
45
+        [self setMenuButtonHighlightedColor:[UIColor colorWithRed:139.0/255.0
46
+                                                            green:135.0/255.0
47
+                                                             blue:136.0/255.0
48
+                                                            alpha:0.9f]];
49
+        
50
+        [self setShadowNormalColor:[[UIColor blackColor] colorWithAlphaComponent:0.5f]];
51
+        [self setShadowHighlightedColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]];
52
+    }
53
+    return self;
54
+}
55
+
56
+-(UIColor *)menuButtonColorForState:(UIControlState)state{
57
+    UIColor * color;
58
+    switch (state) {
59
+        case UIControlStateNormal:
60
+            color = self.menuButtonNormalColor;
61
+            break;
62
+        case UIControlStateHighlighted:
63
+            color = self.menuButtonHighlightedColor;
64
+            break;
65
+        default:
66
+            break;
67
+    }
68
+    return color;
69
+}
70
+
71
+-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
72
+    switch (state) {
73
+        case UIControlStateNormal:
74
+            [self setMenuButtonNormalColor:color];
75
+            break;
76
+        case UIControlStateHighlighted:
77
+            [self setMenuButtonHighlightedColor:color];
78
+            break;
79
+        default:
80
+            break;
81
+    }
82
+    [self setNeedsDisplay];
83
+}
84
+
85
+-(UIColor *)shadowColorForState:(UIControlState)state{
86
+    UIColor * color;
87
+    switch (state) {
88
+        case UIControlStateNormal:
89
+            color = self.shadowNormalColor;
90
+            break;
91
+        case UIControlStateHighlighted:
92
+            color = self.shadowHighlightedColor;
93
+            break;
94
+        default:
95
+            break;
96
+    }
97
+    return color;
98
+}
99
+
100
+-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{
101
+    switch (state) {
102
+        case UIControlStateNormal:
103
+            [self setShadowNormalColor:color];
104
+            break;
105
+        case UIControlStateHighlighted:
106
+            [self setShadowHighlightedColor:color];
107
+            break;
108
+        default:
109
+            break;
110
+    }
111
+    [self setNeedsDisplay];
112
+}
113
+
114
+-(void)drawRect:(CGRect)rect{
115
+    //// General Declarations
116
+    CGContextRef context = UIGraphicsGetCurrentContext();
117
+    
118
+    //Sizes
119
+    CGFloat buttonWidth = CGRectGetWidth(self.bounds)*.80;
120
+    CGFloat buttonHeight = CGRectGetHeight(self.bounds)*.16;
121
+    CGFloat xOffset = CGRectGetWidth(self.bounds)*.10;
122
+    CGFloat yOffset = CGRectGetHeight(self.bounds)*.12;
123
+    CGFloat cornerRadius = 1.0;
124
+    
125
+    //// Color Declarations
126
+    UIColor*  buttonColor = [self menuButtonColorForState:self.state];
127
+    UIColor*  shadowColor = [self shadowColorForState:self.state];
128
+
129
+    
130
+    //// Shadow Declarations
131
+    UIColor* shadow =  shadowColor;
132
+    CGSize shadowOffset = CGSizeMake(0.0, 1.0);
133
+    CGFloat shadowBlurRadius = 0;
134
+    
135
+    //// Top Bun Drawing
136
+    UIBezierPath* topBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
137
+    CGContextSaveGState(context);
138
+    CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
139
+    [buttonColor setFill];
140
+    [topBunPath fill];
141
+    CGContextRestoreGState(context);
142
+    
143
+    //// Meat Drawing
144
+    UIBezierPath* meatPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
145
+    CGContextSaveGState(context);
146
+    CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
147
+    [buttonColor setFill];
148
+    [meatPath fill];
149
+    CGContextRestoreGState(context);
150
+    
151
+    //// Bottom Bun Drawing
152
+    UIBezierPath* bottomBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight) cornerRadius:cornerRadius];
153
+    CGContextSaveGState(context);
154
+    CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor);
155
+    [buttonColor setFill];
156
+    [bottomBunPath fill];
157
+    CGContextRestoreGState(context);
158
+}
159
+
160
+-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
161
+    [super touchesBegan:touches withEvent:event];
162
+    [self setNeedsDisplay];
163
+}
164
+
165
+-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
166
+    [super touchesEnded:touches withEvent:event];
167
+    [self setNeedsDisplay];
168
+}
169
+
170
+-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
171
+    [super touchesCancelled:touches withEvent:event];
172
+    [self setNeedsDisplay];
173
+}
174
+
175
+-(void)setSelected:(BOOL)selected{
176
+    [super setSelected:selected];
177
+    [self setNeedsDisplay];
178
+}
179
+
180
+-(void)setHighlighted:(BOOL)highlighted{
181
+    [super setHighlighted:highlighted];
182
+    [self setNeedsDisplay];
183
+}
184
+
185
+-(void)setTintColor:(UIColor *)tintColor{
186
+    if([super respondsToSelector:@selector(setTintColor:)]){
187
+        [super setTintColor:tintColor];
188
+    }
189
+}
190
+
191
+-(void)tintColorDidChange{
192
+     [self setNeedsDisplay];
193
+}
194
+
195
+@end
196
+
197
+@interface MMDrawerBarButtonItem ()
198
+@property (nonatomic,strong) MMDrawerMenuButtonView * buttonView;
199
+
200
+@end
201
+
202
+@implementation MMDrawerBarButtonItem
203
+
204
++(UIImage*)drawerButtonItemImage{
205
+    
206
+    static UIImage *drawerButtonImage = nil;
207
+    static dispatch_once_t onceToken;
208
+    dispatch_once(&onceToken, ^{
209
+
210
+        UIGraphicsBeginImageContextWithOptions( CGSizeMake(26, 26), NO, 0 );
211
+        
212
+        //// Color Declarations
213
+        UIColor* fillColor = [UIColor whiteColor];
214
+        
215
+        //// Frames
216
+        CGRect frame = CGRectMake(0, 0, 26, 26);
217
+        
218
+        //// Bottom Bar Drawing
219
+        UIBezierPath* bottomBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.72000 + 0.5), 16, 1)];
220
+        [fillColor setFill];
221
+        [bottomBarPath fill];
222
+        
223
+        
224
+        //// Middle Bar Drawing
225
+        UIBezierPath* middleBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.48000 + 0.5), 16, 1)];
226
+        [fillColor setFill];
227
+        [middleBarPath fill];
228
+        
229
+        
230
+        //// Top Bar Drawing
231
+        UIBezierPath* topBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.24000 + 0.5), 16, 1)];
232
+        [fillColor setFill];
233
+        [topBarPath fill];
234
+        
235
+        drawerButtonImage = UIGraphicsGetImageFromCurrentImageContext();
236
+    });
237
+    
238
+    return drawerButtonImage;
239
+}
240
+
241
+-(instancetype)initWithTarget:(id)target action:(SEL)action{
242
+    
243
+    if((floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)){
244
+        return [self initWithImage:[self.class drawerButtonItemImage]
245
+                             style:UIBarButtonItemStylePlain
246
+                            target:target
247
+                            action:action];
248
+    }
249
+    else {
250
+        MMDrawerMenuButtonView * buttonView = [[MMDrawerMenuButtonView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)];
251
+        [buttonView addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside];
252
+        self = [self initWithCustomView:buttonView];
253
+        if(self){
254
+            [self setButtonView:buttonView];
255
+        }
256
+        self.action = action;
257
+        self.target = target;
258
+        return self;
259
+    }
260
+}
261
+
262
+-(instancetype)initWithCoder:(NSCoder *)aDecoder{
263
+    // non-ideal way to get the target/action, but it works
264
+    UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCoder: aDecoder];
265
+    return [self initWithTarget:barButtonItem.target action:barButtonItem.action];
266
+}
267
+
268
+-(void)touchUpInside:(id)sender{
269
+
270
+#pragma clang diagnostic push
271
+#pragma clang diagnostic ignored "-Warc-performSelector-leaks"    
272
+    [self.target performSelector:self.action withObject:sender];
273
+#pragma clang diagnostic pop;
274
+    
275
+}
276
+
277
+-(UIColor *)menuButtonColorForState:(UIControlState)state{
278
+    return [self.buttonView menuButtonColorForState:state];
279
+}
280
+
281
+-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{
282
+    [self.buttonView setMenuButtonColor:color forState:state];
283
+}
284
+
285
+-(UIColor *)shadowColorForState:(UIControlState)state{
286
+    return [self.buttonView shadowColorForState:state];
287
+}
288
+
289
+-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{
290
+    [self.buttonView setShadowColor:color forState:state];
291
+}
292
+
293
+-(void)setTintColor:(UIColor *)tintColor{
294
+    if([super respondsToSelector:@selector(setTintColor:)]){
295
+        [super setTintColor:tintColor];
296
+    }
297
+    if([self.buttonView respondsToSelector:@selector(setTintColor:)]){
298
+        [self.buttonView setTintColor:tintColor];
299
+    }
300
+}
301
+
302
+@end

+ 111
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerController+Subclass.h View File

@@ -0,0 +1,111 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+#import "MMDrawerController.h"
22
+
23
+/**
24
+ This class extension is designed for use by subclasses of `MMDrawerController` to customize the functionality to support a specific use-case by a developer. When importing this file, there is no need to also call `#import MMDrawerController.h`.
25
+ 
26
+ None of these methods are meant to be called by non-subclasses of `MMDrawerController`.
27
+ */
28
+
29
+@interface MMDrawerController (Subclass)
30
+///---------------------------------------
31
+/// @name Gesture Interaction
32
+///---------------------------------------
33
+/** 
34
+ `MMDrawerController`'s single-tap gesture recognizer callback. This method is called every time the `UITapGestureRecognizer` is triggered.
35
+ 
36
+ @param tapGesture The single-tap gesture recognizer instance that triggered the callback
37
+ */
38
+-(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture __attribute((objc_requires_super));
39
+
40
+/** 
41
+ `MMDrawerController`'s pan gesture recognizer callback. This method is called every time the `UIPanGestureRecognizer` is updated.
42
+ 
43
+ @warning This method do the minimal amount of work to keep the pan gesture responsive.
44
+ 
45
+ @param panGesture The pan gesture recognizer instance that triggered the callback
46
+ */
47
+-(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture __attribute((objc_requires_super));
48
+
49
+/**
50
+ A `UIGestureRecognizerDelegate` method that is queried by `MMDrawerController`'s gestures to determine if it should receive the touch.
51
+ 
52
+ @param gestureRecognizer The gesture recognizer that is asking if it should recieve a touch
53
+ @param touch The touch in question in gestureRecognizer.view's coordinate space
54
+ */
55
+-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch __attribute((objc_requires_super));
56
+
57
+///---------------------------------------
58
+/// @name Drawer Presentation
59
+///---------------------------------------
60
+/** 
61
+ Sets the initial conditions for `MMDrawerController` and its child view controllers to prepare the drawer for a transition. If a drawer is open and the opposite drawer is being presented, it prepares that drawer to be hidden and vice-versa for the closing drawer.
62
+ 
63
+ @param drawer The drawer side that will be presented
64
+ @param animated A boolean that indicates whether the presentation is being animated or not
65
+ */
66
+-(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated __attribute((objc_requires_super));
67
+
68
+///---------------------------------------
69
+/// @name Opening/Closing Drawer
70
+///---------------------------------------
71
+/**
72
+ The method that handles closing the drawer. You can subclass this method to get a callback every time the drawer is about to be closed. You can inspect the current open side to determine what side is about to be closed.
73
+ 
74
+ @param animated A boolean that indicates whether the drawer should close with animation
75
+ @param velocity A float indicating how fast the drawer should close
76
+ @param animationOptions A mask defining the animation options of the animation
77
+ @param completion A completion block to be called when the drawer is finished closing
78
+ */
79
+-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super));
80
+
81
+/**
82
+ The method that handles opening the drawer. You can subclass this method to get a callback every time the drawer is about to be opened.
83
+ 
84
+ @param drawerSide The drawer side that will be opened
85
+ @param animated A boolean that indicates whether the drawer should open with animation
86
+ @param velocity A float indicating how fast the drawer should open
87
+ @param animationOptions A mask defining the animation options of the animation
88
+ @param completion A completion block to be called when the drawer is finished opening
89
+ */
90
+-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super));
91
+
92
+///---------------------------------------
93
+/// @name `UIViewController` Subclass Methods
94
+///---------------------------------------
95
+/**
96
+ Included here to ensure subclasses call `super`.
97
+ 
98
+ @param toInterfaceOrientation The interface orientation that the interface is moving to
99
+ @param duration The duration of the interface orientation animation
100
+ */
101
+-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super));
102
+
103
+/** 
104
+ Included here to ensure subclasses call `super`.
105
+ 
106
+ @param toInterfaceOrientation The interface orientation that the interface is moving to
107
+ @param duration The duration of the interface orientation animation
108
+ */
109
+-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super));
110
+
111
+@end

+ 480
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerController.h View File

@@ -0,0 +1,480 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import <UIKit/UIKit.h>
23
+
24
+/**
25
+ `MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in light-weight, focused approach.
26
+ 
27
+ ## Creating a MMDrawerController
28
+ `MMDrawerController` is a container view controller, similiar to `UINavigationController` or `UITabBarController`, with up to three child view controllers - Center, LeftDrawer, and RightDrawer. To create a `MMDrawerController`, you must first instantiate the drawer view controllers and the initial center controller, then call one of the init methods listed in this class.
29
+ 
30
+ ## Handling a UINavigationController as the centerViewController
31
+ `MMDrawerController` automatically supports handling a `UINavigationController` as the `centerViewController`, and will correctly handle the proper gestures on each view (the navigation bar view as well as the content view for the visible view controller). Note that while this library does support other container view controllers, the open/close gestures are not customized to support them.
32
+ 
33
+ ## Accessing MMDrawerController from the Child View Controller
34
+ You can leverage the category class (UIViewController+MMDrawerController) included with this library to access information about the parent `MMDrawerController`. Note that if you are contained within a UINavigationController, the `drawerContainerViewController` will still return the proper reference to the `drawerContainerViewController` parent, even though it is not the direct parent. Refer to the documentation included with the category for more information.
35
+ 
36
+ ## How MMDrawerOpenCenterInteractionMode is handled
37
+ `MMDrawerOpenCenterInteractionMode` controls how the user should be able to interact with the center view controller when either drawer is open. By default, this is set to `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, which allows the user to interact with UINavigationBarItems while either drawer is open (typicaly used to click the menu button to close). If you set the interaction mode to `MMDrawerOpenCenterInteractionModeNone`, no items within the center view will be able to be interacted with while a drawer is open. Note that this setting has no effect at all on the `MMCloseDrawerGestureMode`.
38
+ 
39
+ ## How Open/Close Gestures are handled
40
+ Two gestures are added to every instance of a drawer controller, one for pan and one for touch. `MMDrawerController` is the delegate for each of the gesture recoginzers, and determines if a touch should be sent to the appropriate gesture when a touch is detected compared with the masks set for open and close gestures and the state of the drawer controller.
41
+ 
42
+ ## Integrating with State Restoration
43
+ In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your centerViewController, leftDrawerViewController and rightDrawerViewController must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored.
44
+ 
45
+ ## What this library doesn't do.
46
+ This library is not meant for:
47
+ - Top or bottom drawer views
48
+ - Displaying both drawers at one time
49
+ - Displaying a minimum drawer width
50
+ - Support container view controllers other than `UINavigationController` as the center view controller.
51
+ */
52
+
53
+typedef NS_ENUM(NSInteger,MMDrawerSide){
54
+    MMDrawerSideNone = 0,
55
+    MMDrawerSideLeft,
56
+    MMDrawerSideRight,
57
+};
58
+
59
+typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) {
60
+    MMOpenDrawerGestureModeNone                     = 0,
61
+    MMOpenDrawerGestureModePanningNavigationBar     = 1 << 1,
62
+    MMOpenDrawerGestureModePanningCenterView        = 1 << 2,
63
+    MMOpenDrawerGestureModeBezelPanningCenterView   = 1 << 3,
64
+    MMOpenDrawerGestureModeCustom                   = 1 << 4,
65
+    MMOpenDrawerGestureModeAll                      =   MMOpenDrawerGestureModePanningNavigationBar     |
66
+    MMOpenDrawerGestureModePanningCenterView        |
67
+    MMOpenDrawerGestureModeBezelPanningCenterView   |
68
+    MMOpenDrawerGestureModeCustom,
69
+};
70
+
71
+typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) {
72
+    MMCloseDrawerGestureModeNone                    = 0,
73
+    MMCloseDrawerGestureModePanningNavigationBar    = 1 << 1,
74
+    MMCloseDrawerGestureModePanningCenterView       = 1 << 2,
75
+    MMCloseDrawerGestureModeBezelPanningCenterView  = 1 << 3,
76
+    MMCloseDrawerGestureModeTapNavigationBar        = 1 << 4,
77
+    MMCloseDrawerGestureModeTapCenterView           = 1 << 5,
78
+    MMCloseDrawerGestureModePanningDrawerView       = 1 << 6,
79
+    MMCloseDrawerGestureModeCustom                  = 1 << 7,
80
+    MMCloseDrawerGestureModeAll                     =   MMCloseDrawerGestureModePanningNavigationBar    |
81
+    MMCloseDrawerGestureModePanningCenterView       |
82
+    MMCloseDrawerGestureModeBezelPanningCenterView  |
83
+    MMCloseDrawerGestureModeTapNavigationBar        |
84
+    MMCloseDrawerGestureModeTapCenterView           |
85
+    MMCloseDrawerGestureModePanningDrawerView       |
86
+    MMCloseDrawerGestureModeCustom,
87
+};
88
+
89
+typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) {
90
+    MMDrawerOpenCenterInteractionModeNone,
91
+    MMDrawerOpenCenterInteractionModeFull,
92
+    MMDrawerOpenCenterInteractionModeNavigationBarOnly,
93
+};
94
+
95
+@class  MMDrawerController;
96
+typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible);
97
+
98
+@interface MMDrawerController : UIViewController
99
+
100
+///---------------------------------------
101
+/// @name Accessing Drawer Container View Controller Properties
102
+///---------------------------------------
103
+
104
+/**
105
+ The center view controller.
106
+ 
107
+ This can only be set via the init methods, as well as the `setNewCenterViewController:...` methods. The size of this view controller will automatically be set to the size of the drawer container view controller, and it's position is modified from within this class. Do not modify the frame externally.
108
+ */
109
+@property (nonatomic, strong) UIViewController * centerViewController;
110
+
111
+/**
112
+ The left drawer view controller.
113
+ 
114
+ The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumLeftDrawerWidth`. Do not modify the frame externally.
115
+ */
116
+@property (nonatomic, strong) UIViewController * leftDrawerViewController;
117
+
118
+/**
119
+ The right drawer view controller.
120
+ 
121
+ The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumRightDrawerWidth`. Do not modify the frame externally.
122
+ */
123
+@property (nonatomic, strong) UIViewController * rightDrawerViewController;
124
+
125
+/**
126
+ The maximum width of the `leftDrawerViewController`.
127
+ 
128
+ By default, this is set to 280. If the `leftDrawerViewController` is nil, this property will return 0.0;
129
+ */
130
+@property (nonatomic, assign) CGFloat maximumLeftDrawerWidth;
131
+
132
+/**
133
+ The maximum width of the `rightDrawerViewController`.
134
+ 
135
+ By default, this is set to 280. If the `rightDrawerViewController` is nil, this property will return 0.0;
136
+ 
137
+ */
138
+@property (nonatomic, assign) CGFloat maximumRightDrawerWidth;
139
+
140
+/**
141
+ The visible width of the `leftDrawerViewController`.
142
+ 
143
+ Note this value can be greater than `maximumLeftDrawerWidth` during the full close animation when setting a new center view controller;
144
+ */
145
+@property (nonatomic, assign, readonly) CGFloat visibleLeftDrawerWidth;
146
+
147
+/**
148
+ The visible width of the `rightDrawerViewController`.
149
+ 
150
+ Note this value can be greater than `maximumRightDrawerWidth` during the full close animation when setting a new center view controller;
151
+ */
152
+@property (nonatomic, assign, readonly) CGFloat visibleRightDrawerWidth;
153
+
154
+/**
155
+ The animation velocity of the open and close methods, measured in points per second.
156
+ 
157
+ By default, this is set to 840 points per second (three times the default drawer width), meaning it takes 1/3 of a second for the `centerViewController` to open/close across the default drawer width. Note that there is a minimum .1 second duration for built in animations, to account for small distance animations.
158
+ */
159
+@property (nonatomic, assign) CGFloat animationVelocity;
160
+
161
+/**
162
+ A boolean that determines whether or not the panning gesture will "hard-stop" at the maximum width for a given drawer side.
163
+ 
164
+ By default, this value is set to YES. Enabling `shouldStretchDrawer` will give the pan a gradual asymptotic stopping point much like `UIScrollView` behaves. Note that if this value is set to YES, the `drawerVisualStateBlock` can be passed a `percentVisible` greater than 1.0, so be sure to handle that case appropriately.
165
+ */
166
+@property (nonatomic, assign) BOOL shouldStretchDrawer;
167
+
168
+/**
169
+ The current open side of the drawer.
170
+ 
171
+ Note this value will change as soon as a pan gesture opens a drawer, or when a open/close animation is finished.
172
+ */
173
+@property (nonatomic, assign, readonly) MMDrawerSide openSide;
174
+
175
+/**
176
+ How a user is allowed to open a drawer using gestures.
177
+ 
178
+ By default, this is set to `MMOpenDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately.
179
+ */
180
+@property (nonatomic, assign) MMOpenDrawerGestureMode openDrawerGestureModeMask;
181
+
182
+/**
183
+ How a user is allowed to close a drawer.
184
+ 
185
+ By default, this is set to `MMCloseDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately.
186
+ */
187
+@property (nonatomic, assign) MMCloseDrawerGestureMode closeDrawerGestureModeMask;
188
+
189
+/**
190
+ The value determining if the user can interact with the `centerViewController` when a side drawer is open.
191
+ 
192
+ By default, it is `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, meaning that the user can only interact with the buttons on the `UINavigationBar`, if the center view controller is a `UINavigationController`. Otherwise, the user cannot interact with any other center view controller elements.
193
+ */
194
+@property (nonatomic, assign) MMDrawerOpenCenterInteractionMode centerHiddenInteractionMode;
195
+
196
+/**
197
+ The flag determining if a shadow should be drawn off of `centerViewController` when a drawer is open.
198
+ 
199
+ By default, this is set to YES.
200
+ */
201
+@property (nonatomic, assign) BOOL showsShadow;
202
+
203
+/**
204
+ The shadow radius of `centerViewController` when a drawer is open.
205
+ 
206
+ By default, this is set to 10.0f;
207
+ */
208
+@property (nonatomic, assign) CGFloat shadowRadius;
209
+
210
+/**
211
+ The shadow opacity of `centerViewController` when a drawer is open.
212
+ 
213
+ By default, this is set to 0.8f;
214
+ */
215
+@property (nonatomic, assign) CGFloat shadowOpacity;
216
+
217
+/**
218
+ The shadow offset of `centerViewController` when a drawer is open.
219
+ 
220
+ By default, this is set to (0, -3);
221
+ */
222
+@property (nonatomic, assign) CGSize shadowOffset;
223
+
224
+/**
225
+ The color of the shadow drawn off of 'centerViewController` when a drawer is open.
226
+ 
227
+ By default, this is set to the systme default (opaque black).
228
+ */
229
+@property (nonatomic, strong) UIColor * shadowColor;
230
+
231
+/**
232
+ The flag determining if a custom background view should appear beneath the status bar, forcing the child content to be drawn lower than the status bar.
233
+ 
234
+ By default, this is set to NO.
235
+ */
236
+@property (nonatomic, assign) BOOL showsStatusBarBackgroundView;
237
+
238
+/**
239
+ The color of the status bar background view if `showsStatusBarBackgroundView` is set to YES.
240
+ 
241
+ By default, this is set `[UIColor blackColor]`.
242
+ */
243
+@property (nonatomic, strong) UIColor * statusBarViewBackgroundColor;
244
+
245
+/**
246
+ The value determining panning range of centerView's bezel if the user can open drawer with 'MMOpenDrawerGestureModeBezelPanningCenterView' or close drawer with 'MMCloseDrawerGestureModeBezelPanningCenterView' .
247
+ 
248
+ By default, this is set 20.0f.
249
+ */
250
+@property (nonatomic, assign) CGFloat bezelPanningCenterViewRange;
251
+
252
+/**
253
+ The value determining if the user can open or close drawer with panGesture velocity.
254
+ 
255
+ By default, this is set 200.0f.
256
+ */
257
+@property (nonatomic, assign) CGFloat panVelocityXAnimationThreshold;
258
+
259
+///---------------------------------------
260
+/// @name Initializing a `MMDrawerController`
261
+///---------------------------------------
262
+
263
+/**
264
+ Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller, and right drawer view controller.
265
+ 
266
+ @param centerViewController The center view controller. This argument must not be `nil`.
267
+ @param leftDrawerViewController The left drawer view controller.
268
+ @param rightDrawerViewController The right drawer controller.
269
+ 
270
+ @return The newly-initialized drawer container view controller.
271
+ */
272
+-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController;
273
+
274
+/**
275
+ Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller.
276
+ 
277
+ @param centerViewController The center view controller. This argument must not be `nil`.
278
+ @param leftDrawerViewController The left drawer view controller.
279
+ 
280
+ @return The newly-initialized drawer container view controller.
281
+ */
282
+-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController;
283
+
284
+/**
285
+ Creates and initializes an `MMDrawerController` object with the specified center view controller, right drawer view controller.
286
+ 
287
+ @param centerViewController The center view controller. This argument must not be `nil`.
288
+ @param rightDrawerViewController The right drawer controller.
289
+ 
290
+ @return The newly-initialized drawer container view controller.
291
+ */
292
+-(instancetype)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController;
293
+
294
+///---------------------------------------
295
+/// @name Opening and Closing a Drawer
296
+///---------------------------------------
297
+
298
+/**
299
+ Toggles the drawer open/closed based on the `drawer` passed in.
300
+ 
301
+ Note that if you attempt to toggle a drawer closed while the other is open, nothing will happen. For example, if you pass in MMDrawerSideLeft, but the right drawer is open, nothing will happen. In addition, the completion block will be called with the finished flag set to NO.
302
+ 
303
+ @param drawerSide The `MMDrawerSide` to toggle. This value cannot be `MMDrawerSideNone`.
304
+ @param animated Determines whether the `drawer` should be toggle animated.
305
+ @param completion The block that is called when the toggle is complete, or if no toggle took place at all.
306
+ 
307
+ */
308
+-(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
309
+
310
+/**
311
+ Closes the open drawer.
312
+ 
313
+ @param animated Determines whether the drawer side should be closed animated
314
+ @param completion The block that is called when the close is complete
315
+ 
316
+ */
317
+-(void)closeDrawerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
318
+
319
+/**
320
+ Opens the `drawer` passed in.
321
+ 
322
+ @param drawerSide The `MMDrawerSide` to open. This value cannot be `MMDrawerSideNone`.
323
+ @param animated Determines whether the `drawer` should be open animated.
324
+ @param completion The block that is called when the toggle is open.
325
+ 
326
+ */
327
+-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
328
+
329
+///---------------------------------------
330
+/// @name Setting a new Center View Controller
331
+///---------------------------------------
332
+
333
+/**
334
+ Sets the new `centerViewController`.
335
+ 
336
+ This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeAnimated` is YES, it will immediately change the center view controller, and close the drawer from its current position.
337
+ 
338
+ @param centerViewController The new `centerViewController`.
339
+ @param closeAnimated Determines whether the drawer should be closed with an animation.
340
+ @param completion The block called when the animation is finsihed.
341
+ 
342
+ */
343
+-(void)setCenterViewController:(UIViewController *)centerViewController withCloseAnimation:(BOOL)closeAnimated completion:(void(^)(BOOL finished))completion;
344
+
345
+
346
+/**
347
+ Sets the new `centerViewController.overlayViewColor`.
348
+ 
349
+ This sets the overlay view color
350
+ 
351
+ @param color The new `UIColor`.
352
+ 
353
+ */
354
+-(void)setCenterOverlayColor:(UIColor*)color;
355
+
356
+
357
+/**
358
+ Sets the new `centerViewController`.
359
+ 
360
+ This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeFullAnimated` is YES, the current center view controller will animate off the screen, the new center view controller will then be set, followed by the drawer closing across the full width of the screen.
361
+ 
362
+ @param newCenterViewController The new `centerViewController`.
363
+ @param fullCloseAnimated Determines whether the drawer should be closed with an animation.
364
+ @param completion The block called when the animation is finsihed.
365
+ 
366
+ */
367
+-(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)fullCloseAnimated completion:(void(^)(BOOL finished))completion;
368
+
369
+///---------------------------------------
370
+/// @name Animating the Width of a Drawer
371
+///---------------------------------------
372
+
373
+/**
374
+ Sets the maximum width of the left drawer view controller.
375
+ 
376
+ If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately.
377
+ 
378
+ @param width The new width of left drawer view controller. This must be greater than zero.
379
+ @param animated Determines whether the drawer should be adjusted with an animation.
380
+ @param completion The block called when the animation is finished.
381
+ 
382
+ */
383
+-(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
384
+
385
+/**
386
+ Sets the maximum width of the right drawer view controller.
387
+ 
388
+ If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately.
389
+ 
390
+ @param width The new width of right drawer view controller. This must be greater than zero.
391
+ @param animated Determines whether the drawer should be adjusted with an animation.
392
+ @param completion The block called when the animation is finished.
393
+ 
394
+ */
395
+-(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion;
396
+
397
+///---------------------------------------
398
+/// @name Previewing a Drawer
399
+///---------------------------------------
400
+
401
+/**
402
+ Bounce preview for the specified `drawerSide` a distance of 40 points.
403
+ 
404
+ @param drawerSide The drawer to preview. This value cannot be `MMDrawerSideNone`.
405
+ @param completion The block called when the animation is finsihed.
406
+ 
407
+ */
408
+-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion;
409
+
410
+/**
411
+ Bounce preview for the specified `drawerSide`.
412
+ 
413
+ @param drawerSide The drawer side to preview. This value cannot be `MMDrawerSideNone`.
414
+ @param distance The distance to bounce.
415
+ @param completion The block called when the animation is finsihed.
416
+ 
417
+ */
418
+-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion;
419
+
420
+///---------------------------------------
421
+/// @name Custom Drawer Animations
422
+///---------------------------------------
423
+
424
+/**
425
+ Sets a callback to be called when a drawer visual state needs to be updated.
426
+ 
427
+ This block is responsible for updating the drawer's view state, and the drawer controller will handle animating to that state from the current state. This block will be called when the drawer is opened or closed, as well when the user is panning the drawer. This block is not responsible for doing animations directly, but instead just updating the state of the properies (such as alpha, anchor point, transform, etc). Note that if `shouldStretchDrawer` is set to YES, it is possible for `percentVisible` to be greater than 1.0. If `shouldStretchDrawer` is set to NO, `percentVisible` will never be greater than 1.0.
428
+ 
429
+ Note that when the drawer is finished opening or closing, the side drawer controller view will be reset with the following properies:
430
+ 
431
+ - alpha: 1.0
432
+ - transform: CATransform3DIdentity
433
+ - anchorPoint: (0.5,0.5)
434
+ 
435
+ @param drawerVisualStateBlock A block object to be called that allows the implementer to update visual state properties on the drawer. `percentVisible` represents the amount of the drawer space that is current visible, with drawer space being defined as the edge of the screen to the maxmimum drawer width. Note that you do have access to the drawerController, which will allow you to update things like the anchor point of the side drawer layer.
436
+ */
437
+-(void)setDrawerVisualStateBlock:(void(^)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible))drawerVisualStateBlock;
438
+
439
+///---------------------------------------
440
+/// @name Gesture Completion Handling
441
+///---------------------------------------
442
+
443
+/**
444
+ Sets a callback to be called when a gesture has been completed.
445
+ 
446
+ This block is called when a gesture action has been completed. You can query the `openSide` of the `drawerController` to determine what the new state of the drawer is.
447
+ 
448
+ @param gestureCompletionBlock A block object to be called that allows the implementer be notified when a gesture action has been completed.
449
+ */
450
+-(void)setGestureCompletionBlock:(void(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture))gestureCompletionBlock;
451
+
452
+///---------------------------------------
453
+/// @name Gesture Start Handling
454
+///---------------------------------------
455
+
456
+/**
457
+ Sets a callback to be called when a gesture starts
458
+ 
459
+ This block is called when a gesture action has started.
460
+ 
461
+ @param gestureCompletionBlock A block object to be called that allows the implementer be notified when a gesture action has started.
462
+ */
463
+-(void)setGestureStartBlock:(void (^)(MMDrawerController *, UIGestureRecognizer *))gestureStartBlock;
464
+
465
+///---------------------------------------
466
+/// @name Custom Gesture Handler
467
+///---------------------------------------
468
+
469
+/**
470
+ Sets a callback to be called to determine if a UIGestureRecognizer should recieve the given UITouch.
471
+ 
472
+ This block provides a way to allow a gesture to be recognized with custom logic. For example, you may have a certain part of your view that should accept a pan gesture recognizer to open the drawer, but not another a part. If you return YES, the gesture is recognized and the appropriate action is taken. This provides similar support to how Facebook allows you to pan on the background view of the main table view, but not the content itself. You can inspect the `openSide` property of the `drawerController` to determine the current state of the drawer, and apply the appropriate logic within your block.
473
+ 
474
+ Note that either `openDrawerGestureModeMask` must contain `MMOpenDrawerGestureModeCustom`, or `closeDrawerGestureModeMask` must contain `MMCloseDrawerGestureModeCustom` for this block to be consulted.
475
+ 
476
+ @param gestureShouldRecognizeTouchBlock A block object to be called to determine if the given `touch` should be recognized by the given gesture.
477
+ */
478
+-(void)setGestureShouldRecognizeTouchBlock:(BOOL(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch))gestureShouldRecognizeTouchBlock;
479
+
480
+@end

+ 1529
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerController.m
File diff suppressed because it is too large
View File


+ 61
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerVisualState.h View File

@@ -0,0 +1,61 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import <Foundation/Foundation.h>
23
+#import "MMDrawerController.h"
24
+
25
+/**
26
+ `MMDrawerVisualState` provides prebuilt visual state update blocks that can be used in the callback block of `MMDrawerController` for drawer animation.
27
+ */
28
+
29
+@interface MMDrawerVisualState : NSObject
30
+
31
+/**
32
+ Creates a slide and scale visual state block that gives an experience similar to Mailbox.app. It scales from 90% to 100%, and translates 50 pixels in the x direction. In addition, it also sets alpha from 0.0 to 1.0.
33
+ 
34
+ @return The visual state block.
35
+ */
36
++(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock;
37
+
38
+/**
39
+ Creates a slide visual state block that gives the user an experience that slides at the same speed of the center view controller during animation. This is equal to calling `parallaxVisualStateBlockWithParallaxFactor:` with a parallax factor of 1.0.
40
+ 
41
+ @return The visual state block.
42
+ */
43
++(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock;
44
+
45
+/**
46
+ Creates a swinging door visual state block that gives the user an experience that animates the drawer in along the hinge. 
47
+ 
48
+ @return The visual state block.
49
+ */
50
++(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock;
51
+
52
+/**
53
+ Creates a parallax experience that slides the side drawer view controller at a different rate than the center view controller during animation. For every parallaxFactor of points moved by the center view controller, the side drawer view controller will move 1 point. Passing in 1.0 is the  equivalent of a applying a sliding animation, while passing in MAX_FLOAT is the equivalent of having no animation at all.
54
+ 
55
+ @param parallaxFactor The amount of parallax applied to the side drawer conroller. This value must be greater than 1.0. The closer the value is to 1.0, the faster the side drawer view controller will be parallaxing.
56
+ 
57
+ @return The visual state block.
58
+ */
59
++(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor;
60
+
61
+@end

+ 150
- 0
ios/RNNSideMenu/MMDrawerController/MMDrawerVisualState.m View File

@@ -0,0 +1,150 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import "MMDrawerVisualState.h"
23
+#import <QuartzCore/QuartzCore.h>
24
+
25
+@implementation MMDrawerVisualState
26
++(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{
27
+    MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
28
+    ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
29
+        CGFloat minScale = .90;
30
+        CGFloat scale = minScale + (percentVisible*(1.0-minScale));
31
+        CATransform3D scaleTransform =  CATransform3DMakeScale(scale, scale, scale);
32
+        
33
+        CGFloat maxDistance = 50;
34
+        CGFloat distance = maxDistance * percentVisible;
35
+        CATransform3D translateTransform = CATransform3DIdentity;
36
+        UIViewController * sideDrawerViewController;
37
+        if(drawerSide == MMDrawerSideLeft) {
38
+            sideDrawerViewController = drawerController.leftDrawerViewController;
39
+            translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0);
40
+        }
41
+        else if(drawerSide == MMDrawerSideRight){
42
+            sideDrawerViewController = drawerController.rightDrawerViewController;
43
+            translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0);
44
+        }
45
+        
46
+        [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)];
47
+        [sideDrawerViewController.view setAlpha:percentVisible];
48
+    };
49
+    return visualStateBlock;
50
+}
51
+
52
++(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{
53
+    return [self parallaxVisualStateBlockWithParallaxFactor:1.0];
54
+}
55
+
56
+
57
++(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{
58
+    MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
59
+    ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
60
+        UIViewController * sideDrawerViewController;
61
+        CGPoint anchorPoint;
62
+        CGFloat maxDrawerWidth = 0.0;
63
+        CGFloat xOffset;
64
+        CGFloat angle = 0.0;
65
+        
66
+        if(drawerSide==MMDrawerSideLeft){
67
+            
68
+            sideDrawerViewController = drawerController.leftDrawerViewController;
69
+            anchorPoint =  CGPointMake(1.0, .5);
70
+            maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth);
71
+            xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible;
72
+            angle = -M_PI_2+(percentVisible*M_PI_2);
73
+        }
74
+        else {
75
+            sideDrawerViewController = drawerController.rightDrawerViewController;
76
+            anchorPoint = CGPointMake(0.0, .5);
77
+            maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth);
78
+            xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible;
79
+            angle = M_PI_2-(percentVisible*M_PI_2);
80
+        }
81
+        
82
+        [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint];
83
+        [sideDrawerViewController.view.layer setShouldRasterize:YES];
84
+        [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]];
85
+        
86
+        CATransform3D swingingDoorTransform = CATransform3DIdentity;
87
+        if (percentVisible <= 1.f) {
88
+            
89
+            CATransform3D identity = CATransform3DIdentity;
90
+            identity.m34 = -1.0/1000.0;
91
+            CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0);
92
+            
93
+            CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0);
94
+            
95
+            CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform);
96
+            
97
+            swingingDoorTransform = concatTransform;
98
+        }
99
+        else{
100
+            CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
101
+            
102
+            NSInteger scalingModifier = 1.f;
103
+            if (drawerSide == MMDrawerSideRight) {
104
+                scalingModifier = -1.f;
105
+            }
106
+            
107
+            overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f);
108
+            swingingDoorTransform = overshootTransform;
109
+        }
110
+        
111
+        [sideDrawerViewController.view.layer setTransform:swingingDoorTransform];
112
+    };
113
+    return visualStateBlock;
114
+}
115
+
116
++(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor{
117
+    MMDrawerControllerDrawerVisualStateBlock visualStateBlock =
118
+    ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
119
+        NSParameterAssert(parallaxFactor >= 1.0);
120
+        CATransform3D transform = CATransform3DIdentity;
121
+        UIViewController * sideDrawerViewController;
122
+        if(drawerSide == MMDrawerSideLeft) {
123
+            sideDrawerViewController = drawerController.leftDrawerViewController;
124
+            CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth);
125
+            if (percentVisible <= 1.f) {
126
+                transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0);
127
+            }
128
+            else{
129
+                transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
130
+                transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
131
+            }
132
+        }
133
+        else if(drawerSide == MMDrawerSideRight){
134
+            sideDrawerViewController = drawerController.rightDrawerViewController;
135
+            CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth);
136
+            if(percentVisible <= 1.f){
137
+                transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0);
138
+            }
139
+            else{
140
+                transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
141
+                transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
142
+            }
143
+        }
144
+        
145
+        [sideDrawerViewController.view.layer setTransform:transform];
146
+    };
147
+    return visualStateBlock;
148
+}
149
+
150
+@end

+ 42
- 0
ios/RNNSideMenu/MMDrawerController/MMExampleDrawerVisualStateManager.h View File

@@ -0,0 +1,42 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import <Foundation/Foundation.h>
23
+#import "MMDrawerVisualState.h"
24
+
25
+typedef NS_ENUM(NSInteger, MMDrawerAnimationType){
26
+    MMDrawerAnimationTypeNone,
27
+    MMDrawerAnimationTypeSlide,
28
+    MMDrawerAnimationTypeSlideAndScale,
29
+    MMDrawerAnimationTypeSwingingDoor,
30
+    MMDrawerAnimationTypeParallax,
31
+};
32
+
33
+@interface MMExampleDrawerVisualStateManager : NSObject
34
+
35
+@property (nonatomic,assign) MMDrawerAnimationType leftDrawerAnimationType;
36
+@property (nonatomic,assign) MMDrawerAnimationType rightDrawerAnimationType;
37
+
38
++ (MMExampleDrawerVisualStateManager *)sharedManager;
39
+
40
+-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide;
41
+
42
+@end

+ 97
- 0
ios/RNNSideMenu/MMDrawerController/MMExampleDrawerVisualStateManager.m View File

@@ -0,0 +1,97 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import "MMExampleDrawerVisualStateManager.h"
23
+
24
+#import <QuartzCore/QuartzCore.h>
25
+
26
+@implementation MMExampleDrawerVisualStateManager
27
+
28
++ (MMExampleDrawerVisualStateManager *)sharedManager {
29
+    static MMExampleDrawerVisualStateManager *_sharedManager = nil;
30
+    static dispatch_once_t onceToken;
31
+    dispatch_once(&onceToken, ^{
32
+        _sharedManager = [[MMExampleDrawerVisualStateManager alloc] init];
33
+        [_sharedManager setLeftDrawerAnimationType:MMDrawerAnimationTypeParallax];
34
+        [_sharedManager setRightDrawerAnimationType:MMDrawerAnimationTypeParallax];
35
+    });
36
+    
37
+    return _sharedManager;
38
+}
39
+
40
+-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide{
41
+    MMDrawerAnimationType animationType;
42
+    if(drawerSide == MMDrawerSideLeft){
43
+        animationType = self.leftDrawerAnimationType;
44
+    }
45
+    else {
46
+        animationType = self.rightDrawerAnimationType;
47
+    }
48
+    
49
+    MMDrawerControllerDrawerVisualStateBlock visualStateBlock = nil;
50
+    switch (animationType) {
51
+        case MMDrawerAnimationTypeSlide:
52
+            visualStateBlock = [MMDrawerVisualState slideVisualStateBlock];
53
+            break;
54
+        case MMDrawerAnimationTypeSlideAndScale:
55
+            visualStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
56
+            break;
57
+        case MMDrawerAnimationTypeParallax:
58
+            visualStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
59
+            break;
60
+        case MMDrawerAnimationTypeSwingingDoor:
61
+            visualStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
62
+            break;
63
+        default:
64
+            visualStateBlock =  ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){
65
+                
66
+                UIViewController * sideDrawerViewController;
67
+                CATransform3D transform;
68
+                CGFloat maxDrawerWidth = 0;
69
+                
70
+                if(drawerSide == MMDrawerSideLeft){
71
+                    sideDrawerViewController = drawerController.leftDrawerViewController;
72
+                    maxDrawerWidth = drawerController.maximumLeftDrawerWidth;
73
+                }
74
+                else if(drawerSide == MMDrawerSideRight){
75
+                    sideDrawerViewController = drawerController.rightDrawerViewController;
76
+                    maxDrawerWidth = drawerController.maximumRightDrawerWidth;
77
+                }
78
+                
79
+                if(percentVisible > 1.0){
80
+                    transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f);
81
+                    
82
+                    if(drawerSide == MMDrawerSideLeft){
83
+                        transform = CATransform3DTranslate(transform, maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
84
+                    }else if(drawerSide == MMDrawerSideRight){
85
+                        transform = CATransform3DTranslate(transform, -maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f);
86
+                    }
87
+                }
88
+                else {
89
+                    transform = CATransform3DIdentity;
90
+                }
91
+                [sideDrawerViewController.view.layer setTransform:transform];
92
+            };
93
+            break;
94
+    }
95
+    return visualStateBlock;
96
+}
97
+@end

+ 45
- 0
ios/RNNSideMenu/MMDrawerController/UIViewController+MMDrawerController.h View File

@@ -0,0 +1,45 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+#import <UIKit/UIKit.h>
22
+
23
+#import "MMDrawerController.h"
24
+
25
+/**
26
+ A helper category on `UIViewController` that exposes the parent drawer controller, the visible side drawer frame, and a `mm_drawerWillAppear` method that is called when the drawer is about to appear.
27
+ */
28
+
29
+@interface UIViewController (MMDrawerController)
30
+
31
+///---------------------------------------
32
+/// @name Accessing Drawer View Controller Properties
33
+///---------------------------------------
34
+
35
+/**
36
+ The `MMDrawerController` that the view controller is contained within. If the view controller is not contained within a `MMDrawerController`, this property is nil. Note that if the view controller is contained within a `UINavigationController`, that navigation controller is contained within a `MMDrawerController`, this property will return a refernce to the `MMDrawerController`, despite the fact that it is not the direct parent of the view controller.
37
+ */
38
+@property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController;
39
+
40
+/**
41
+ The visible rect of the side drawer view controller in the drawer controller coordinate space. If the view controller is not a drawer in a `MMDrawerController`, then this property returns `CGRectNull`
42
+ */
43
+@property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame;
44
+
45
+@end

+ 64
- 0
ios/RNNSideMenu/MMDrawerController/UIViewController+MMDrawerController.m View File

@@ -0,0 +1,64 @@
1
+// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/)
2
+//
3
+// Permission is hereby granted, free of charge, to any person obtaining a copy
4
+// of this software and associated documentation files (the "Software"), to deal
5
+// in the Software without restriction, including without limitation the rights
6
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+// copies of the Software, and to permit persons to whom the Software is
8
+// furnished to do so, subject to the following conditions:
9
+//
10
+// The above copyright notice and this permission notice shall be included in
11
+// all copies or substantial portions of the Software.
12
+//
13
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+// THE SOFTWARE.
20
+
21
+
22
+#import "UIViewController+MMDrawerController.h"
23
+
24
+@implementation UIViewController (MMDrawerController)
25
+
26
+
27
+-(MMDrawerController*)mm_drawerController{
28
+    UIViewController *parentViewController = self.parentViewController;
29
+    while (parentViewController != nil) {
30
+        if([parentViewController isKindOfClass:[MMDrawerController class]]){
31
+            return (MMDrawerController *)parentViewController;
32
+        }
33
+        parentViewController = parentViewController.parentViewController;
34
+    }
35
+    return nil;
36
+}
37
+
38
+-(CGRect)mm_visibleDrawerFrame{
39
+    if([self isEqual:self.mm_drawerController.leftDrawerViewController] ||
40
+       [self.navigationController isEqual:self.mm_drawerController.leftDrawerViewController]){
41
+        CGRect rect = self.mm_drawerController.view.bounds;
42
+        rect.size.width = self.mm_drawerController.maximumLeftDrawerWidth;
43
+        if (self.mm_drawerController.showsStatusBarBackgroundView) {
44
+            rect.size.height -= 20.0f;
45
+        }
46
+        return rect;
47
+        
48
+    }
49
+    else if([self isEqual:self.mm_drawerController.rightDrawerViewController] ||
50
+             [self.navigationController isEqual:self.mm_drawerController.rightDrawerViewController]){
51
+        CGRect rect = self.mm_drawerController.view.bounds;
52
+        rect.size.width = self.mm_drawerController.maximumRightDrawerWidth;
53
+        rect.origin.x = CGRectGetWidth(self.mm_drawerController.view.bounds)-rect.size.width;
54
+        if (self.mm_drawerController.showsStatusBarBackgroundView) {
55
+            rect.size.height -= 20.0f;
56
+        }
57
+        return rect;
58
+    }
59
+    else {
60
+        return CGRectNull;
61
+    }
62
+}
63
+
64
+@end

+ 10
- 0
ios/RNNSideMenu/RCCDrawerController.h View File

@@ -0,0 +1,10 @@
1
+#import <UIKit/UIKit.h>
2
+#import "RCTBridge.h"
3
+#import "MMDrawerController.h"
4
+#import "RCCDrawerProtocol.h"
5
+
6
+
7
+@interface RCCDrawerController : MMDrawerController <RCCDrawerDelegate>
8
+
9
+
10
+@end

+ 154
- 0
ios/RNNSideMenu/RCCDrawerController.m View File

@@ -0,0 +1,154 @@
1
+//#import "RCCDrawerController.h"
2
+//#import "RCCViewController.h"
3
+//#import "MMExampleDrawerVisualStateManager.h"
4
+//#import "RCCDrawerHelper.h"
5
+//#import "RCTConvert.h"
6
+//#import "RCCManagerModule.h"
7
+//
8
+//#define RCCDRAWERCONTROLLER_ANIMATION_DURATION 0.33f
9
+//
10
+//
11
+//@implementation RCCDrawerController
12
+//
13
+//@synthesize drawerStyle = _drawerStyle;
14
+//
15
+//
16
+//
17
+//- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge
18
+//{
19
+//    
20
+//    self.drawerStyle = props[@"style"];
21
+//    
22
+//    // center
23
+//    if ([children count] < 1) return nil;
24
+//    UIViewController *centerViewController = [RCCViewController controllerWithLayout:children[0] globalProps:globalProps bridge:bridge];
25
+//    
26
+//    // left
27
+//    UIViewController *leftViewController = nil;
28
+//    NSString *componentLeft = props[@"componentLeft"];
29
+//    NSDictionary *passPropsLeft = props[@"passPropsLeft"];
30
+//    if (componentLeft) leftViewController = [[RCCViewController alloc] initWithComponent:componentLeft passProps:passPropsLeft navigatorStyle:nil globalProps:globalProps bridge:bridge];
31
+//    
32
+//    // right
33
+//    UIViewController *rightViewController = nil;
34
+//    NSString *componentRight = props[@"componentRight"];
35
+//    NSDictionary *passPropsRight = props[@"passPropsRight"];
36
+//    if (componentRight) rightViewController = [[RCCViewController alloc] initWithComponent:componentRight passProps:passPropsRight navigatorStyle:nil globalProps:globalProps bridge:bridge];
37
+//    
38
+//    self = [super initWithCenterViewController:centerViewController
39
+//                      leftDrawerViewController:leftViewController
40
+//                     rightDrawerViewController:rightViewController];
41
+//    
42
+//    [self setAnimationTypeWithName:props[@"animationType"]];
43
+//    
44
+//    // default is all MMOpenDrawerGestureModeAll and MMCloseDrawerGestureModeAll
45
+//    self.openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
46
+//    self.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
47
+//    
48
+//    NSNumber *disableOpenGesture = props[@"disableOpenGesture"];
49
+//    if ([disableOpenGesture boolValue]) {
50
+//        self.openDrawerGestureModeMask = MMOpenDrawerGestureModeNone;
51
+//    }
52
+//    
53
+//    [self setStyle];
54
+//    
55
+//    [self setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
56
+//        MMDrawerControllerDrawerVisualStateBlock block;
57
+//        block = [[MMExampleDrawerVisualStateManager sharedManager] drawerVisualStateBlockForDrawerSide:drawerSide];
58
+//        if (block) {
59
+//            block(drawerController, drawerSide, percentVisible);
60
+//        }
61
+//    }];
62
+//    
63
+//    [self setGestureStartBlock:^(MMDrawerController *drawerController, UIGestureRecognizer *gesture) {
64
+//        [RCCManagerModule cancelAllRCCViewControllerReactTouches];
65
+//     }];
66
+//                                               
67
+//    self.view.backgroundColor = [UIColor clearColor];
68
+//    
69
+//    if (!self) return nil;
70
+//    return self;
71
+//}
72
+//
73
+//
74
+//-(void)setStyle {
75
+//    
76
+//    if (self.drawerStyle[@"drawerShadow"]) {
77
+//        self.showsShadow = ([self.drawerStyle[@"drawerShadow"] boolValue]) ? YES : NO;
78
+//    }
79
+//    
80
+//    NSNumber *leftDrawerWidth = self.drawerStyle[@"leftDrawerWidth"];
81
+//    if (leftDrawerWidth) {
82
+//        self.maximumLeftDrawerWidth = self.view.bounds.size.width * MIN(1, (leftDrawerWidth.floatValue/100.0));
83
+//    }
84
+//    
85
+//    NSNumber *rightDrawerWidth = self.drawerStyle[@"rightDrawerWidth"];
86
+//    if (rightDrawerWidth) {
87
+//        self.maximumRightDrawerWidth = self.view.bounds.size.width * MIN(1, (rightDrawerWidth.floatValue/100.0));
88
+//    }
89
+//    
90
+//    NSString *contentOverlayColor = self.drawerStyle[@"contentOverlayColor"];
91
+//    if (contentOverlayColor)
92
+//    {
93
+//        UIColor *color = contentOverlayColor != (id)[NSNull null] ? [RCTConvert UIColor:contentOverlayColor] : nil;
94
+//        [self setCenterOverlayColor:color];
95
+//    }
96
+//}
97
+//
98
+//
99
+//- (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge
100
+//{
101
+//    MMDrawerSide side = MMDrawerSideLeft;
102
+//    if ([actionParams[@"side"] isEqualToString:@"right"]) side = MMDrawerSideRight;
103
+//    BOOL animated = actionParams[@"animated"] ? [actionParams[@"animated"] boolValue] : YES;
104
+//    
105
+//    // open
106
+//    if ([performAction isEqualToString:@"open"])
107
+//    {
108
+//        [self openDrawerSide:side animated:animated completion:nil];
109
+//        return;
110
+//    }
111
+//    
112
+//    // close
113
+//    if ([performAction isEqualToString:@"close"])
114
+//    {
115
+//        if (self.openSide == side) {
116
+//            [self closeDrawerAnimated:animated completion:nil];
117
+//        }
118
+//        
119
+//        return;
120
+//    }
121
+//    
122
+//    // toggle
123
+//    if ([performAction isEqualToString:@"toggle"])
124
+//    {
125
+//        [super toggleDrawerSide:side animated:animated completion:nil];
126
+//        return;
127
+//    }
128
+//    
129
+//    // setStyle
130
+//    if ([performAction isEqualToString:@"setStyle"])
131
+//    {
132
+//        if (actionParams[@"animationType"]) {
133
+//            NSString *animationTypeString = actionParams[@"animationType"];
134
+//            [self setAnimationTypeWithName:animationTypeString];
135
+//        }
136
+//        return;
137
+//    }
138
+//    
139
+//}
140
+//
141
+//-(void)setAnimationTypeWithName:(NSString*)animationTypeName {
142
+//    MMDrawerAnimationType animationType = MMDrawerAnimationTypeNone;
143
+//    
144
+//    if ([animationTypeName isEqualToString:@"door"]) animationType = MMDrawerAnimationTypeSwingingDoor;
145
+//    else if ([animationTypeName isEqualToString:@"parallax"]) animationType = MMDrawerAnimationTypeParallax;
146
+//    else if ([animationTypeName isEqualToString:@"slide"]) animationType = MMDrawerAnimationTypeSlide;
147
+//    else if ([animationTypeName isEqualToString:@"slide-and-scale"]) animationType = MMDrawerAnimationTypeSlideAndScale;
148
+//    
149
+//    [MMExampleDrawerVisualStateManager sharedManager].leftDrawerAnimationType = animationType;
150
+//    [MMExampleDrawerVisualStateManager sharedManager].rightDrawerAnimationType = animationType;
151
+//}
152
+//
153
+//
154
+//@end

+ 35
- 0
ios/RNNSideMenu/RCCDrawerHelper.h View File

@@ -0,0 +1,35 @@
1
+//
2
+//  RCCDrawerHelper.h
3
+//  ReactNativeControllers
4
+//
5
+//  Created by Ran Greenberg on 07/04/2016.
6
+//  Copyright © 2016 artal. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+#import <UIKit/UIKit.h>
11
+
12
+#define DRAWER_DEFAULT_WIDTH_PERCENTAGE 80
13
+
14
+typedef NS_ENUM(NSInteger,RCCDrawerSide){
15
+    RCCDrawerSideLeft,
16
+    RCCDrawerSideRight
17
+};
18
+
19
+
20
+@interface RCCDrawerHelper : NSObject
21
+
22
++(UIButton*)createOverlayButton:(id)target;
23
+
24
++(void)addOverlayButtonToScreen:(UIButton*)buttonToAdd
25
+                    contextView:(UIView*)view
26
+                           side:(RCCDrawerSide)side
27
+                  sideMenuWidth:(CGFloat)sideMenuWidth
28
+              animationDuration:(CGFloat)duration;
29
+
30
++(void)overlayButtonPressed:(UIButton*)button animationDuration:(CGFloat)duration;
31
++(UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize;
32
+
33
+
34
+
35
+@end

+ 96
- 0
ios/RNNSideMenu/RCCDrawerHelper.m View File

@@ -0,0 +1,96 @@
1
+////
2
+////  RCCDrawerHelper.m
3
+////  ReactNativeControllers
4
+////
5
+////  Created by Ran Greenberg on 07/04/2016.
6
+////  Copyright © 2016 artal. All rights reserved.
7
+////
8
+//
9
+//#import "RCCDrawerHelper.h"
10
+//
11
+//@implementation RCCDrawerHelper
12
+//
13
+//static CGFloat _sideMenuWidth;
14
+//
15
+//+(UIButton*)createOverlayButton:(id)target {
16
+//    UIButton *overlayButton = [[UIButton alloc] init];
17
+//    overlayButton.backgroundColor = [UIColor clearColor];
18
+//    [overlayButton addTarget:target action:@selector(overlayButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
19
+//    
20
+//    return overlayButton;
21
+//}
22
+//
23
+//
24
+//+(void)addOverlayButtonToScreen:(UIButton*)buttonToAdd
25
+//                    contextView:(UIView*)view
26
+//                           side:(RCCDrawerSide)side
27
+//                  sideMenuWidth:(CGFloat)sideMenuWidth
28
+//              animationDuration:(CGFloat)duration {
29
+//    
30
+//    _sideMenuWidth = sideMenuWidth;
31
+//    
32
+//    CGRect buttonFrame = view.bounds;
33
+//    
34
+//    buttonFrame.origin.x = [RCCDrawerHelper overlayButtonX:sideMenuWidth side:side];
35
+//    
36
+//    switch (side) {
37
+//        case RCCDrawerSideLeft:
38
+//        {
39
+//            buttonFrame.origin.x = sideMenuWidth;
40
+//        }
41
+//            
42
+//            break;
43
+//        case RCCDrawerSideRight:
44
+//        {
45
+//            buttonFrame.origin.x = 0;
46
+//        }
47
+//            
48
+//            break;
49
+//            
50
+//        default:
51
+//            break;
52
+//    }
53
+//    
54
+//    buttonFrame.size.width = buttonFrame.size.width - sideMenuWidth;
55
+//    buttonToAdd.frame = buttonFrame;
56
+//    [view addSubview:buttonToAdd];
57
+//}
58
+//
59
+//+(void)overlayButtonPressed:(UIButton*)button animationDuration:(CGFloat)duration {
60
+//    [button removeFromSuperview];
61
+//}
62
+//
63
+//
64
+//+(CGFloat)overlayButtonX:(CGFloat)sideMenuWidth side:(RCCDrawerSide)side {
65
+//    switch (side) {
66
+//        case RCCDrawerSideLeft:
67
+//        {
68
+//            return sideMenuWidth;
69
+//        }
70
+//            
71
+//            break;
72
+//        case RCCDrawerSideRight:
73
+//        {
74
+//            return 0;
75
+//        }
76
+//            
77
+//            break;
78
+//            
79
+//        default:
80
+//            break;
81
+//    }
82
+//}
83
+//
84
+//
85
+//+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)newSize {
86
+//    //UIGraphicsBeginImageContext(newSize);
87
+//    // In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution).
88
+//    // Pass 1.0 to force exact pixel size.
89
+//    UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
90
+//    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
91
+//    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
92
+//    UIGraphicsEndImageContext();
93
+//    return newImage;
94
+//}
95
+//
96
+//@end

+ 24
- 0
ios/RNNSideMenu/RCCDrawerProtocol.h View File

@@ -0,0 +1,24 @@
1
+//
2
+//  RCCDrawerProtocol.h
3
+//  ReactNativeControllers
4
+//
5
+//  Created by Ran Greenberg on 23/03/2016.
6
+//  Copyright © 2016 artal. All rights reserved.
7
+//
8
+
9
+
10
+
11
+@class RCTBridge;
12
+
13
+
14
+@protocol RCCDrawerDelegate <NSObject>
15
+
16
+@property (nonatomic, strong) UIButton *overlayButton;
17
+@property (nonatomic, strong) NSDictionary *drawerStyle;
18
+
19
+@required
20
+- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge;
21
+- (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge;
22
+
23
+@end
24
+

+ 22
- 0
ios/RNNSideMenu/RCCTheSideBarManagerViewController.h View File

@@ -0,0 +1,22 @@
1
+//
2
+//  DarwerTheSideBarManagerViewController.h
3
+//  ReactNativeControllers
4
+//
5
+//  Created by Ran Greenberg on 22/03/2016.
6
+//  Copyright © 2016 artal. All rights reserved.
7
+//
8
+
9
+#import "TheSidebarController.h"
10
+#import "RCCDrawerProtocol.h"
11
+
12
+typedef NS_ENUM(NSInteger,TheSideBarSide){
13
+    TheSideBarSideNone = 0,
14
+    TheSideBarSideLeft,
15
+    TheSideBarSideRight,
16
+};
17
+
18
+
19
+@interface RCCTheSideBarManagerViewController : TheSidebarController <RCCDrawerDelegate>
20
+
21
+
22
+@end

+ 258
- 0
ios/RNNSideMenu/RCCTheSideBarManagerViewController.m View File

@@ -0,0 +1,258 @@
1
+////
2
+////  DarwerTheSideBarManagerViewController.m
3
+////  ReactNativeControllers
4
+////
5
+////  Created by Ran Greenberg on 22/03/2016.
6
+////  Copyright © 2016 artal. All rights reserved.
7
+////
8
+//
9
+//#import "RCCTheSideBarManagerViewController.h"
10
+//#import "RCCViewController.h"
11
+//#import "RCCDrawerHelper.h"
12
+//#import "RCTConvert.h"
13
+//
14
+//
15
+//@interface RCCTheSideBarManagerViewController () <TheSidebarControllerDelegate>
16
+//
17
+//@property (nonatomic) BOOL isOpen;
18
+//
19
+//@property (nonatomic) SidebarTransitionStyle animationStyle;
20
+//
21
+//@property (nonatomic, strong) RCCViewController *leftViewController;
22
+//@property (nonatomic, strong) RCCViewController *rightViewController;
23
+//@property (nonatomic, strong) RCCViewController *centerViewController;
24
+//
25
+//
26
+//@property (nonatomic, strong) UIColor *originalWindowBackgroundColor;
27
+//
28
+//@end
29
+//
30
+//@implementation RCCTheSideBarManagerViewController
31
+//
32
+//@synthesize overlayButton = _overlayButton, drawerStyle = _drawerStyle;
33
+//
34
+//
35
+//-(UIButton*)overlayButton {
36
+//    if (!_overlayButton) {
37
+//        _overlayButton = [RCCDrawerHelper createOverlayButton:self];
38
+//    }
39
+//    return _overlayButton;
40
+//}
41
+//
42
+//- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge {
43
+//    
44
+//    if ([children count] < 1) return nil;
45
+//    
46
+//    UIViewController *centerVC = [RCCViewController controllerWithLayout:children[0] globalProps:props bridge:bridge];
47
+//    UIViewController *leftVC = nil;
48
+//    UIViewController *rightVC = nil;
49
+//    
50
+//    // left
51
+//    NSString *componentLeft = props[@"componentLeft"];
52
+//    if (componentLeft)  {
53
+//        leftVC = [[RCCViewController alloc] initWithComponent:componentLeft passProps:props[@"passPropsLeft"] navigatorStyle:nil globalProps:props bridge:bridge];
54
+//    }
55
+//    
56
+//    // right
57
+//    NSString *componentRight = props[@"componentRight"];
58
+//    if (componentRight) {
59
+//        rightVC = [[RCCViewController alloc] initWithComponent:componentRight passProps:props[@"passPropsRight"] navigatorStyle:nil globalProps:props bridge:bridge];
60
+//    }
61
+//    
62
+//    self = [super initWithContentViewController:centerVC
63
+//                      leftSidebarViewController:leftVC
64
+//                     rightSidebarViewController:rightVC];
65
+//    if (!self) return nil;
66
+//    
67
+//    self.leftViewController = leftVC;
68
+//    self.rightViewController = rightVC;
69
+//    self.centerViewController = centerVC;
70
+//    self.drawerStyle = props[@"style"];
71
+//    self.delegate = self;
72
+//    self.isOpen = NO;
73
+//    [self setAnimationType:props[@"animationType"]];
74
+//    [self setStyle];
75
+//    
76
+//    return self;
77
+//}
78
+//
79
+//
80
+//-(void)viewDidDisappear:(BOOL)animated {
81
+//    [super viewDidDisappear:animated];
82
+//    
83
+//    UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
84
+//    [appDelegateWindow setBackgroundColor:self.originalWindowBackgroundColor];
85
+//    
86
+//}
87
+//
88
+//
89
+//-(void)setStyle:(TheSideBarSide)side {
90
+//    
91
+//    if(side == TheSideBarSideLeft && !self.leftViewController) return;
92
+//    if(side == TheSideBarSideRight && !self.rightViewController) return;
93
+//    
94
+//    CGRect sideBarFrame = self.view.frame;
95
+//    
96
+//    switch (side) {
97
+//        case TheSideBarSideLeft:
98
+//        {
99
+//            NSNumber *leftDrawerWidth = self.drawerStyle[@"leftDrawerWidth"];
100
+//            if (!leftDrawerWidth) leftDrawerWidth = [NSNumber numberWithInteger:DRAWER_DEFAULT_WIDTH_PERCENTAGE];
101
+//            
102
+//            self.visibleWidth = self.view.bounds.size.width * MIN(1, (leftDrawerWidth.floatValue/100.0));
103
+//            sideBarFrame.size.width = self.view.bounds.size.width * MIN(1, (leftDrawerWidth.floatValue/100.0));
104
+//            self.leftViewController.view.frame = sideBarFrame;
105
+//        }
106
+//            break;
107
+//            
108
+//        case TheSideBarSideRight:
109
+//        {
110
+//            NSNumber *rightDrawerWidth = self.drawerStyle[@"rightDrawerWidth"];
111
+//            if (!rightDrawerWidth) rightDrawerWidth = [NSNumber numberWithInteger:DRAWER_DEFAULT_WIDTH_PERCENTAGE];
112
+//            
113
+//            self.visibleWidth = self.view.bounds.size.width * MIN(1, (rightDrawerWidth.floatValue/100.0));
114
+//            sideBarFrame.size.width = self.view.bounds.size.width * MIN(1, (rightDrawerWidth.floatValue/100.0));
115
+//            sideBarFrame.origin.x = self.view.frame.size.width - self.visibleWidth;
116
+//            self.rightViewController.view.frame = sideBarFrame;
117
+//        }
118
+//            break;
119
+//            
120
+//        default:
121
+//            break;
122
+//    }
123
+//}
124
+//
125
+//
126
+//-(void)setStyle {
127
+//    
128
+//    [self setStyle:TheSideBarSideLeft];
129
+//    [self setStyle:TheSideBarSideRight];
130
+//    
131
+//    NSString *contentOverlayColor = self.drawerStyle[@"contentOverlayColor"];
132
+//    if (contentOverlayColor)
133
+//    {
134
+//        UIColor *color = contentOverlayColor != (id)[NSNull null] ? [RCTConvert UIColor:contentOverlayColor] : nil;
135
+//        self.overlayContentColor = color;
136
+//    }
137
+//    
138
+//    UIImage *backgroundImage = nil;
139
+//    id icon = self.drawerStyle[@"backgroundImage"];
140
+//    UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
141
+//    self.originalWindowBackgroundColor = appDelegateWindow.backgroundColor;
142
+//    
143
+//    if (icon)
144
+//    {
145
+//        backgroundImage = [RCTConvert UIImage:icon];
146
+//        if (backgroundImage) {
147
+//            backgroundImage = [RCCDrawerHelper imageWithImage:backgroundImage scaledToSize:appDelegateWindow.bounds.size];
148
+//            [appDelegateWindow setBackgroundColor:[UIColor colorWithPatternImage:backgroundImage]];
149
+//        }
150
+//    }
151
+//}
152
+//
153
+//
154
+//-(void)setAnimationType:(NSString*)type {
155
+//    if ([type isEqualToString:@"airbnb"]) self.animationStyle = SidebarTransitionStyleAirbnb;
156
+//    else if ([type isEqualToString:@"facebook"]) self.animationStyle = SidebarTransitionStyleFacebook;
157
+//    else if ([type isEqualToString:@"luvocracy"]) self.animationStyle = SidebarTransitionStyleLuvocracy;
158
+//    else if ([type isEqualToString:@"wunder-list"]) self.animationStyle = SidebarTransitionStyleWunderlist;
159
+//    
160
+//    //    currently unsuported animation types
161
+//    //    else if ([type isEqualToString:@"feedly"]) self.animationStyle = SidebarTransitionStyleFeedly;
162
+//    //    else if ([type isEqualToString:@"flipboard"]) self.animationStyle = SidebarTransitionStyleFlipboard;
163
+//    
164
+//    
165
+//    // default
166
+//    else self.animationStyle = SidebarTransitionStyleAirbnb;
167
+//}
168
+//
169
+//- (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge {
170
+//    
171
+//    TheSideBarSide side = TheSideBarSideLeft;
172
+//    
173
+//    if ([actionParams[@"side"] isEqualToString:@"right"]) side = TheSideBarSideRight;
174
+//    
175
+//    // open
176
+//    if ([performAction isEqualToString:@"open"])
177
+//    {
178
+//        [self openSideMenu:side];
179
+//        return;
180
+//    }
181
+//    
182
+//    // close
183
+//    if ([performAction isEqualToString:@"close"])
184
+//    {
185
+//        [self overlayButtonPressed:self.overlayButton];
186
+//        return;
187
+//    }
188
+//    
189
+//    // toggle
190
+//    if ([performAction isEqualToString:@"toggle"])
191
+//    {
192
+//        [self setStyle:side];
193
+//        if (self.isOpen) {
194
+//            [self overlayButtonPressed:self.overlayButton];
195
+//        }
196
+//        else {
197
+//            [self openSideMenu:side];
198
+//        }
199
+//        self.isOpen = !self.isOpen;
200
+//        return;
201
+//    }
202
+//    
203
+//    // setStyle
204
+//    if ([performAction isEqualToString:@"setStyle"])
205
+//    {
206
+//        if (actionParams[@"animationType"]) {
207
+//            NSString *animationTypeString = actionParams[@"animationType"];
208
+//            
209
+//            CGRect leftSideBarFrame = self.leftViewController.view.frame;
210
+//            leftSideBarFrame.origin.x = 0;
211
+//            self.leftViewController.view.frame = leftSideBarFrame;
212
+//            
213
+//            CGRect rightSideBarFrame = self.rightViewController.view.frame;
214
+//            rightSideBarFrame.origin.x = self.view.frame.size.width - self.visibleWidth;
215
+//            self.rightViewController.view.frame = rightSideBarFrame;
216
+//            
217
+//            [self setAnimationType:animationTypeString];
218
+//        }
219
+//        return;
220
+//    }
221
+//}
222
+//
223
+//
224
+//-(void)openSideMenu:(TheSideBarSide)side{
225
+//    
226
+//    RCCDrawerSide drawerSide;
227
+//    
228
+//    switch (side) {
229
+//        case TheSideBarSideLeft:
230
+//        {
231
+//            [self presentLeftSidebarViewControllerWithStyle:self.animationStyle];
232
+//            drawerSide = RCCDrawerSideLeft;
233
+//        }
234
+//            
235
+//            break;
236
+//        case TheSideBarSideRight:
237
+//        {
238
+//            [self presentRightSidebarViewControllerWithStyle:self.animationStyle];
239
+//            drawerSide = RCCDrawerSideRight;
240
+//        }
241
+//            
242
+//            break;
243
+//            
244
+//        default:
245
+//            break;
246
+//    }
247
+//    
248
+//    [RCCDrawerHelper addOverlayButtonToScreen:self.overlayButton contextView:self.view side:drawerSide sideMenuWidth:self.visibleWidth animationDuration:self.animationDuration];
249
+//}
250
+//
251
+//-(void)overlayButtonPressed:(UIButton*)button {
252
+//    [self dismissSidebarViewController];
253
+//    [RCCDrawerHelper overlayButtonPressed:button animationDuration:self.animationDuration];
254
+//    self.isOpen = NO;
255
+//}
256
+//
257
+//
258
+//@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarAirbnbAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarAirbnbAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarAirbnbAnimation : SidebarAnimation
27
+
28
+@end

+ 135
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarAirbnbAnimation.m View File

@@ -0,0 +1,135 @@
1
+// SidebarAirbnbAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarAirbnbAnimation.h"
26
+
27
+@implementation SidebarAirbnbAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+    
35
+    // Animation settings for content view
36
+    CATransform3D contentTransform = CATransform3DIdentity;
37
+    contentTransform.m34 = -1.0f / 800.0f;
38
+    contentView.layer.zPosition = 100;
39
+    
40
+    // Animation settings for menu view
41
+    CATransform3D sidebarTransform = CATransform3DIdentity;
42
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
43
+    sidebarView.layer.transform = sidebarTransform;
44
+    
45
+    sidebarTransform = CATransform3DIdentity;
46
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
47
+    
48
+    if(side == LeftSide)
49
+    {
50
+        contentTransform = CATransform3DTranslate(contentTransform, visibleWidth - (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
51
+        contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
52
+        contentTransform = CATransform3DRotate(contentTransform, DEG2RAD(-45), 0.0, 1.0, 0.0);
53
+    }
54
+    else
55
+    {
56
+        contentTransform = CATransform3DTranslate(contentTransform, 0 - visibleWidth + (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
57
+        contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
58
+        contentTransform = CATransform3DRotate(contentTransform, DEG2RAD(45), 0.0, 1.0, 0.0);
59
+    }
60
+    
61
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
62
+    [contentView addSubview:overlayContentView];
63
+    
64
+    
65
+    
66
+    // Animate content view
67
+    [UIView animateWithDuration:animationDuration
68
+                          delay:0.0
69
+                        options:UIViewAnimationOptionCurveEaseInOut
70
+                     animations:^{
71
+                         contentView.layer.transform = contentTransform;
72
+                         overlayContentView.backgroundColor = [self overlayContentColor];
73
+                         
74
+                     }
75
+                     completion:^(BOOL finished) {
76
+                         completion(finished);
77
+                     }];
78
+    
79
+    // Animate menu view
80
+    [UIView animateWithDuration:animationDuration
81
+                          delay:0.0
82
+                        options:UIViewAnimationOptionCurveEaseInOut
83
+                     animations:^{
84
+                         sidebarView.layer.transform = sidebarTransform;
85
+                     }
86
+                     completion:nil];
87
+}
88
+
89
+
90
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
91
+{
92
+    // Animation settings for content view
93
+    CATransform3D contentTransform = CATransform3DIdentity;
94
+    contentTransform.m34 = -1.0f / 800.0f;
95
+    contentView.layer.zPosition = 100;
96
+    contentTransform = CATransform3DTranslate(contentTransform, 0.0, 0.0, 0.0);
97
+    contentTransform = CATransform3DScale(contentTransform, 1.0, 1.0, 1.0);
98
+    contentTransform = CATransform3DRotate(contentTransform, DEG2RAD(0), 0.0, 1.0, 0.0);
99
+    
100
+    // Animation settings for menu view
101
+    __block CATransform3D sidebarTransform = CATransform3DIdentity;
102
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
103
+    
104
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
105
+    [contentView addSubview:overlayContentView];
106
+    
107
+    
108
+    // Animate content view
109
+    [UIView animateWithDuration:animationDuration
110
+                          delay:0.0
111
+                        options:UIViewAnimationOptionCurveEaseInOut
112
+                     animations:^{
113
+                         contentView.layer.transform = contentTransform;
114
+                         overlayContentView.backgroundColor = [UIColor clearColor];
115
+                     }
116
+                     completion:^(BOOL finished) {
117
+                         completion(finished);
118
+                     }];
119
+    
120
+    // Animate menu view
121
+    [UIView animateWithDuration:animationDuration
122
+                          delay:0.0
123
+                        options:UIViewAnimationOptionCurveEaseInOut
124
+                     animations:^{
125
+                         sidebarView.layer.transform = sidebarTransform;
126
+                     }
127
+                     completion:^(BOOL finished) {
128
+                         sidebarTransform = CATransform3DIdentity;
129
+                         sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
130
+                         sidebarView.layer.transform = sidebarTransform;
131
+                         [overlayContentView removeFromSuperview];
132
+                     }];
133
+}
134
+
135
+@end

+ 80
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarAnimation.h View File

@@ -0,0 +1,80 @@
1
+// SidebarAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import <Foundation/Foundation.h>
25
+#import <QuartzCore/QuartzCore.h>
26
+#import <UIKit/UIKit.h>
27
+
28
+#define DEG2RAD(degrees) (degrees * M_PI / 180)
29
+#define SIDEBAR_ANIMATIONS \
30
+    @"SidebarFacebookAnimation", \
31
+    @"SidebarAirbnbAnimation", \
32
+    @"SidebarLuvocracyAnimation", \
33
+    @"SidebarFeedlyAnimation", \
34
+    @"SidebarFlipboardAnimation", \
35
+    @"SidebarWunderlistAnimation"
36
+
37
+
38
+typedef NS_ENUM(NSInteger, SidebarTransitionStyle)
39
+{
40
+    SidebarTransitionStyleFacebook,
41
+    SidebarTransitionStyleAirbnb,
42
+    SidebarTransitionStyleLuvocracy,
43
+    SidebarTransitionStyleFeedly,
44
+    SidebarTransitionStyleFlipboard,
45
+    SidebarTransitionStyleWunderlist
46
+};
47
+
48
+typedef NS_ENUM(NSInteger, Side)
49
+{
50
+    LeftSide,
51
+    RightSide,
52
+};
53
+
54
+
55
+@class SidebarAnimation;
56
+@interface SidebarAnimation : NSObject
57
+
58
++ (void)animateContentView:(UIView *)contentView
59
+               sidebarView:(UIView *)sidebarView
60
+                  fromSide:(Side)side
61
+              visibleWidth:(CGFloat)visibleWidth
62
+                  duration:(NSTimeInterval)animationDuration
63
+                completion:(void (^)(BOOL finished))completion;
64
+
65
++ (void)reverseAnimateContentView:(UIView *)contentView
66
+                      sidebarView:(UIView *)sidebarView
67
+                         fromSide:(Side)side
68
+                     visibleWidth:(CGFloat)visibleWidth
69
+                         duration:(NSTimeInterval)animationDuration
70
+                       completion:(void (^)(BOOL finished))completion;
71
+
72
++ (void)resetSidebarPosition:(UIView *)sidebarView;
73
++ (void)resetContentPosition:(UIView *)contentView;
74
+
75
++(UIView*)overlayContentView:(CGRect)frame;
76
+
77
++(void)setOverlayContentColor:(UIColor*)color;
78
++(UIColor*)overlayContentColor;
79
+
80
+@end

+ 101
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarAnimation.m View File

@@ -0,0 +1,101 @@
1
+// SidebarAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarAnimation.h"
26
+
27
+
28
+
29
+@implementation SidebarAnimation
30
+
31
+static UIColor *overlayContentColor;
32
+
33
++(void)setOverlayContentColor:(UIColor*)color {
34
+    overlayContentColor = color;
35
+}
36
+
37
++(UIColor*)overlayContentColor {
38
+    return overlayContentColor;
39
+}
40
+
41
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
42
+{
43
+    
44
+}
45
+
46
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
47
+{
48
+    
49
+}
50
+
51
++ (void)resetSidebarPosition:(UIView *)sidebarView
52
+{
53
+    CATransform3D resetTransform = CATransform3DIdentity;
54
+    resetTransform = CATransform3DRotate(resetTransform, DEG2RAD(0), 1, 1, 1);
55
+    resetTransform = CATransform3DScale(resetTransform, 1.0, 1.0, 1.0);
56
+    resetTransform = CATransform3DTranslate(resetTransform, 0.0, 0.0, 0.0);
57
+    sidebarView.layer.transform = resetTransform;
58
+    
59
+    CGRect resetFrame = sidebarView.frame;
60
+    resetFrame.origin.x = 0;
61
+    resetFrame.origin.y = 0;
62
+    sidebarView.frame = resetFrame;
63
+    
64
+    [sidebarView.superview sendSubviewToBack:sidebarView];
65
+    sidebarView.layer.zPosition = 0;
66
+}
67
+
68
++ (void)resetContentPosition:(UIView *)contentView
69
+{
70
+    CATransform3D resetTransform = CATransform3DIdentity;
71
+    resetTransform = CATransform3DRotate(resetTransform, DEG2RAD(0), 1, 1, 1);
72
+    resetTransform = CATransform3DScale(resetTransform, 1.0, 1.0, 1.0);
73
+    resetTransform = CATransform3DTranslate(resetTransform, 0.0, 0.0, 0.0);
74
+    contentView.layer.transform = resetTransform;
75
+    
76
+    CGRect resetFrame = contentView.frame;
77
+    resetFrame.origin.x = 0;
78
+    resetFrame.origin.y = 0;
79
+    contentView.frame = resetFrame;
80
+    
81
+    [contentView.superview bringSubviewToFront:contentView];
82
+    contentView.layer.zPosition = 0;
83
+}
84
+
85
+
86
++(UIView*)overlayContentView:(CGRect)frame {
87
+    
88
+    static UIView *overlayView;
89
+    static dispatch_once_t onceToken;
90
+    
91
+    dispatch_once(&onceToken, ^{
92
+        overlayView = [[UIView alloc] initWithFrame:frame];
93
+        overlayView.backgroundColor = [UIColor clearColor];
94
+        overlayView.userInteractionEnabled = NO;
95
+    });
96
+    
97
+    return overlayView;
98
+}
99
+
100
+
101
+@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFacebookAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarFacebookAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarFacebookAnimation : SidebarAnimation
27
+
28
+@end

+ 83
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFacebookAnimation.m View File

@@ -0,0 +1,83 @@
1
+// SidebarFacebookAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarFacebookAnimation.h"
26
+
27
+@implementation SidebarFacebookAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+    
35
+    CGRect contentFrame = contentView.frame;
36
+    
37
+    if(side == LeftSide)
38
+    {
39
+        contentFrame.origin.x += visibleWidth;
40
+    }
41
+    else
42
+    {
43
+        contentFrame.origin.x -= visibleWidth;
44
+    }
45
+    
46
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
47
+    [contentView addSubview:overlayContentView];
48
+    
49
+    [UIView animateWithDuration:animationDuration
50
+                          delay:0.0
51
+                        options:UIViewAnimationOptionCurveEaseInOut
52
+                     animations:^{
53
+                         contentView.frame = contentFrame;
54
+                         overlayContentView.backgroundColor = [self overlayContentColor];
55
+                     }
56
+                     completion:^(BOOL finished) {
57
+                         completion(finished);
58
+                     }];
59
+}
60
+
61
+
62
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
63
+{
64
+    CGRect contentFrame = contentView.frame;
65
+    contentFrame.origin.x = 0;
66
+    
67
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
68
+    [contentView addSubview:overlayContentView];
69
+    
70
+    [UIView animateWithDuration:animationDuration
71
+                          delay:0.0
72
+                        options:UIViewAnimationOptionCurveEaseInOut
73
+                     animations:^{
74
+                         contentView.frame = contentFrame;
75
+                         overlayContentView.backgroundColor = [UIColor clearColor];
76
+                     }
77
+                     completion:^(BOOL finished) {
78
+                         completion(finished);
79
+                         [overlayContentView removeFromSuperview];
80
+                     }];
81
+}
82
+
83
+@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFeedlyAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarFeedlyAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarFeedlyAnimation : SidebarAnimation
27
+
28
+@end

+ 89
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFeedlyAnimation.m View File

@@ -0,0 +1,89 @@
1
+// SidebarFeedlyAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarFeedlyAnimation.h"
26
+
27
+@implementation SidebarFeedlyAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+        
35
+    CGRect sidebarFrame = sidebarView.frame;
36
+    [sidebarView.superview bringSubviewToFront:sidebarView];
37
+    
38
+    if(side == LeftSide)
39
+    {
40
+        sidebarFrame.origin.x = -sidebarFrame.size.width;
41
+        sidebarView.frame = sidebarFrame;
42
+        sidebarFrame.origin.x += visibleWidth;
43
+    }
44
+    else
45
+    {
46
+        sidebarFrame.origin.x = sidebarFrame.size.width;
47
+        sidebarView.frame = sidebarFrame;
48
+        sidebarFrame.origin.x -= visibleWidth;
49
+    }
50
+    
51
+    [UIView animateWithDuration:animationDuration
52
+                          delay:0.0
53
+                        options:UIViewAnimationOptionCurveEaseInOut
54
+                     animations:^{
55
+                         sidebarView.frame = sidebarFrame;
56
+                         contentView.alpha = 0.3;
57
+                     }
58
+                     completion:^(BOOL finished) {
59
+                         completion(finished);
60
+                     }];
61
+}
62
+
63
+
64
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
65
+{
66
+    CGRect sidebarFrame = sidebarView.frame;
67
+    
68
+    if(side == LeftSide)
69
+    {
70
+        sidebarFrame.origin.x -= visibleWidth;
71
+    }
72
+    else
73
+    {
74
+        sidebarFrame.origin.x += visibleWidth;
75
+    }
76
+    
77
+    [UIView animateWithDuration:animationDuration
78
+                          delay:0.0
79
+                        options:UIViewAnimationOptionCurveEaseInOut
80
+                     animations:^{
81
+                         sidebarView.frame = sidebarFrame;
82
+                         contentView.alpha = 1;
83
+                     }
84
+                     completion:^(BOOL finished) {
85
+                         completion(finished);
86
+                     }];
87
+}
88
+
89
+@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFlipboardAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarFlipboardAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarFlipboardAnimation : SidebarAnimation
27
+
28
+@end

+ 99
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarFlipboardAnimation.m View File

@@ -0,0 +1,99 @@
1
+// SidebarFlipboardAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarFlipboardAnimation.h"
26
+
27
+@implementation SidebarFlipboardAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+    
35
+    CGRect sidebarFrame = sidebarView.frame;
36
+    [sidebarView.superview bringSubviewToFront:sidebarView];
37
+    
38
+    CATransform3D contentTransform = CATransform3DIdentity;
39
+    contentTransform = CATransform3DScale(contentTransform, 0.9, 0.9, 0.9);
40
+    
41
+    if(side == LeftSide)
42
+    {
43
+        sidebarFrame.origin.x = -sidebarFrame.size.width;
44
+        sidebarView.frame = sidebarFrame;
45
+        sidebarFrame.origin.x += visibleWidth;
46
+    }
47
+    else
48
+    {
49
+        sidebarFrame.origin.x = sidebarFrame.size.width;
50
+        sidebarView.frame = sidebarFrame;
51
+        sidebarFrame.origin.x -= visibleWidth;
52
+    }
53
+    
54
+    [UIView animateWithDuration:animationDuration
55
+                          delay:0.0
56
+                        options:UIViewAnimationOptionCurveEaseInOut
57
+                     animations:^{
58
+                         sidebarView.frame = sidebarFrame;
59
+                         contentView.alpha = 0.3;
60
+                         contentView.layer.transform = contentTransform;
61
+                     }
62
+                     completion:^(BOOL finished) {
63
+                         completion(finished);
64
+                     }];
65
+    
66
+    
67
+    
68
+}
69
+
70
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
71
+{
72
+    CGRect sidebarFrame = sidebarView.frame;
73
+    CATransform3D contentTransform = CATransform3DIdentity;
74
+    contentTransform = CATransform3DScale(contentTransform, 1.0, 1.0, 1.0);
75
+    
76
+    if(side == LeftSide)
77
+    {
78
+        sidebarFrame.origin.x -= visibleWidth;
79
+    }
80
+    else
81
+    {
82
+        sidebarFrame.origin.x += visibleWidth;
83
+    }
84
+    
85
+    [UIView animateWithDuration:animationDuration
86
+                          delay:0.0
87
+                        options:UIViewAnimationOptionCurveEaseInOut
88
+                     animations:^{
89
+                         sidebarView.frame = sidebarFrame;
90
+                         contentView.alpha = 1;
91
+                         contentView.layer.transform = contentTransform;
92
+                     }
93
+                     completion:^(BOOL finished) {
94
+                         completion(finished);
95
+                     }];
96
+}
97
+
98
+
99
+@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarLuvocracyAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarLuvocracyAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarLuvocracyAnimation : SidebarAnimation
27
+
28
+@end

+ 111
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarLuvocracyAnimation.m View File

@@ -0,0 +1,111 @@
1
+// SidebarLuvocracyAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarLuvocracyAnimation.h"
26
+
27
+@implementation SidebarLuvocracyAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+    // Animation settings for content view
35
+    CATransform3D contentTransform = CATransform3DIdentity;
36
+    contentTransform.m34 = -1.0f / 800.0f;
37
+    contentView.layer.zPosition = 100;
38
+    
39
+    // Animation settings for sidebar view
40
+    CATransform3D sidebarTransform = CATransform3DIdentity;
41
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
42
+    sidebarView.layer.transform = sidebarTransform;
43
+    
44
+    sidebarTransform = CATransform3DIdentity;
45
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
46
+    
47
+    if(side == LeftSide)
48
+    {
49
+        contentTransform = CATransform3DTranslate(contentTransform, visibleWidth - (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
50
+        contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
51
+    }
52
+    else
53
+    {
54
+        contentTransform = CATransform3DTranslate(contentTransform, 0 - visibleWidth + (contentView.frame.size.width / 2 * 0.4), 0.0, 0.0);
55
+        contentTransform = CATransform3DScale(contentTransform, 0.6, 0.6, 0.6);
56
+    }
57
+    
58
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
59
+    [contentView addSubview:overlayContentView];
60
+    
61
+    // Animate
62
+    [UIView animateWithDuration:animationDuration
63
+                          delay:0.0
64
+                        options:UIViewAnimationOptionCurveEaseInOut
65
+                     animations:^{
66
+                         contentView.layer.transform = contentTransform;
67
+                         sidebarView.layer.transform = sidebarTransform;
68
+                         overlayContentView.backgroundColor = [self overlayContentColor];
69
+                     }
70
+                     completion:^(BOOL finished) {
71
+                         completion(finished);
72
+                     }];
73
+}
74
+
75
+
76
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
77
+{
78
+    // Animation settings for content view
79
+    CATransform3D contentTransform = CATransform3DIdentity;
80
+    contentTransform.m34 = -1.0f / 800.0f;
81
+    contentView.layer.zPosition = 100;
82
+    contentTransform = CATransform3DTranslate(contentTransform, 0.0, 0.0, 0.0);
83
+    contentTransform = CATransform3DScale(contentTransform, 1.0, 1.0, 1.0);
84
+    
85
+    // Animation settings for menu view
86
+    __block CATransform3D sidebarTransform = CATransform3DIdentity;
87
+    sidebarTransform = CATransform3DScale(sidebarTransform, 1.7, 1.7, 1.7);
88
+    
89
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
90
+    [contentView addSubview:overlayContentView];
91
+    
92
+    // Animate
93
+    [UIView animateWithDuration:animationDuration
94
+                          delay:0.0
95
+                        options:UIViewAnimationOptionCurveEaseInOut
96
+                     animations:^{
97
+                         contentView.layer.transform = contentTransform;
98
+                         sidebarView.layer.transform = sidebarTransform;
99
+                         overlayContentView.backgroundColor = [UIColor clearColor];
100
+                     }
101
+                     completion:^(BOOL finished) {
102
+                         completion(finished);
103
+                         sidebarTransform = CATransform3DIdentity;
104
+                         sidebarTransform = CATransform3DScale(sidebarTransform, 1.0, 1.0, 1.0);
105
+                         sidebarView.layer.transform = sidebarTransform;
106
+                         [overlayContentView removeFromSuperview];
107
+                     }];
108
+}
109
+
110
+
111
+@end

+ 28
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarWunderlistAnimation.h View File

@@ -0,0 +1,28 @@
1
+// SidebarWunderlistAnimation.h
2
+// TheSidebarController
3
+// 
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+// 
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+// 
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+#import "SidebarAnimation.h"
25
+
26
+@interface SidebarWunderlistAnimation : SidebarAnimation
27
+
28
+@end

+ 103
- 0
ios/RNNSideMenu/TheSidebarController/Animations/SidebarWunderlistAnimation.m View File

@@ -0,0 +1,103 @@
1
+// SidebarWunderlistAnimation.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2014 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "SidebarWunderlistAnimation.h"
26
+
27
+@implementation SidebarWunderlistAnimation
28
+
29
++ (void)animateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
30
+{
31
+    [self resetSidebarPosition:sidebarView];
32
+    [self resetContentPosition:contentView];
33
+    
34
+    
35
+    CGRect contentFrame = contentView.frame;
36
+    CGRect sidebarFrame = sidebarView.frame;
37
+    
38
+    if(side == LeftSide)
39
+    {
40
+        contentFrame.origin.x += visibleWidth;
41
+        sidebarFrame.origin.x -= 50;
42
+    }
43
+    else
44
+    {
45
+        contentFrame.origin.x -= visibleWidth;
46
+        sidebarFrame.origin.x += 50;
47
+    }
48
+    
49
+    sidebarView.frame = sidebarFrame;
50
+    sidebarFrame.origin.x = 0;
51
+    
52
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
53
+    [contentView addSubview:overlayContentView];
54
+    
55
+    [UIView animateWithDuration:animationDuration
56
+                          delay:0.0
57
+                        options:UIViewAnimationOptionCurveEaseInOut
58
+                     animations:^{
59
+                         contentView.frame = contentFrame;
60
+                         sidebarView.frame = sidebarFrame;
61
+                         overlayContentView.backgroundColor = [self overlayContentColor];
62
+                     }
63
+                     completion:^(BOOL finished) {
64
+                         completion(finished);
65
+                     }];
66
+}
67
+
68
+
69
++ (void)reverseAnimateContentView:(UIView *)contentView sidebarView:(UIView *)sidebarView fromSide:(Side)side visibleWidth:(CGFloat)visibleWidth duration:(NSTimeInterval)animationDuration completion:(void (^)(BOOL))completion
70
+{
71
+    CGRect contentFrame = contentView.frame;
72
+    contentFrame.origin.x = 0;
73
+    
74
+    CGRect sidebarFrame = sidebarView.frame;
75
+    
76
+    if(side == LeftSide)
77
+    {
78
+        sidebarFrame.origin.x -= 50;
79
+    }
80
+    else
81
+    {
82
+        sidebarFrame.origin.x += 50;
83
+    }
84
+    
85
+    UIView *overlayContentView = [self overlayContentView:contentView.bounds];
86
+    [contentView addSubview:overlayContentView];
87
+    
88
+    [UIView animateWithDuration:animationDuration
89
+                          delay:0.0
90
+                        options:UIViewAnimationOptionCurveEaseInOut
91
+                     animations:^{
92
+                         contentView.frame = contentFrame;
93
+                         sidebarView.frame = sidebarFrame;
94
+                         overlayContentView.backgroundColor = [UIColor clearColor];
95
+                     }
96
+                     completion:^(BOOL finished) {
97
+                         completion(finished);
98
+                         [overlayContentView removeFromSuperview];
99
+                     }];
100
+}
101
+
102
+
103
+@end

+ 91
- 0
ios/RNNSideMenu/TheSidebarController/TheSidebarController.h View File

@@ -0,0 +1,91 @@
1
+// TheSidebarController.h
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2013 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import <UIKit/UIKit.h>
26
+#import "Animations/SidebarAnimation.h"
27
+
28
+@protocol TheSidebarControllerDelegate;
29
+
30
+@interface TheSidebarController : UIViewController
31
+
32
+@property (strong, nonatomic) UIViewController *contentViewController;
33
+@property (strong, nonatomic) UIViewController *leftSidebarViewController;
34
+@property (strong, nonatomic) UIViewController *rightSidebarViewController;
35
+
36
+@property (assign, nonatomic) NSTimeInterval animationDuration;
37
+@property (assign, nonatomic) CGFloat visibleWidth;
38
+@property (assign, nonatomic) BOOL sidebarIsPresenting;
39
+@property (assign, nonatomic) id<TheSidebarControllerDelegate> delegate;
40
+@property (assign, nonatomic) BOOL storyboardsUseAutolayout;
41
+@property (nonatomic, strong) UIColor *overlayContentColor;
42
+
43
+- (id)initWithContentViewController:(UIViewController *)contentViewController
44
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController;
45
+
46
+- (id)initWithContentViewController:(UIViewController *)contentViewController
47
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController;
48
+
49
+- (id)initWithContentViewController:(UIViewController *)contentViewController
50
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController
51
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController;
52
+
53
+- (id)initWithContentViewController:(UIViewController *)contentViewController
54
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController
55
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout;
56
+
57
+- (id)initWithContentViewController:(UIViewController *)contentViewController
58
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController
59
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout;
60
+
61
+- (id)initWithContentViewController:(UIViewController *)contentViewController
62
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController
63
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController
64
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout;
65
+
66
+- (void)dismissSidebarViewController;
67
+- (void)presentLeftSidebarViewController;
68
+- (void)presentLeftSidebarViewControllerWithStyle:(SidebarTransitionStyle)transitionStyle;
69
+- (void)presentRightSidebarViewController;
70
+- (void)presentRightSidebarViewControllerWithStyle:(SidebarTransitionStyle)transitionStyle;
71
+
72
+@end
73
+
74
+
75
+
76
+@protocol TheSidebarControllerDelegate <NSObject>
77
+
78
+@optional
79
+- (void)sidebarController:(TheSidebarController *)sidebarController willShowViewController:(UIViewController *)viewController;
80
+- (void)sidebarController:(TheSidebarController *)sidebarController didShowViewController:(UIViewController *)viewController;
81
+- (void)sidebarController:(TheSidebarController *)sidebarController willHideViewController:(UIViewController *)viewController;
82
+- (void)sidebarController:(TheSidebarController *)sidebarController didHideViewController:(UIViewController *)viewController;
83
+@end
84
+
85
+
86
+
87
+@interface UIViewController(TheSidebarController)
88
+
89
+@property (strong, readonly, nonatomic) TheSidebarController *sidebarController;
90
+
91
+@end

+ 414
- 0
ios/RNNSideMenu/TheSidebarController/TheSidebarController.m View File

@@ -0,0 +1,414 @@
1
+// TheSidebarController.m
2
+// TheSidebarController
3
+//
4
+// Copyright (c) 2013 Jon Danao (danao.org | jondanao)
5
+//
6
+// Permission is hereby granted, free of charge, to any person obtaining a copy
7
+// of this software and associated documentation files (the "Software"), to deal
8
+// in the Software without restriction, including without limitation the rights
9
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+// copies of the Software, and to permit persons to whom the Software is
11
+// furnished to do so, subject to the following conditions:
12
+//
13
+// The above copyright notice and this permission notice shall be included in
14
+// all copies or substantial portions of the Software.
15
+//
16
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+// THE SOFTWARE.
23
+
24
+
25
+#import "TheSidebarController.h"
26
+
27
+
28
+static const CGFloat kAnimationDuration = 0.3f;
29
+static const CGFloat kVisibleWidth = 310.0f;
30
+
31
+
32
+@interface TheSidebarController()
33
+
34
+@property (assign, nonatomic) SidebarTransitionStyle selectedTransitionStyle;
35
+@property (assign, nonatomic) Side selectedSide;
36
+@property (strong, nonatomic) UIViewController *selectedSidebarViewController;
37
+@property (strong, nonatomic) NSArray *sidebarAnimations;
38
+@property (strong, nonatomic) UIViewController *contentContainerViewController;
39
+@property (strong, nonatomic) UIViewController *leftSidebarContainerViewController;
40
+@property (strong, nonatomic) UIViewController *rightSidebarContainerViewController;
41
+@property (assign, nonatomic) CATransform3D contentTransform;
42
+
43
+- (void)showSidebarViewControllerFromSide:(Side)side withTransitionStyle:(SidebarTransitionStyle)transitionStyle;
44
+- (void)hideSidebarViewController;
45
+- (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view;
46
+
47
+@end
48
+
49
+
50
+@implementation TheSidebarController
51
+
52
+#pragma mark - Designated Initializer
53
+- (id)init
54
+{
55
+    return [self initWithContentViewController:nil leftSidebarViewController:nil rightSidebarViewController:nil];
56
+}
57
+
58
+- (id)initWithContentViewController:(UIViewController *)contentViewController leftSidebarViewController:(UIViewController *)leftSidebarViewController
59
+{
60
+    return [self initWithContentViewController:contentViewController leftSidebarViewController:leftSidebarViewController rightSidebarViewController:nil];
61
+}
62
+
63
+- (id)initWithContentViewController:(UIViewController *)contentViewController rightSidebarViewController:(UIViewController *)rightSidebarViewController
64
+{
65
+    return [self initWithContentViewController:contentViewController leftSidebarViewController:nil rightSidebarViewController:rightSidebarViewController];
66
+}
67
+
68
+- (id)initWithContentViewController:(UIViewController *)contentViewController leftSidebarViewController:(UIViewController *)leftSidebarViewController rightSidebarViewController:(UIViewController *)rightSidebarViewController
69
+{
70
+    self = [super init];
71
+    
72
+    if(self)
73
+    {
74
+        _contentContainerViewController = [[UIViewController alloc] init];
75
+        _leftSidebarContainerViewController = [[UIViewController alloc] init];
76
+        _rightSidebarContainerViewController = [[UIViewController alloc] init];
77
+        
78
+        _contentContainerViewController.view.backgroundColor = [UIColor clearColor];
79
+        _leftSidebarContainerViewController.view.backgroundColor = [UIColor clearColor];
80
+        _rightSidebarContainerViewController.view.backgroundColor = [UIColor clearColor];
81
+        
82
+        _contentViewController = contentViewController;
83
+        _leftSidebarViewController = leftSidebarViewController;
84
+        _rightSidebarViewController = rightSidebarViewController;
85
+        
86
+        _animationDuration = kAnimationDuration;
87
+        _visibleWidth = kVisibleWidth;
88
+        _sidebarAnimations = @[SIDEBAR_ANIMATIONS];
89
+        _sidebarIsPresenting = NO;
90
+    }
91
+    
92
+    return self;
93
+}
94
+
95
+- (id)initWithContentViewController:(UIViewController *)contentViewController
96
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController
97
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout
98
+{
99
+    self.storyboardsUseAutolayout = storyboardsUseAutoLayout;
100
+    return [self initWithContentViewController:contentViewController leftSidebarViewController:leftSidebarViewController];
101
+}
102
+
103
+- (id)initWithContentViewController:(UIViewController *)contentViewController
104
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController
105
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout
106
+{
107
+    self.storyboardsUseAutolayout = storyboardsUseAutoLayout;
108
+    return [self initWithContentViewController:contentViewController rightSidebarViewController:rightSidebarViewController];
109
+}
110
+
111
+- (id)initWithContentViewController:(UIViewController *)contentViewController
112
+          leftSidebarViewController:(UIViewController *)leftSidebarViewController
113
+         rightSidebarViewController:(UIViewController *)rightSidebarViewController
114
+           storyboardsUseAutoLayout:(BOOL)storyboardsUseAutoLayout
115
+{
116
+    self.storyboardsUseAutolayout = storyboardsUseAutoLayout;
117
+    return [self initWithContentViewController:contentViewController leftSidebarViewController:leftSidebarViewController rightSidebarViewController:rightSidebarViewController];
118
+}
119
+
120
+#pragma mark - UIViewController Lifecycle
121
+- (void)viewDidLoad
122
+{
123
+    NSAssert(self.contentViewController != nil, @"contentViewController was not set");
124
+    
125
+    [super viewDidLoad];
126
+    self.view.translatesAutoresizingMaskIntoConstraints = self.storyboardsUseAutolayout;
127
+    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
128
+    
129
+    if(self.leftSidebarViewController)
130
+    {
131
+        // Parent View Controller
132
+        [self addChildViewController:self.leftSidebarContainerViewController];
133
+        [self.view addSubview:self.leftSidebarContainerViewController.view];
134
+        [self.leftSidebarContainerViewController didMoveToParentViewController:self];
135
+        self.leftSidebarContainerViewController.view.translatesAutoresizingMaskIntoConstraints = self.storyboardsUseAutolayout;
136
+        self.leftSidebarContainerViewController.view.hidden = YES;
137
+        
138
+        // Child View Controller
139
+        [self.leftSidebarContainerViewController addChildViewController:self.leftSidebarViewController];
140
+        [self.leftSidebarContainerViewController.view addSubview:self.leftSidebarViewController.view];
141
+        [self.leftSidebarViewController didMoveToParentViewController:self.leftSidebarContainerViewController];
142
+    }
143
+    
144
+    if(self.rightSidebarViewController)
145
+    {
146
+        // Parent View Controller
147
+        [self addChildViewController:self.rightSidebarContainerViewController];
148
+        [self.view addSubview:self.rightSidebarContainerViewController.view];
149
+        [self.rightSidebarContainerViewController didMoveToParentViewController:self];
150
+        self.rightSidebarContainerViewController.view.translatesAutoresizingMaskIntoConstraints = self.storyboardsUseAutolayout;
151
+        self.rightSidebarContainerViewController.view.hidden = YES;
152
+        
153
+        // Child View Controller
154
+        [self.rightSidebarContainerViewController addChildViewController:self.rightSidebarViewController];
155
+        [self.rightSidebarContainerViewController.view addSubview:self.rightSidebarViewController.view];
156
+        [self.rightSidebarViewController didMoveToParentViewController:self.rightSidebarContainerViewController];
157
+    }
158
+    
159
+    
160
+    // Parent View Controller
161
+    [self addChildViewController:self.contentContainerViewController];
162
+    [self.view addSubview:self.contentContainerViewController.view];
163
+    [self.contentContainerViewController didMoveToParentViewController:self];
164
+    
165
+    // Child View Controller
166
+    [self.contentContainerViewController addChildViewController:self.contentViewController];
167
+    [self.contentContainerViewController.view addSubview:self.contentViewController.view];
168
+    [self.contentViewController didMoveToParentViewController:self.contentContainerViewController];
169
+}
170
+
171
+- (void)viewWillAppear:(BOOL)animated
172
+{
173
+    [super viewWillAppear:animated];
174
+}
175
+
176
+- (void)viewWillDisappear:(BOOL)animated
177
+{
178
+    [super viewWillDisappear:animated];
179
+}
180
+
181
+- (void)viewWillLayoutSubviews
182
+{
183
+    [super viewWillLayoutSubviews];
184
+}
185
+
186
+- (void)didReceiveMemoryWarning
187
+{
188
+    [super didReceiveMemoryWarning];
189
+}
190
+
191
+
192
+#pragma mark - TheSidebarController Presentation Methods
193
+- (void)dismissSidebarViewController
194
+{
195
+    [self hideSidebarViewController];
196
+}
197
+
198
+- (void)presentLeftSidebarViewController
199
+{
200
+    [self presentLeftSidebarViewControllerWithStyle:SidebarTransitionStyleFacebook];
201
+}
202
+
203
+- (void)presentLeftSidebarViewControllerWithStyle:(SidebarTransitionStyle)transitionStyle
204
+{
205
+    NSAssert(self.leftSidebarViewController != nil, @"leftSidebarViewController was not set");
206
+    [self showSidebarViewControllerFromSide:LeftSide withTransitionStyle:transitionStyle];
207
+}
208
+
209
+- (void)presentRightSidebarViewController
210
+{
211
+    [self presentRightSidebarViewControllerWithStyle:SidebarTransitionStyleFacebook];
212
+}
213
+
214
+- (void)presentRightSidebarViewControllerWithStyle:(SidebarTransitionStyle)transitionStyle
215
+{
216
+    NSAssert(self.rightSidebarViewController != nil, @"rightSidebarViewController was not set");
217
+    [self showSidebarViewControllerFromSide:RightSide withTransitionStyle:transitionStyle];
218
+}
219
+
220
+
221
+#pragma mark - TheSidebarController Private Methods
222
+- (void)showSidebarViewControllerFromSide:(Side)side withTransitionStyle:(SidebarTransitionStyle)transitionStyle
223
+{
224
+    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
225
+    self.view.autoresizingMask = UIViewAutoresizingNone;
226
+    
227
+    if(side == LeftSide)
228
+    {
229
+        self.leftSidebarContainerViewController.view.hidden = NO;
230
+        self.rightSidebarContainerViewController.view.hidden = YES;
231
+        self.selectedSidebarViewController = self.leftSidebarViewController;
232
+        self.view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
233
+    }
234
+    else if(side == RightSide)
235
+    {
236
+        self.rightSidebarContainerViewController.view.hidden = NO;
237
+        self.leftSidebarContainerViewController.view.hidden = YES;
238
+        self.selectedSidebarViewController = self.rightSidebarViewController;
239
+        self.view.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
240
+    }
241
+    
242
+    self.selectedSide = side;
243
+    self.selectedTransitionStyle = transitionStyle;
244
+    
245
+    if([self.delegate conformsToProtocol:@protocol(TheSidebarControllerDelegate)] && [self.delegate respondsToSelector:@selector(sidebarController:willShowViewController:)])
246
+    {
247
+        [self.delegate sidebarController:self willShowViewController:self.selectedSidebarViewController];
248
+    }
249
+    
250
+    NSString *animationClassName = self.sidebarAnimations[transitionStyle];
251
+    Class animationClass = NSClassFromString(animationClassName);
252
+    [animationClass setOverlayContentColor:self.overlayContentColor];
253
+    [animationClass animateContentView:self.contentContainerViewController.view
254
+                           sidebarView:self.selectedSidebarViewController.parentViewController.view
255
+                              fromSide:self.selectedSide
256
+                          visibleWidth:self.visibleWidth
257
+                              duration:self.animationDuration
258
+                            completion:^(BOOL finished) {
259
+                                [[UIApplication sharedApplication] endIgnoringInteractionEvents];
260
+                                self.sidebarIsPresenting = YES;
261
+                                
262
+                                if([self.delegate conformsToProtocol:@protocol(TheSidebarControllerDelegate)] && [self.delegate respondsToSelector:@selector(sidebarController:didShowViewController:)])
263
+                                {
264
+                                    [self.delegate sidebarController:self didShowViewController:self.selectedSidebarViewController];
265
+                                }
266
+                            }
267
+     ];
268
+}
269
+
270
+- (void)hideSidebarViewController
271
+{
272
+    [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
273
+    
274
+    if([self.delegate conformsToProtocol:@protocol(TheSidebarControllerDelegate)] && [self.delegate respondsToSelector:@selector(sidebarController:willHideViewController:)])
275
+    {
276
+        [self.delegate sidebarController:self willHideViewController:self.selectedSidebarViewController];
277
+    }
278
+    
279
+    NSString *animationClassName = self.sidebarAnimations[self.selectedTransitionStyle];
280
+    Class animationClass = NSClassFromString(animationClassName);
281
+    [animationClass reverseAnimateContentView:self.contentContainerViewController.view
282
+                                  sidebarView:self.selectedSidebarViewController.parentViewController.view
283
+                                     fromSide:self.selectedSide
284
+                                 visibleWidth:self.visibleWidth
285
+                                     duration:self.animationDuration
286
+                                   completion:^(BOOL finished) {
287
+                                       [[UIApplication sharedApplication] endIgnoringInteractionEvents];
288
+                                       self.sidebarIsPresenting = NO;
289
+                                       
290
+                                       if([self.delegate conformsToProtocol:@protocol(TheSidebarControllerDelegate)] && [self.delegate respondsToSelector:@selector(sidebarController:didHideViewController:)])
291
+                                       {
292
+                                           [self.delegate sidebarController:self didHideViewController:self.selectedSidebarViewController];
293
+                                       }
294
+                                   }
295
+     ];
296
+}
297
+
298
+
299
+#pragma mark - UIViewController Setters
300
+- (void)setContentViewController:(UIViewController *)contentViewController
301
+{
302
+    // Old View Controller
303
+    UIViewController *oldViewController = self.contentViewController;
304
+    [oldViewController willMoveToParentViewController:nil];
305
+    [oldViewController.view removeFromSuperview];
306
+    [oldViewController removeFromParentViewController];
307
+    
308
+    // New View Controller
309
+    UIViewController *newViewController = contentViewController;
310
+    [self.contentContainerViewController addChildViewController:newViewController];
311
+    [self.contentContainerViewController.view addSubview:newViewController.view];
312
+    [newViewController didMoveToParentViewController:self.contentContainerViewController];
313
+    
314
+    _contentViewController = newViewController;
315
+}
316
+
317
+- (void)setLeftSidebarViewController:(UIViewController *)leftSidebarViewController
318
+{
319
+    // Old View Controller
320
+    UIViewController *oldViewController = self.leftSidebarViewController;
321
+    [oldViewController willMoveToParentViewController:nil];
322
+    [oldViewController.view removeFromSuperview];
323
+    [oldViewController removeFromParentViewController];
324
+    
325
+    // New View Controller
326
+    UIViewController *newViewController = leftSidebarViewController;
327
+    [self.leftSidebarContainerViewController addChildViewController:newViewController];
328
+    [self.leftSidebarContainerViewController.view addSubview:newViewController.view];
329
+    [newViewController didMoveToParentViewController:self.leftSidebarContainerViewController];
330
+    
331
+    _leftSidebarViewController = newViewController;
332
+}
333
+
334
+- (void)setRightSidebarViewController:(UIViewController *)rightSidebarViewController
335
+{
336
+    // Old View Controller
337
+    UIViewController *oldViewController = self.leftSidebarViewController;
338
+    [oldViewController willMoveToParentViewController:nil];
339
+    [oldViewController.view removeFromSuperview];
340
+    [oldViewController removeFromParentViewController];
341
+    
342
+    // New View Controller
343
+    UIViewController *newViewController = rightSidebarViewController;
344
+    [self.rightSidebarContainerViewController addChildViewController:newViewController];
345
+    [self.rightSidebarContainerViewController.view addSubview:newViewController.view];
346
+    [newViewController didMoveToParentViewController:self.rightSidebarContainerViewController];
347
+    
348
+    _rightSidebarViewController = newViewController;
349
+}
350
+
351
+
352
+#pragma mark - Autorotation Delegates
353
+- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
354
+{
355
+    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
356
+    
357
+    if((toInterfaceOrientation == UIInterfaceOrientationPortrait) ||
358
+       (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
359
+    {
360
+        NSLog(@"Portrait");
361
+    }
362
+    else if((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
363
+            (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight))
364
+    {
365
+        NSLog(@"Landscape");
366
+    }
367
+    
368
+    
369
+}
370
+
371
+
372
+#pragma mark - Helpers
373
+- (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view
374
+{
375
+    CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x, view.bounds.size.height * anchorPoint.y);
376
+    CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x, view.bounds.size.height * view.layer.anchorPoint.y);
377
+    
378
+    newPoint = CGPointApplyAffineTransform(newPoint, view.transform);
379
+    oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform);
380
+    
381
+    CGPoint position = view.layer.position;
382
+    
383
+    position.x -= oldPoint.x;
384
+    position.x += newPoint.x;
385
+    
386
+    position.y -= oldPoint.y;
387
+    position.y += newPoint.y;
388
+    
389
+    view.layer.position = position;
390
+    view.layer.anchorPoint = anchorPoint;
391
+}
392
+
393
+@end
394
+
395
+
396
+#pragma mark - TheSidebarController Category
397
+@implementation UIViewController(TheSidebarController)
398
+
399
+- (TheSidebarController *)sidebarController
400
+{
401
+    if([self.parentViewController.parentViewController isKindOfClass:[TheSidebarController class]])
402
+    {
403
+        return (TheSidebarController *)self.parentViewController.parentViewController;
404
+    }
405
+    else if([self.parentViewController isKindOfClass:[UINavigationController class]] &&
406
+            [self.parentViewController.parentViewController.parentViewController isKindOfClass:[TheSidebarController class]])
407
+    {
408
+        return (TheSidebarController *)self.parentViewController.parentViewController.parentViewController;
409
+    }
410
+    
411
+    return nil;
412
+}
413
+
414
+@end

+ 17
- 0
ios/RNNSideMenuCenterVC.h View File

@@ -0,0 +1,17 @@
1
+//
2
+//  RNNSideMenuCenterVC.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+@interface RNNSideMenuCenterVC : UIViewController
12
+
13
+@property (readonly) UIViewController* child;
14
+
15
+-(instancetype)initWithChild:(UIViewController*)child;
16
+
17
+@end

+ 24
- 0
ios/RNNSideMenuCenterVC.m View File

@@ -0,0 +1,24 @@
1
+//
2
+//  RNNSideMenuCenterVC.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNSideMenuCenterVC.h"
10
+
11
+@interface RNNSideMenuCenterVC ()
12
+@property (readwrite) UIViewController* child;
13
+@end
14
+
15
+@implementation RNNSideMenuCenterVC
16
+
17
+-(instancetype)initWithChild:(UIViewController *)child
18
+{
19
+	self = [super init];
20
+	self.child = child;
21
+	return self;
22
+}
23
+
24
+@end

+ 22
- 0
ios/RNNSideMenuController.h View File

@@ -0,0 +1,22 @@
1
+//
2
+//  RNNSideMenuController.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+#import "RNNSideMenuCenterVC.h"
11
+#import "RNNSideMenuLeftVC.h"
12
+#import "RNNSideMenuRightVC.h"
13
+
14
+@interface RNNSideMenuController : UIViewController
15
+
16
+@property (readonly) RNNSideMenuCenterVC *center;
17
+@property (readonly) RNNSideMenuLeftVC *left;
18
+@property (readonly) RNNSideMenuRightVC *right;
19
+
20
+-(instancetype)initWithControllers:(NSArray*)controllers;
21
+
22
+@end

+ 49
- 0
ios/RNNSideMenuController.m View File

@@ -0,0 +1,49 @@
1
+//
2
+//  RNNSideMenuController.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNSideMenuController.h"
10
+#import "RNNSideMenuCenterVC.h"
11
+
12
+@interface RNNSideMenuController ()
13
+
14
+@property (readwrite) RNNSideMenuCenterVC *center;
15
+@property (readwrite) RNNSideMenuLeftVC *left;
16
+@property (readwrite) RNNSideMenuRightVC *right;
17
+
18
+@end
19
+
20
+@implementation RNNSideMenuController
21
+
22
+-(instancetype)initWithControllers:(NSArray*)controllers;
23
+ {
24
+	self = [super init];
25
+
26
+	 [self setControllers:controllers];
27
+	 
28
+	return self;
29
+}
30
+
31
+-(void)setControllers:(NSArray*)controllers {
32
+	for (id controller in controllers) {
33
+		
34
+		if ([controller isKindOfClass:[RNNSideMenuCenterVC class]]) {
35
+			self.center = controller;
36
+		}
37
+		else if ([controller isKindOfClass:[RNNSideMenuLeftVC class]]){
38
+			self.left = controller;
39
+		}
40
+		else if ([controller isKindOfClass:[RNNSideMenuRightVC class]]) {
41
+			self.right = controller;
42
+		}
43
+		else {
44
+			@throw [NSException exceptionWithName:@"UnknownSideMenuControllerType" reason:[@"Unknown side menu type " stringByAppendingString:[controller description]] userInfo:nil];
45
+		}
46
+	}
47
+}
48
+
49
+@end

+ 17
- 0
ios/RNNSideMenuLeftVC.h View File

@@ -0,0 +1,17 @@
1
+//
2
+//  RNNSideMenuLeftVC.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+@interface RNNSideMenuLeftVC : UIViewController
12
+
13
+@property (readonly) UIViewController* child;
14
+
15
+-(instancetype)initWithChild:(UIViewController*)child;
16
+
17
+@end

+ 28
- 0
ios/RNNSideMenuLeftVC.m View File

@@ -0,0 +1,28 @@
1
+//
2
+//  RNNSideMenuLeftVC.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNSideMenuLeftVC.h"
10
+
11
+@interface RNNSideMenuLeftVC ()
12
+
13
+@property (readwrite) UIViewController *child;
14
+
15
+@end
16
+
17
+@implementation RNNSideMenuLeftVC
18
+
19
+
20
+-(instancetype)initWithChild:(UIViewController*)child {
21
+	self = [super init];
22
+	self.child = child;
23
+	
24
+	return self;
25
+}
26
+
27
+
28
+@end

+ 17
- 0
ios/RNNSideMenuRightVC.h View File

@@ -0,0 +1,17 @@
1
+//
2
+//  RNNSideMenuRightVC.h
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import <UIKit/UIKit.h>
10
+
11
+@interface RNNSideMenuRightVC : UIViewController
12
+
13
+@property (readonly) UIViewController *child;
14
+
15
+-(instancetype)initWithChild:(UIViewController*)child;
16
+
17
+@end

+ 26
- 0
ios/RNNSideMenuRightVC.m View File

@@ -0,0 +1,26 @@
1
+//
2
+//  RNNSideMenuRightVC.m
3
+//  ReactNativeNavigation
4
+//
5
+//  Created by Ran Greenberg on 09/02/2017.
6
+//  Copyright © 2017 Wix. All rights reserved.
7
+//
8
+
9
+#import "RNNSideMenuRightVC.h"
10
+
11
+@interface RNNSideMenuRightVC ()
12
+
13
+@property (readwrite) UIViewController *child;
14
+
15
+@end
16
+
17
+@implementation RNNSideMenuRightVC
18
+
19
+
20
+-(instancetype)initWithChild:(UIViewController*)child {
21
+	self = [super init];
22
+	self.child = child;
23
+	return self;
24
+}
25
+
26
+@end

+ 200
- 0
ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

@@ -7,6 +7,48 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
10
+		263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */; };
11
+		263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */; };
12
+		263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */; };
13
+		263905B11E4C6F440023D7D3 /* MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058D1E4C6F440023D7D3 /* MMDrawerController.h */; };
14
+		263905B21E4C6F440023D7D3 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639058E1E4C6F440023D7D3 /* MMDrawerController.m */; };
15
+		263905B31E4C6F440023D7D3 /* MMDrawerVisualState.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639058F1E4C6F440023D7D3 /* MMDrawerVisualState.h */; };
16
+		263905B41E4C6F440023D7D3 /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905901E4C6F440023D7D3 /* MMDrawerVisualState.m */; };
17
+		263905B51E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905911E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.h */; };
18
+		263905B61E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905921E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m */; };
19
+		263905B71E4C6F440023D7D3 /* UIViewController+MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905931E4C6F440023D7D3 /* UIViewController+MMDrawerController.h */; };
20
+		263905B81E4C6F440023D7D3 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905941E4C6F440023D7D3 /* UIViewController+MMDrawerController.m */; };
21
+		263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905951E4C6F440023D7D3 /* RCCDrawerController.h */; };
22
+		263905BA1E4C6F440023D7D3 /* RCCDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905961E4C6F440023D7D3 /* RCCDrawerController.m */; };
23
+		263905BB1E4C6F440023D7D3 /* RCCDrawerHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905971E4C6F440023D7D3 /* RCCDrawerHelper.h */; };
24
+		263905BC1E4C6F440023D7D3 /* RCCDrawerHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905981E4C6F440023D7D3 /* RCCDrawerHelper.m */; };
25
+		263905BD1E4C6F440023D7D3 /* RCCDrawerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905991E4C6F440023D7D3 /* RCCDrawerProtocol.h */; };
26
+		263905BE1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639059A1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h */; };
27
+		263905BF1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639059B1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m */; };
28
+		263905C01E4C6F440023D7D3 /* SidebarAirbnbAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2639059E1E4C6F440023D7D3 /* SidebarAirbnbAnimation.h */; };
29
+		263905C11E4C6F440023D7D3 /* SidebarAirbnbAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2639059F1E4C6F440023D7D3 /* SidebarAirbnbAnimation.m */; };
30
+		263905C21E4C6F440023D7D3 /* SidebarAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905A01E4C6F440023D7D3 /* SidebarAnimation.h */; };
31
+		263905C31E4C6F440023D7D3 /* SidebarAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905A11E4C6F440023D7D3 /* SidebarAnimation.m */; };
32
+		263905C41E4C6F440023D7D3 /* SidebarFacebookAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905A21E4C6F440023D7D3 /* SidebarFacebookAnimation.h */; };
33
+		263905C51E4C6F440023D7D3 /* SidebarFacebookAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905A31E4C6F440023D7D3 /* SidebarFacebookAnimation.m */; };
34
+		263905C61E4C6F440023D7D3 /* SidebarFeedlyAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905A41E4C6F440023D7D3 /* SidebarFeedlyAnimation.h */; };
35
+		263905C71E4C6F440023D7D3 /* SidebarFeedlyAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905A51E4C6F440023D7D3 /* SidebarFeedlyAnimation.m */; };
36
+		263905C81E4C6F440023D7D3 /* SidebarFlipboardAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905A61E4C6F440023D7D3 /* SidebarFlipboardAnimation.h */; };
37
+		263905C91E4C6F440023D7D3 /* SidebarFlipboardAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905A71E4C6F440023D7D3 /* SidebarFlipboardAnimation.m */; };
38
+		263905CA1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905A81E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h */; };
39
+		263905CB1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905A91E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m */; };
40
+		263905CC1E4C6F440023D7D3 /* SidebarWunderlistAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905AA1E4C6F440023D7D3 /* SidebarWunderlistAnimation.h */; };
41
+		263905CD1E4C6F440023D7D3 /* SidebarWunderlistAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905AB1E4C6F440023D7D3 /* SidebarWunderlistAnimation.m */; };
42
+		263905CE1E4C6F440023D7D3 /* TheSidebarController.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905AC1E4C6F440023D7D3 /* TheSidebarController.h */; };
43
+		263905CF1E4C6F440023D7D3 /* TheSidebarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905AD1E4C6F440023D7D3 /* TheSidebarController.m */; };
44
+		263905D61E4C94970023D7D3 /* RNNSideMenuController.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905D41E4C94970023D7D3 /* RNNSideMenuController.h */; };
45
+		263905D71E4C94970023D7D3 /* RNNSideMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905D51E4C94970023D7D3 /* RNNSideMenuController.m */; };
46
+		263905DA1E4C99C70023D7D3 /* RNNSideMenuCenterVC.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905D81E4C99C70023D7D3 /* RNNSideMenuCenterVC.h */; };
47
+		263905DB1E4C99C70023D7D3 /* RNNSideMenuCenterVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905D91E4C99C70023D7D3 /* RNNSideMenuCenterVC.m */; };
48
+		263905DE1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905DC1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.h */; };
49
+		263905DF1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905DD1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.m */; };
50
+		263905E21E4CA8C70023D7D3 /* RNNSideMenuRightVC.h in Headers */ = {isa = PBXBuildFile; fileRef = 263905E01E4CA8C70023D7D3 /* RNNSideMenuRightVC.h */; };
51
+		263905E31E4CA8C70023D7D3 /* RNNSideMenuRightVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 263905E11E4CA8C70023D7D3 /* RNNSideMenuRightVC.m */; };
10 52
 		26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = 26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */; };
11 53
 		26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = 26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */; };
12 54
 		7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B11269F1E2D263F00F9B03B /* RNNEventEmitter.m */; };
@@ -40,6 +82,48 @@
40 82
 /* End PBXCopyFilesBuildPhase section */
41 83
 
42 84
 /* Begin PBXFileReference section */
85
+		2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = "<group>"; };
86
+		2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = "<group>"; };
87
+		2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = "<group>"; };
88
+		2639058D1E4C6F440023D7D3 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = "<group>"; };
89
+		2639058E1E4C6F440023D7D3 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = "<group>"; };
90
+		2639058F1E4C6F440023D7D3 /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = "<group>"; };
91
+		263905901E4C6F440023D7D3 /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = "<group>"; };
92
+		263905911E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleDrawerVisualStateManager.h; sourceTree = "<group>"; };
93
+		263905921E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleDrawerVisualStateManager.m; sourceTree = "<group>"; };
94
+		263905931E4C6F440023D7D3 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = "<group>"; };
95
+		263905941E4C6F440023D7D3 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = "<group>"; };
96
+		263905951E4C6F440023D7D3 /* RCCDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCDrawerController.h; sourceTree = "<group>"; };
97
+		263905961E4C6F440023D7D3 /* RCCDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCCDrawerController.m; sourceTree = "<group>"; };
98
+		263905971E4C6F440023D7D3 /* RCCDrawerHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCDrawerHelper.h; sourceTree = "<group>"; };
99
+		263905981E4C6F440023D7D3 /* RCCDrawerHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCCDrawerHelper.m; sourceTree = "<group>"; };
100
+		263905991E4C6F440023D7D3 /* RCCDrawerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCDrawerProtocol.h; sourceTree = "<group>"; };
101
+		2639059A1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCTheSideBarManagerViewController.h; sourceTree = "<group>"; };
102
+		2639059B1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCCTheSideBarManagerViewController.m; sourceTree = "<group>"; };
103
+		2639059E1E4C6F440023D7D3 /* SidebarAirbnbAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarAirbnbAnimation.h; sourceTree = "<group>"; };
104
+		2639059F1E4C6F440023D7D3 /* SidebarAirbnbAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarAirbnbAnimation.m; sourceTree = "<group>"; };
105
+		263905A01E4C6F440023D7D3 /* SidebarAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarAnimation.h; sourceTree = "<group>"; };
106
+		263905A11E4C6F440023D7D3 /* SidebarAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarAnimation.m; sourceTree = "<group>"; };
107
+		263905A21E4C6F440023D7D3 /* SidebarFacebookAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarFacebookAnimation.h; sourceTree = "<group>"; };
108
+		263905A31E4C6F440023D7D3 /* SidebarFacebookAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarFacebookAnimation.m; sourceTree = "<group>"; };
109
+		263905A41E4C6F440023D7D3 /* SidebarFeedlyAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarFeedlyAnimation.h; sourceTree = "<group>"; };
110
+		263905A51E4C6F440023D7D3 /* SidebarFeedlyAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarFeedlyAnimation.m; sourceTree = "<group>"; };
111
+		263905A61E4C6F440023D7D3 /* SidebarFlipboardAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarFlipboardAnimation.h; sourceTree = "<group>"; };
112
+		263905A71E4C6F440023D7D3 /* SidebarFlipboardAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarFlipboardAnimation.m; sourceTree = "<group>"; };
113
+		263905A81E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarLuvocracyAnimation.h; sourceTree = "<group>"; };
114
+		263905A91E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarLuvocracyAnimation.m; sourceTree = "<group>"; };
115
+		263905AA1E4C6F440023D7D3 /* SidebarWunderlistAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarWunderlistAnimation.h; sourceTree = "<group>"; };
116
+		263905AB1E4C6F440023D7D3 /* SidebarWunderlistAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarWunderlistAnimation.m; sourceTree = "<group>"; };
117
+		263905AC1E4C6F440023D7D3 /* TheSidebarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TheSidebarController.h; sourceTree = "<group>"; };
118
+		263905AD1E4C6F440023D7D3 /* TheSidebarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TheSidebarController.m; sourceTree = "<group>"; };
119
+		263905D41E4C94970023D7D3 /* RNNSideMenuController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuController.h; sourceTree = "<group>"; };
120
+		263905D51E4C94970023D7D3 /* RNNSideMenuController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuController.m; sourceTree = "<group>"; };
121
+		263905D81E4C99C70023D7D3 /* RNNSideMenuCenterVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuCenterVC.h; sourceTree = "<group>"; };
122
+		263905D91E4C99C70023D7D3 /* RNNSideMenuCenterVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuCenterVC.m; sourceTree = "<group>"; };
123
+		263905DC1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuLeftVC.h; sourceTree = "<group>"; };
124
+		263905DD1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuLeftVC.m; sourceTree = "<group>"; };
125
+		263905E01E4CA8C70023D7D3 /* RNNSideMenuRightVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNSideMenuRightVC.h; sourceTree = "<group>"; };
126
+		263905E11E4CA8C70023D7D3 /* RNNSideMenuRightVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuRightVC.m; sourceTree = "<group>"; };
43 127
 		26916C941E4B9CCC00D13680 /* RNNRootViewCreator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNRootViewCreator.h; sourceTree = "<group>"; };
44 128
 		26916C961E4B9E7700D13680 /* RNNReactRootViewCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNReactRootViewCreator.h; sourceTree = "<group>"; };
45 129
 		26916C971E4B9E7700D13680 /* RNNReactRootViewCreator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNReactRootViewCreator.m; sourceTree = "<group>"; };
@@ -73,6 +157,71 @@
73 157
 /* End PBXFrameworksBuildPhase section */
74 158
 
75 159
 /* Begin PBXGroup section */
160
+		263905881E4C6F440023D7D3 /* RNNSideMenu */ = {
161
+			isa = PBXGroup;
162
+			children = (
163
+				263905891E4C6F440023D7D3 /* MMDrawerController */,
164
+				263905951E4C6F440023D7D3 /* RCCDrawerController.h */,
165
+				263905961E4C6F440023D7D3 /* RCCDrawerController.m */,
166
+				263905971E4C6F440023D7D3 /* RCCDrawerHelper.h */,
167
+				263905981E4C6F440023D7D3 /* RCCDrawerHelper.m */,
168
+				263905991E4C6F440023D7D3 /* RCCDrawerProtocol.h */,
169
+				2639059A1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h */,
170
+				2639059B1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m */,
171
+				2639059C1E4C6F440023D7D3 /* TheSidebarController */,
172
+			);
173
+			path = RNNSideMenu;
174
+			sourceTree = "<group>";
175
+		};
176
+		263905891E4C6F440023D7D3 /* MMDrawerController */ = {
177
+			isa = PBXGroup;
178
+			children = (
179
+				2639058A1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h */,
180
+				2639058B1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m */,
181
+				2639058C1E4C6F440023D7D3 /* MMDrawerController+Subclass.h */,
182
+				2639058D1E4C6F440023D7D3 /* MMDrawerController.h */,
183
+				2639058E1E4C6F440023D7D3 /* MMDrawerController.m */,
184
+				2639058F1E4C6F440023D7D3 /* MMDrawerVisualState.h */,
185
+				263905901E4C6F440023D7D3 /* MMDrawerVisualState.m */,
186
+				263905911E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.h */,
187
+				263905921E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m */,
188
+				263905931E4C6F440023D7D3 /* UIViewController+MMDrawerController.h */,
189
+				263905941E4C6F440023D7D3 /* UIViewController+MMDrawerController.m */,
190
+			);
191
+			path = MMDrawerController;
192
+			sourceTree = "<group>";
193
+		};
194
+		2639059C1E4C6F440023D7D3 /* TheSidebarController */ = {
195
+			isa = PBXGroup;
196
+			children = (
197
+				2639059D1E4C6F440023D7D3 /* Animations */,
198
+				263905AC1E4C6F440023D7D3 /* TheSidebarController.h */,
199
+				263905AD1E4C6F440023D7D3 /* TheSidebarController.m */,
200
+			);
201
+			path = TheSidebarController;
202
+			sourceTree = "<group>";
203
+		};
204
+		2639059D1E4C6F440023D7D3 /* Animations */ = {
205
+			isa = PBXGroup;
206
+			children = (
207
+				2639059E1E4C6F440023D7D3 /* SidebarAirbnbAnimation.h */,
208
+				2639059F1E4C6F440023D7D3 /* SidebarAirbnbAnimation.m */,
209
+				263905A01E4C6F440023D7D3 /* SidebarAnimation.h */,
210
+				263905A11E4C6F440023D7D3 /* SidebarAnimation.m */,
211
+				263905A21E4C6F440023D7D3 /* SidebarFacebookAnimation.h */,
212
+				263905A31E4C6F440023D7D3 /* SidebarFacebookAnimation.m */,
213
+				263905A41E4C6F440023D7D3 /* SidebarFeedlyAnimation.h */,
214
+				263905A51E4C6F440023D7D3 /* SidebarFeedlyAnimation.m */,
215
+				263905A61E4C6F440023D7D3 /* SidebarFlipboardAnimation.h */,
216
+				263905A71E4C6F440023D7D3 /* SidebarFlipboardAnimation.m */,
217
+				263905A81E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h */,
218
+				263905A91E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m */,
219
+				263905AA1E4C6F440023D7D3 /* SidebarWunderlistAnimation.h */,
220
+				263905AB1E4C6F440023D7D3 /* SidebarWunderlistAnimation.m */,
221
+			);
222
+			path = Animations;
223
+			sourceTree = "<group>";
224
+		};
76 225
 		7B1E4C4B1E2D173700C3A525 /* Controllers */ = {
77 226
 			isa = PBXGroup;
78 227
 			children = (
@@ -87,6 +236,14 @@
87 236
 				7BC9346D1E26886E00EFA125 /* RNNControllerFactory.m */,
88 237
 				7BEF0D161E437684003E96B0 /* RNNRootViewController.h */,
89 238
 				7BEF0D171E437684003E96B0 /* RNNRootViewController.m */,
239
+				263905D41E4C94970023D7D3 /* RNNSideMenuController.h */,
240
+				263905D51E4C94970023D7D3 /* RNNSideMenuController.m */,
241
+				263905D81E4C99C70023D7D3 /* RNNSideMenuCenterVC.h */,
242
+				263905D91E4C99C70023D7D3 /* RNNSideMenuCenterVC.m */,
243
+				263905E01E4CA8C70023D7D3 /* RNNSideMenuRightVC.h */,
244
+				263905E11E4CA8C70023D7D3 /* RNNSideMenuRightVC.m */,
245
+				263905DC1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.h */,
246
+				263905DD1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.m */,
90 247
 			);
91 248
 			name = Controllers;
92 249
 			sourceTree = "<group>";
@@ -105,6 +262,7 @@
105 262
 		D8AFADB41BEE6F3F00A4592D = {
106 263
 			isa = PBXGroup;
107 264
 			children = (
265
+				263905881E4C6F440023D7D3 /* RNNSideMenu */,
108 266
 				7BA500731E2544B9001B9E1B /* ReactNativeNavigation.h */,
109 267
 				7BA500741E2544B9001B9E1B /* ReactNativeNavigation.m */,
110 268
 				7BBFE55F1E253F97002A6182 /* RNN.h */,
@@ -134,13 +292,35 @@
134 292
 			buildActionMask = 2147483647;
135 293
 			files = (
136 294
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
295
+				263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */,
137 296
 				7B1126A41E2D2B6C00F9B03B /* ReactNativeNavigation.h in Headers */,
297
+				263905DE1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.h in Headers */,
298
+				263905B71E4C6F440023D7D3 /* UIViewController+MMDrawerController.h in Headers */,
299
+				263905BB1E4C6F440023D7D3 /* RCCDrawerHelper.h in Headers */,
300
+				263905CC1E4C6F440023D7D3 /* SidebarWunderlistAnimation.h in Headers */,
301
+				263905AE1E4C6F440023D7D3 /* MMDrawerBarButtonItem.h in Headers */,
302
+				263905BD1E4C6F440023D7D3 /* RCCDrawerProtocol.h in Headers */,
303
+				263905C21E4C6F440023D7D3 /* SidebarAnimation.h in Headers */,
304
+				263905B51E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.h in Headers */,
305
+				263905C61E4C6F440023D7D3 /* SidebarFeedlyAnimation.h in Headers */,
138 306
 				7B1126A31E2D2B6C00F9B03B /* RNNSplashScreen.h in Headers */,
139 307
 				7B1126A51E2D2B6C00F9B03B /* RNN.h in Headers */,
308
+				263905C01E4C6F440023D7D3 /* SidebarAirbnbAnimation.h in Headers */,
309
+				263905C41E4C6F440023D7D3 /* SidebarFacebookAnimation.h in Headers */,
140 310
 				7BEF0D181E437684003E96B0 /* RNNRootViewController.h in Headers */,
141 311
 				7B1126A61E2D2B6C00F9B03B /* RNNBridgeModule.h in Headers */,
312
+				263905DA1E4C99C70023D7D3 /* RNNSideMenuCenterVC.h in Headers */,
313
+				263905BE1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.h in Headers */,
314
+				263905CE1E4C6F440023D7D3 /* TheSidebarController.h in Headers */,
142 315
 				7B1126A71E2D2B6C00F9B03B /* RNNEventEmitter.h in Headers */,
316
+				263905CA1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.h in Headers */,
317
+				263905B11E4C6F440023D7D3 /* MMDrawerController.h in Headers */,
318
+				263905B91E4C6F440023D7D3 /* RCCDrawerController.h in Headers */,
319
+				263905E21E4CA8C70023D7D3 /* RNNSideMenuRightVC.h in Headers */,
320
+				263905B31E4C6F440023D7D3 /* MMDrawerVisualState.h in Headers */,
143 321
 				7B1126A91E2D2B6C00F9B03B /* RNNControllerFactory.h in Headers */,
322
+				263905D61E4C94970023D7D3 /* RNNSideMenuController.h in Headers */,
323
+				263905C81E4C6F440023D7D3 /* SidebarFlipboardAnimation.h in Headers */,
144 324
 				7BEF0D1C1E43771B003E96B0 /* RNNLayoutNode.h in Headers */,
145 325
 			);
146 326
 			runOnlyForDeploymentPostprocessing = 0;
@@ -202,15 +382,35 @@
202 382
 			isa = PBXSourcesBuildPhase;
203 383
 			buildActionMask = 2147483647;
204 384
 			files = (
385
+				263905C71E4C6F440023D7D3 /* SidebarFeedlyAnimation.m in Sources */,
386
+				263905B41E4C6F440023D7D3 /* MMDrawerVisualState.m in Sources */,
387
+				263905C51E4C6F440023D7D3 /* SidebarFacebookAnimation.m in Sources */,
205 388
 				7BEF0D191E437684003E96B0 /* RNNRootViewController.m in Sources */,
389
+				263905C31E4C6F440023D7D3 /* SidebarAnimation.m in Sources */,
390
+				263905BF1E4C6F440023D7D3 /* RCCTheSideBarManagerViewController.m in Sources */,
206 391
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
392
+				263905CB1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m in Sources */,
207 393
 				7BA500751E2544B9001B9E1B /* ReactNativeNavigation.m in Sources */,
394
+				263905B21E4C6F440023D7D3 /* MMDrawerController.m in Sources */,
208 395
 				7BBFE5441E25330E002A6182 /* RNNBridgeModule.m in Sources */,
209 396
 				7BEF0D1D1E43771B003E96B0 /* RNNLayoutNode.m in Sources */,
210 397
 				7BA500781E254908001B9E1B /* RNNSplashScreen.m in Sources */,
398
+				263905BA1E4C6F440023D7D3 /* RCCDrawerController.m in Sources */,
399
+				263905E31E4CA8C70023D7D3 /* RNNSideMenuRightVC.m in Sources */,
400
+				263905BC1E4C6F440023D7D3 /* RCCDrawerHelper.m in Sources */,
401
+				263905C11E4C6F440023D7D3 /* SidebarAirbnbAnimation.m in Sources */,
402
+				263905D71E4C94970023D7D3 /* RNNSideMenuController.m in Sources */,
211 403
 				26916C991E4B9E7700D13680 /* RNNReactRootViewCreator.m in Sources */,
404
+				263905B81E4C6F440023D7D3 /* UIViewController+MMDrawerController.m in Sources */,
405
+				263905DB1E4C99C70023D7D3 /* RNNSideMenuCenterVC.m in Sources */,
406
+				263905CD1E4C6F440023D7D3 /* SidebarWunderlistAnimation.m in Sources */,
407
+				263905CF1E4C6F440023D7D3 /* TheSidebarController.m in Sources */,
408
+				263905AF1E4C6F440023D7D3 /* MMDrawerBarButtonItem.m in Sources */,
212 409
 				7BBFE5611E253F97002A6182 /* RNN.m in Sources */,
213 410
 				7BC9346E1E26886E00EFA125 /* RNNControllerFactory.m in Sources */,
411
+				263905B61E4C6F440023D7D3 /* MMExampleDrawerVisualStateManager.m in Sources */,
412
+				263905DF1E4CA5B70023D7D3 /* RNNSideMenuLeftVC.m in Sources */,
413
+				263905C91E4C6F440023D7D3 /* SidebarFlipboardAnimation.m in Sources */,
214 414
 			);
215 415
 			runOnlyForDeploymentPostprocessing = 0;
216 416
 		};

+ 162
- 15
playground/ios/playgroundTests/RNNControllerFactoryTest.m View File

@@ -7,42 +7,189 @@
7 7
 //
8 8
 
9 9
 #import <XCTest/XCTest.h>
10
-#import "RNNControllerFactory.m"
10
+#import "RNNControllerFactory.h"
11
+
11 12
 
12 13
 @interface RNNControllerFactoryTest : XCTestCase
13 14
 
15
+@property (nonatomic, strong) id<RNNRootViewCreator> creator;
16
+@property (nonatomic, strong) RNNControllerFactory *factory;
17
+
14 18
 @end
15 19
 
16 20
 @implementation RNNControllerFactoryTest
17 21
 
18 22
 - (void)setUp {
19
-    [super setUp];
20
-    // Put setup code here. This method is called before the invocation of each test method in the class.
23
+	[super setUp];
24
+	self.creator = nil;
25
+	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator];
26
+	
21 27
 }
22 28
 
23 29
 - (void)tearDown {
24
-    // Put teardown code here. This method is called after the invocation of each test method in the class.
25
-    [super tearDown];
30
+	// Put teardown code here. This method is called after the invocation of each test method in the class.
31
+	[super tearDown];
32
+}
33
+
34
+- (void)testCreateLayout_EmptyLayout {
35
+	XCTAssertThrows([self.factory createLayout:@{}]);
36
+}
37
+
38
+
39
+- (void)testCreateLayout_ContainerLayout {
40
+	
41
+	id ans = [self.factory createLayout:
42
+			  @{@"id": @"cntId",
43
+				@"type": @"Container",
44
+				@"data": @{},
45
+				@"children": @[]}];
46
+	XCTAssertTrue([ans isMemberOfClass:[RNNRootViewController class]]);
26 47
 }
27 48
 
28
-- (void)testCreateContainer_EmptyLayout {
29
-	RNNControllerFactory *factory = [[RNNControllerFactory alloc] init];
30
-	XCTAssertThrows([factory createLayout:@{}]);
49
+- (void)testCreateLayout_ContainerStackLayout {
50
+	id ans = [self.factory createLayout:
51
+			  @{@"id": @"cntId",
52
+				@"type": @"ContainerStack",
53
+				@"data": @{},
54
+				@"children": @[]}];
55
+	XCTAssertTrue([ans isMemberOfClass:[UINavigationController class]]);
31 56
 }
32 57
 
58
+- (void)testCreateLayout_ContainerStackLayoutRecursive {
59
+	UINavigationController* ans = (UINavigationController*) [self.factory createLayout:
60
+															 @{@"id": @"cntId",
61
+															   @"type": @"ContainerStack",
62
+															   @"data": @{},
63
+															   @"children": @[
64
+																	   @{@"id": @"cntId_2",
65
+																		 @"type": @"Container",
66
+																		 @"data": @{},
67
+																		 @"children": @[]}]}];
68
+	
69
+	XCTAssertTrue([ans isMemberOfClass:[UINavigationController class]]);
70
+	XCTAssertTrue(ans.childViewControllers.count == 1);
71
+	XCTAssertTrue([ans.childViewControllers[0] isMemberOfClass:[RNNRootViewController class]]);
72
+}
33 73
 
34
-- (void)testCreateContainer_ContainerLayout {
74
+- (void)testCreateLayout_BottomTabsLayout {
75
+	UITabBarController* tabBar = (UITabBarController*) [self.factory createLayout:
76
+														@{
77
+														  @"id": @"cntId",
78
+														  @"type": @"BottomTabs",
79
+														  @"data": @{},
80
+														  @"children": @[
81
+																  @{@"id": @"cntId_2",
82
+																	@"type": @"ContainerStack",
83
+																	@"data": @{},
84
+																	@"children": @[
85
+																			@{@"id": @"cntId_3",
86
+																			  @"type": @"Container",
87
+																			  @"data": @{},
88
+																			  @"children": @[]}]}]}];
89
+	
90
+	XCTAssertTrue([tabBar isMemberOfClass:[UITabBarController class]]);
91
+	XCTAssertTrue(tabBar.childViewControllers.count == 1);
92
+	XCTAssertTrue([tabBar.childViewControllers[0] isMemberOfClass:[UINavigationController class]]);
35 93
 	
36
-	id <RNNRootViewCreator> creator = nil;
94
+	UINavigationController *navController = tabBar.childViewControllers[0];
95
+	XCTAssertTrue(navController.childViewControllers.count == 1);
96
+	XCTAssertTrue([navController.childViewControllers[0] isMemberOfClass:[RNNRootViewController class]]);
37 97
 	
38
-	RNNControllerFactory *factory = [[RNNControllerFactory alloc] initWithRootViewCreator:creator];
39
-	id ans = [factory createLayout:@{@"id": @"cntId",
40
-									 @"type": @"Container",
41
-									 @"data": @{},
42
-									 @"children": @[]}];
98
+	
99
+}
100
+
101
+- (void)testCreateLayout_ContainerSideMenuLayoutCenterOnly {
102
+	RNNSideMenuController *ans = (RNNSideMenuController*) [self.factory createLayout:@{@"id": @"cntId",
103
+																					   @"type": @"SideMenuRoot",
104
+																					   @"data": @{},
105
+																					   @"children": @[@{@"id": @"cntI_2",
106
+																										@"type": @"SideMenuCenter",
107
+																										@"data": @{},
108
+																										@"children": @[
109
+																												@{@"id": @"cntId_3",
110
+																												  @"type": @"Container",
111
+																												  @"data": @{},
112
+																												  @"children": @[]}]}]}];
113
+	XCTAssertTrue([ans isMemberOfClass:[RNNSideMenuController class]]);
114
+	XCTAssertTrue([ans isKindOfClass:[UIViewController class]]);
115
+	XCTAssertTrue([ans.center isMemberOfClass:[RNNSideMenuCenterVC class]]);
116
+	XCTAssertTrue([ans.center.child isMemberOfClass:[RNNRootViewController class]]);
117
+}
118
+
119
+
120
+- (void)testCreateLayout_ContainerSideMenuLayoutCenterAndLeft {
121
+	RNNSideMenuController *ans = (RNNSideMenuController*) [self.factory createLayout:@{@"id": @"cntId",
122
+																					   @"type": @"SideMenuRoot",
123
+																					   @"data": @{},
124
+																					   @"children": @[
125
+																							   @{@"id": @"cntI_2",
126
+																								 @"type": @"SideMenuCenter",
127
+																								 @"data": @{},
128
+																								 @"children": @[
129
+																										 @{@"id": @"cntId_3",
130
+																										   @"type": @"Container",
131
+																										   @"data": @{},
132
+																										   @"children": @[]}]},
133
+																							   @{@"id": @"cntI_4",
134
+																								 @"type": @"SideMenuLeft",
135
+																								 @"data": @{},
136
+																								 @"children": @[
137
+																										 @{@"id": @"cntId_5",
138
+																										   @"type": @"Container",
139
+																										   @"data": @{},
140
+																										   @"children": @[]}]}]}];
141
+	XCTAssertTrue([ans isMemberOfClass:[RNNSideMenuController class]]);
43 142
 	XCTAssertTrue([ans isKindOfClass:[UIViewController class]]);
143
+	XCTAssertTrue([ans.center isMemberOfClass:[RNNSideMenuCenterVC class]]);
144
+	XCTAssertTrue([ans.center.child isMemberOfClass:[RNNRootViewController class]]);
145
+	XCTAssertTrue([ans.left isMemberOfClass:[RNNSideMenuLeftVC class]]);
146
+	
147
+	RNNSideMenuLeftVC *left = (RNNSideMenuLeftVC*)ans.left;
148
+	XCTAssertTrue([left.child isMemberOfClass:[RNNRootViewController class]]);
44 149
 }
45 150
 
151
+- (void)testCreateLayout_ContainerSideMenuLayoutCenterLeftRight {
152
+	RNNSideMenuController *ans = (RNNSideMenuController*) [self.factory createLayout:@{@"id": @"cntId",
153
+																					   @"type": @"SideMenuRoot",
154
+																					   @"data": @{},
155
+																					   @"children": @[
156
+																							   @{@"id": @"cntI_2",
157
+																								 @"type": @"SideMenuCenter",
158
+																								 @"data": @{},
159
+																								 @"children": @[
160
+																										 @{@"id": @"cntId_3",
161
+																										   @"type": @"Container",
162
+																										   @"data": @{},
163
+																										   @"children": @[]}]},
164
+																							   @{@"id": @"cntI_4",
165
+																								 @"type": @"SideMenuLeft",
166
+																								 @"data": @{},
167
+																								 @"children": @[
168
+																										 @{@"id": @"cntId_5",
169
+																										   @"type": @"Container",
170
+																										   @"data": @{},
171
+																										   @"children": @[]}]},
172
+																							   @{@"id": @"cntI_6",
173
+																								 @"type": @"SideMenuRight",
174
+																								 @"data": @{},
175
+																								 @"children": @[
176
+																										 @{@"id": @"cntId_5",
177
+																										   @"type": @"Container",
178
+																										   @"data": @{},
179
+																										   @"children": @[]}]}]}];
180
+	XCTAssertTrue([ans isMemberOfClass:[RNNSideMenuController class]]);
181
+	XCTAssertTrue([ans isKindOfClass:[UIViewController class]]);
182
+	XCTAssertTrue([ans.center isMemberOfClass:[RNNSideMenuCenterVC class]]);
183
+	XCTAssertTrue([ans.center.child isMemberOfClass:[RNNRootViewController class]]);
184
+	XCTAssertTrue([ans.left isMemberOfClass:[RNNSideMenuLeftVC class]]);
185
+	
186
+	RNNSideMenuLeftVC *left = (RNNSideMenuLeftVC*)ans.left;
187
+	XCTAssertTrue([left.child isMemberOfClass:[RNNRootViewController class]]);
188
+	
189
+	XCTAssertTrue([ans.right isMemberOfClass:[RNNSideMenuRightVC class]]);
190
+	RNNSideMenuRightVC *right = (RNNSideMenuRightVC*)ans.right;
191
+	XCTAssertTrue([right.child isMemberOfClass:[RNNRootViewController class]]);
192
+}
46 193
 
47 194
 
48 195