Преглед на файлове

[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 години
родител
ревизия
03e07fa0c7
променени са 3 файла, в които са добавени 36 реда и са изтрити 2 реда
  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 Целия файл

@@ -187,6 +187,18 @@ Navigation.mergeOptions(this.props.componentId, {
187 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 202
   bottomTabs: {
191 203
     barStyle: 'default' | 'black',
192 204
     translucent: true,

+ 3
- 0
lib/ios/RNNSideMenuSideOptions.h Целия файл

@@ -8,5 +8,8 @@
8 8
 @property (nonatomic, strong) NSNumber* visible;
9 9
 @property (nonatomic, strong) NSNumber* enabled;
10 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 15
 @end

+ 21
- 2
lib/ios/RNNSideMenuSideOptions.m Целия файл

@@ -1,5 +1,6 @@
1 1
 #import "RNNSideMenuSideOptions.h"
2 2
 #import "RNNSideMenuController.h"
3
+#import "MMDrawerVisualState.h"
3 4
 
4 5
 @implementation RNNSideMenuSideOptions
5 6
 
@@ -17,7 +18,7 @@
17 18
 					break;
18 19
 			}
19 20
 		}
20
-		
21
+
21 22
 		if (self.visible) {
22 23
 			if (self.visible.boolValue) {
23 24
 				[sideMenuController showSideMenu:side animated:YES];
@@ -26,6 +27,24 @@
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 48
 		if (self.width) {
30 49
 			switch (side) {
31 50
 				case MMDrawerSideRight:
@@ -38,7 +57,7 @@
38 57
 			}
39 58
 		}
40 59
 	}
41
-	
60
+
42 61
 	[self resetOptions];
43 62
 }
44 63