Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

createBottomTabNavigator transitionConfig

i'm studying react-native by cloning instagram.

There is any way apply transitionConfig to createBottomTabNavigator(react-navigation)? I know there is no transitionConfig in document. but i want to slide up the page just like instagram's upload

const Footer = createBottomTabNavigator(
  {
    Home: { screen: Home },
    Upload: { screen: Upload  },
  },
  {
    initialRouteName: 'Home',
    transitionConfig: TransitionConfiguration,
  }
);
like image 838
meli Avatar asked Jun 09 '18 05:06

meli


People also ask

How do you style the tab bar in react native?

Add icons to the tab bar To add icons to each tab, first import the Icon component from react-native-vector-icons library inside the navigation/TabNavigator/index. js file. For this example, let's use AntDesign based icons. // after other import statements import Icon from 'react-native-vector-icons/AntDesign';


1 Answers

createBottomTabNavigator do not have transitionConfig. To enable transition when clicking on the nav bar, I made the following workaround.

First put the Upload screen into a StackNavigator, and set tabBarOnPress as follow:

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

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

Then put this stack in the BottomTabNavigator

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

Finally put the BottomTabNavigator and the Upload screen into a StackNavigator with the transitionConfig:

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

}, {headerMode: 'none', transitionConfig: TransitionConfiguration})
like image 70
maalls Avatar answered Sep 30 '22 13:09

maalls