createBottomTabNavigator transitionConfig

时间:2018-06-09 05:59:55

标签: react-native react-navigation

我正在通过克隆Instagram来学习反应原生。

有什么方法可以将transitionConfig应用到createBottomTabNavigator(react-navigation)? 我知道document中没有transitionConfig。 但我想像Instagram的上传一样向上滑动页面

const Footer = createBottomTabNavigator(
  {
    Home: { screen: Home },
    Upload: { screen: Upload  },
  },
  {
    initialRouteName: 'Home',
    transitionConfig: TransitionConfiguration,
  }
);

1 个答案:

答案 0 :(得分:1)

createBottomTabNavigator没有transitionConfig。为了在单击导航栏时启用过渡,我做了以下解决方法。

首先将“上传”屏幕放入StackNavigator,然后如下设置tabBarOnPress:

const UploadStack = createStackNavigator({
        Upload: Upload
});

UploadStack.navigationOptions = {
    tabBarOnPress: ({navigation, defaultHandler}) => { navigation.navigate('ModalUpload') }
}

然后将堆栈放入BottomTabNavigator

const Footer = createBottomTabNavigator({ 
    Home: Home,
    UploadStack: UploadStack
});

最后使用transitionConfig将BottomTabNavigator和Upload屏幕放入StackNavigator:

export default createStackNavigator({
    Footer: Footer,
    ModalUpload: Upload

}, {headerMode: 'none', transitionConfig: TransitionConfiguration})