aksonov / react-native-router-flux

The first declarative React Native router
MIT License
8.98k stars 2.11k forks source link

Open nested drawers with button #3468

Open cjinghong opened 5 years ago

cjinghong commented 5 years ago

Version

Tell us which versions you are using:

Is there any way to trigger a drawer open using a key? I have a nested Drawer, one opens from left and another opens from right.

<Router>
  <Stack key="root">

    {/* Login Stack */}
    <Stack
      key="login"
      initial
      init
      hideNavBar
    >
      <Scene component={Login} />
    </Stack>

    {/* After Login */}
    <Drawer
      hideNavBar
      key="leftDrawer"
      drawerPosition="left"
      contentComponent={ProfileMenu}
      navigationBarStyle={styles.navBarStyle}
      drawerWidth={300}
    >
      <Drawer
        hideNavBar
        key="rightDrawer"
        drawerPosition="right"
        contentComponent={ProfileMenu}
        navigationBarStyle={styles.navBarStyle}
        drawerWidth={300}
      >
        <Scene
          key="home"
          title="Home"
          component={Home}
          renderLeftButton={this.renderProfileDrawerButton()}
          renderRightButton={this.renderNotificationsDrawerButton()}
          renderTitle={this.renderTitle('Home')}
        />
        <Scene
          key="about"
          title="About"
          component={About}
          renderLeftButton={this.renderProfileDrawerButton()}
          renderRightButton={this.renderNotificationsDrawerButton()}
          renderTitle={this.renderTitle('About')}
        />
      </Drawer>
    </Drawer>
  </Stack>
</Router>

renderProfileDrawerButton() and renderNotificationsDrawerButton() both Renders a button that triggers Actions.drawerOpen() when tapped on.

Is there a way to open the left and right drawer specifically?

simokhalil commented 5 years ago

@cjinghong Did you find any solution/workaround for this ? Both Actions.drawerOpen() and Actions.drawerClose() seem to only trigger on the root drawer...

msushahidullah commented 5 years ago

i'm having the same issue, can anyone pls help me finding how to open right drawer with a button? @cjinghong and @simokhalil you find any solution? really helpful if any...

simokhalil commented 5 years ago

@msushahidullah I managed this by using only the left drawer from react-native-router-flux, and used the Drawer component from Native Base for the right side