瀏覽代碼

(Android) Allow disableOpenGesture right or left in the drawer (#2189)

This pull request allows you to disable the open gesture only in one side of the drawer.

```
Navigation.startSingleScreenApp({
      screen: initialScreen,
      drawer: {
        left: {
          screen: DRAWER_SCREEN,
          disableOpenGesture: false,
        },
        right: {
          screen: SIDEBAR_FILTER_SCREEN,
          disableOpenGesture: true,
        },
      },
    });
```

If we pass disableOpenGesture to the drawer root object, like this: 

```
Navigation.startSingleScreenApp({
      screen: initialScreen,
      drawer: {
        left: {
          screen: DRAWER_SCREEN,
          disableOpenGesture: false,
        },
        right: {
          screen: SIDEBAR_FILTER_SCREEN,
          disableOpenGesture: true,
        },
        disableOpenGesture: true <======
      },
    });
```

Then the two drawer positions would be gesture disabled and the specific disableOpenGesture would be ignored. This way we don`t introduce breaking changes.
Ricardo Fuhrmann 7 年之前
父節點
當前提交
04a64d142b
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 3
    1
      docs/top-level-api.md
  2. 6
    1
      src/deprecated/platformSpecificDeprecated.android.js

+ 3
- 1
docs/top-level-api.md 查看文件

@@ -104,10 +104,12 @@ Navigation.startSingleScreenApp({
104 104
     left: { // optional, define if you want a drawer from the left
105 105
       screen: 'example.FirstSideMenu', // unique ID registered with Navigation.registerScreen
106 106
       passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
107
+      disableOpenGesture: false // optional, can the drawer be opened with a swipe instead of button
107 108
     },
108 109
     right: { // optional, define if you want a drawer from the right
109 110
       screen: 'example.SecondSideMenu', // unique ID registered with Navigation.registerScreen
110 111
       passProps: {} // simple serializable object that will pass as props to all top screens (optional)
112
+      disableOpenGesture: false // optional, can the drawer be opened with a swipe instead of button
111 113
     },
112 114
     style: { // ( iOS only )
113 115
       drawerShadow: true, // optional, add this if you want a side menu drawer shadow
@@ -118,7 +120,7 @@ Navigation.startSingleScreenApp({
118 120
     type: 'MMDrawer', // optional, iOS only, types: 'TheSideBar', 'MMDrawer' default: 'MMDrawer'
119 121
     animationType: 'door', //optional, iOS only, for MMDrawer: 'door', 'parallax', 'slide', 'slide-and-scale'
120 122
                                         // for TheSideBar: 'airbnb', 'facebook', 'luvocracy','wunder-list'
121
-    disableOpenGesture: false // optional, can the drawer be opened with a swipe instead of button
123
+    disableOpenGesture: false // optional, can the drawer, both right and left, be opened with a swipe instead of button
122 124
   },
123 125
   passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
124 126
   animationType: 'slide-down' // optional, add transition animation to root change: 'none', 'slide-down', 'fade'

+ 6
- 1
src/deprecated/platformSpecificDeprecated.android.js 查看文件

@@ -242,7 +242,12 @@ function convertDrawerParamsToSideMenuParams(drawerParams) {
242 242
       addNavigatorParams(result[key]);
243 243
       result[key] = adaptNavigationParams(result[key]);
244 244
       result[key].passProps = drawer[key].passProps;
245
-      result[key].disableOpenGesture = drawer.disableOpenGesture;
245
+      if (drawer.disableOpenGesture) {
246
+        result[key].disableOpenGesture = drawer.disableOpenGesture;
247
+      } else {
248
+        result[key].disableOpenGesture = drawer[key].disableOpenGesture;
249
+      }
250
+      
246 251
     } else {
247 252
       result[key] = null;
248 253
     }