Browse Source

[V2] Added sideMenu style options similar to V1 options (#3877)

* [V2] Added sideMenu style options similar to V1 options

* Added appropriate header import

* Documented iOS specific styling for new options

* Removed trailing commas for styling consistency
Rob Goldiez 6 years ago
parent
commit
03e07fa0c7
3 changed files with 36 additions and 2 deletions
  1. 12
    0
      docs/docs/styling.md
  2. 3
    0
      lib/ios/RNNSideMenuSideOptions.h
  3. 21
    2
      lib/ios/RNNSideMenuSideOptions.m

+ 12
- 0
docs/docs/styling.md View File

187
       fontFamily: 'Helvetica'
187
       fontFamily: 'Helvetica'
188
     },
188
     },
189
   },
189
   },
190
+  sideMenu: {
191
+    left: {
192
+      shouldStretchDrawer: false, // defaults to true, when false sideMenu contents not stretched when opened past the width
193
+      animationVelocity: 2500, // defaults to 840, high number is a faster sideMenu open/close animation
194
+      animationType: 'parallax' // defaults to none if not provided, options are 'parallax', 'door', 'slide', or 'slide-and-scale'    
195
+    },
196
+    right: {
197
+      shouldStretchDrawer: false, // defaults to true, when false sideMenu contents not stretched when opened past the width
198
+      animationVelocity: 2500, // defaults to 840, high number is a faster sideMenu open/close animation
199
+      animationType: 'parallax' // defaults to none if not provided, options are 'parallax', 'door', 'slide', or 'slide-and-scale'    
200
+    }
201
+  }
190
   bottomTabs: {
202
   bottomTabs: {
191
     barStyle: 'default' | 'black',
203
     barStyle: 'default' | 'black',
192
     translucent: true,
204
     translucent: true,

+ 3
- 0
lib/ios/RNNSideMenuSideOptions.h View File

8
 @property (nonatomic, strong) NSNumber* visible;
8
 @property (nonatomic, strong) NSNumber* visible;
9
 @property (nonatomic, strong) NSNumber* enabled;
9
 @property (nonatomic, strong) NSNumber* enabled;
10
 @property (nonatomic, strong) NSNumber* width;
10
 @property (nonatomic, strong) NSNumber* width;
11
+@property (nonatomic, strong) NSNumber* shouldStretchDrawer;
12
+@property (nonatomic, strong) NSNumber* animationVelocity;
13
+@property (nonatomic, strong) NSString* animationType;
11
 
14
 
12
 @end
15
 @end

+ 21
- 2
lib/ios/RNNSideMenuSideOptions.m View File

1
 #import "RNNSideMenuSideOptions.h"
1
 #import "RNNSideMenuSideOptions.h"
2
 #import "RNNSideMenuController.h"
2
 #import "RNNSideMenuController.h"
3
+#import "MMDrawerVisualState.h"
3
 
4
 
4
 @implementation RNNSideMenuSideOptions
5
 @implementation RNNSideMenuSideOptions
5
 
6
 
17
 					break;
18
 					break;
18
 			}
19
 			}
19
 		}
20
 		}
20
-		
21
+
21
 		if (self.visible) {
22
 		if (self.visible) {
22
 			if (self.visible.boolValue) {
23
 			if (self.visible.boolValue) {
23
 				[sideMenuController showSideMenu:side animated:YES];
24
 				[sideMenuController showSideMenu:side animated:YES];
26
 			}
27
 			}
27
 		}
28
 		}
28
 
29
 
30
+		if (self.shouldStretchDrawer) {
31
+			sideMenuController.sideMenu.shouldStretchDrawer = self.shouldStretchDrawer.boolValue;
32
+		}
33
+
34
+		if (self.animationVelocity) {
35
+			sideMenuController.sideMenu.animationVelocity = [self.animationVelocity doubleValue];
36
+		}
37
+
38
+		MMDrawerControllerDrawerVisualStateBlock animationTypeStateBlock = nil;
39
+		if ([self.animationType isEqualToString:@"door"]) animationTypeStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock];
40
+    else if ([self.animationType isEqualToString:@"parallax"]) animationTypeStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0];
41
+    else if ([self.animationType isEqualToString:@"slide"]) animationTypeStateBlock = [MMDrawerVisualState slideVisualStateBlock];
42
+    else if ([self.animationType isEqualToString:@"slide-and-scale"]) animationTypeStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock];
43
+
44
+		if (animationTypeStateBlock) {
45
+			[sideMenuController.sideMenu setDrawerVisualStateBlock:animationTypeStateBlock];
46
+		}
47
+
29
 		if (self.width) {
48
 		if (self.width) {
30
 			switch (side) {
49
 			switch (side) {
31
 				case MMDrawerSideRight:
50
 				case MMDrawerSideRight:
38
 			}
57
 			}
39
 		}
58
 		}
40
 	}
59
 	}
41
-	
60
+
42
 	[self resetOptions];
61
 	[self resetOptions];
43
 }
62
 }
44
 
63