Browse Source

(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 years ago
parent
commit
04a64d142b
2 changed files with 9 additions and 2 deletions
  1. 3
    1
      docs/top-level-api.md
  2. 6
    1
      src/deprecated/platformSpecificDeprecated.android.js

+ 3
- 1
docs/top-level-api.md View File

104
     left: { // optional, define if you want a drawer from the left
104
     left: { // optional, define if you want a drawer from the left
105
       screen: 'example.FirstSideMenu', // unique ID registered with Navigation.registerScreen
105
       screen: 'example.FirstSideMenu', // unique ID registered with Navigation.registerScreen
106
       passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
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
     right: { // optional, define if you want a drawer from the right
109
     right: { // optional, define if you want a drawer from the right
109
       screen: 'example.SecondSideMenu', // unique ID registered with Navigation.registerScreen
110
       screen: 'example.SecondSideMenu', // unique ID registered with Navigation.registerScreen
110
       passProps: {} // simple serializable object that will pass as props to all top screens (optional)
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
     style: { // ( iOS only )
114
     style: { // ( iOS only )
113
       drawerShadow: true, // optional, add this if you want a side menu drawer shadow
115
       drawerShadow: true, // optional, add this if you want a side menu drawer shadow
118
     type: 'MMDrawer', // optional, iOS only, types: 'TheSideBar', 'MMDrawer' default: 'MMDrawer'
120
     type: 'MMDrawer', // optional, iOS only, types: 'TheSideBar', 'MMDrawer' default: 'MMDrawer'
119
     animationType: 'door', //optional, iOS only, for MMDrawer: 'door', 'parallax', 'slide', 'slide-and-scale'
121
     animationType: 'door', //optional, iOS only, for MMDrawer: 'door', 'parallax', 'slide', 'slide-and-scale'
120
                                         // for TheSideBar: 'airbnb', 'facebook', 'luvocracy','wunder-list'
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
   passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
125
   passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
124
   animationType: 'slide-down' // optional, add transition animation to root change: 'none', 'slide-down', 'fade'
126
   animationType: 'slide-down' // optional, add transition animation to root change: 'none', 'slide-down', 'fade'

+ 6
- 1
src/deprecated/platformSpecificDeprecated.android.js View File

242
       addNavigatorParams(result[key]);
242
       addNavigatorParams(result[key]);
243
       result[key] = adaptNavigationParams(result[key]);
243
       result[key] = adaptNavigationParams(result[key]);
244
       result[key].passProps = drawer[key].passProps;
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
     } else {
251
     } else {
247
       result[key] = null;
252
       result[key] = null;
248
     }
253
     }