使用模态和抽屉导航

时间:2017-07-19 18:33:59

标签: react-native react-router react-navigation react-native-router-flux

我在react-native应用程序中使用react-native-router-flux进行导航。 我在router.js文件中有这个 -

render() {
    return (
        <Router navigationBarStyle={styles.navBar}
            titleStyle={styles.navBarTitle}
        >

            <Scene key="modal" component={Modal}>
                <Scene key="drawer" component={Drawer} open={false} type="replace">

                    <Scene key="home" component={Home} title="HOME" hideNavBar type="replace" />
                    <Scene key="myorder" component={MyOrder} title="MY ORDERS" type="replace" />
                    <Scene key="bookachef" component={BookAChef} title="BOOK A CHEF" type="replace" />
                    <Scene key="offers" component={Offers} title="OFFERS" type="replace" />
                    <Scene key="terms" component={Terms} title="TERMS & CONDITIONS" />
                    <Scene key="mywishlist" component={MyWishlist} title="WISHLIST" type="replace" />
                    <Scene key="myaddresses" component={MyAddresses} title="Addresses" type="replace" />
                    <Scene key="faq" component={FAQ} title="FAQ" type="replace" />
                    <Scene key="aboutus" component={AboutUs} title="About Us" type="replace" />

                </Scene>
                <Scene key="auth" initial>
                    <Scene key="login" panHandlers={null} component={Login} title="Login" hideNavBar={true} />
                    <Scene key="signup" panHandlers={null} component={SignUp} title="SignUp" hideNavBar={true} />
                    <Scene key="terms" panHandlers={null} component={Terms} title="TERMS & CONDITIONS" />
                </Scene>
                <Scene key="popUpImagePicker" panHandlers={null} component={PopUpImagePicker} title="PopUpImagePicker" hideNavBar={true} />
            </Scene>

        </Router>
    );
}  

现在,登录后,我想拥有通常的流程,即用抽屉打开应用程序。问题是,我可以通过

打开“主页”屏幕

Actions.drawer()

但我无法通过Actions.refresh({key: "drawer", open: true})或从屏幕滑动打开抽屉。我做错了什么,我无法弄明白。 我正在使用"react-native-router-flux": "^3.41.0"

1 个答案:

答案 0 :(得分:0)

要在登录后导航到家庭场景,您可以拨打Actions.drawer(),但在您降落到drawer场景中的任何场景之前,从屏幕滑动将无效,因为您的Drawer组件尚未安装到屏幕上。

至于无法将抽屉滑出,请尝试移除抽屉场景中的type="replace"道具。

至于调用Actions.refresh({ key: 'drawer', open: true })并未解决抽屉组件问题,请确保在Drawer组件中设置open道具,您可以查看RNRF& #39; s v3抽屉example,如果您忘记设置open道具,您的Actions.refresh会更新navigationState,但无法控制开放/ {关闭抽屉组件的状态。