Pārlūkot izejas kodu

Feature/set drawer enabled ios (#1347)

* setDrawerEnabled with params side and enabled

* Tweak docs, small RCCDrawerController fix

* Correct indents

* Correct indents
Kyle Johnson 7 gadus atpakaļ
vecāks
revīzija
0381fd0f98

+ 1
- 1
docs/screen-api.md Parādīt failu

@@ -173,7 +173,7 @@ this.props.navigator.toggleDrawer({
173 173
 });
174 174
 ```
175 175
 
176
-## setDrawerEnabled(params = {}) (Android only)
176
+## setDrawerEnabled(params = {})
177 177
 
178 178
 Enables or disables the side menu drawer assuming you have one in your app. Both drawers are enabled by default.
179 179
 

+ 15
- 1
ios/RCCDrawerController/RCCDrawerController.m Parādīt failu

@@ -13,6 +13,9 @@
13 13
 
14 14
 @synthesize drawerStyle = _drawerStyle;
15 15
 
16
+UIViewController *leftViewController = nil;
17
+UIViewController *rightViewController = nil;
18
+
16 19
 -(UIInterfaceOrientationMask)supportedInterfaceOrientations {
17 20
     return [self supportedControllerOrientations];
18 21
 }
@@ -124,7 +127,18 @@
124 127
         
125 128
         return;
126 129
     }
127
-    
130
+
131
+    // setDrawerEnabled
132
+    if ([performAction isEqualToString:@"setDrawerEnabled"])
133
+    {
134
+        bool enabled = [actionParams[@"enabled"] boolValue];
135
+        if ([actionParams[@"side"] isEqualToString:@"left"]) {
136
+            [super setLeftDrawerViewController: enabled ? rightViewController : nil];
137
+        } else if ([actionParams[@"side"] isEqualToString:@"right"]) {
138
+            [super setRightDrawerViewController: enabled ? rightViewController : nil];
139
+        }
140
+    }
141
+
128 142
     // toggle
129 143
     if ([performAction isEqualToString:@"toggle"])
130 144
     {

+ 3
- 0
src/deprecated/controllers/index.js Parādīt failu

@@ -161,6 +161,9 @@ var Controllers = {
161 161
       popToRoot: function (params) {
162 162
         RCCManager.NavigationControllerIOS(id, "popToRoot", params);
163 163
       },
164
+      setDrawerEnabled: function (params) {
165
+        RCCManager.DrawerControllerIOS(id, "setDrawerEnabled", params);
166
+      },
164 167
       setTitle: function (params) {
165 168
         if (params['style']) {
166 169
           params['style'] = Object.assign({}, params['style']);

+ 6
- 0
src/deprecated/platformSpecificDeprecated.ios.js Parādīt failu

@@ -301,6 +301,11 @@ function navigatorResetTo(navigator, params) {
301 301
   });
302 302
 }
303 303
 
304
+function navigatorSetDrawerEnabled(navigator, params) {
305
+    const controllerID = navigator.navigatorID.split('_')[0];
306
+    Controllers.NavigationControllerIOS(controllerID + '_drawer').setDrawerEnabled(params)
307
+}
308
+
304 309
 function navigatorSetTitle(navigator, params) {
305 310
   Controllers.NavigationControllerIOS(navigator.navigatorID).setTitle({
306 311
     title: params.title,
@@ -622,6 +627,7 @@ export default {
622 627
   showInAppNotification,
623 628
   dismissInAppNotification,
624 629
   navigatorSetButtons,
630
+  navigatorSetDrawerEnabled,
625 631
   navigatorSetTitle,
626 632
   navigatorSetSubtitle,
627 633
   navigatorSetStyle,