Advertisement
dobrado

MainTabNavigator.js

May 29th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import { Platform, TouchableOpacity } from 'react-native';
  3. import { Ionicons } from '@expo/vector-icons';
  4. import { TabNavigator, TabBarBottom, DrawerNavigator } from 'react-navigation';
  5.  
  6. import Colors from '../constants/Colors';
  7.  
  8. import UserHome from '../screens/UserHome';
  9. import MapScreen from '../screens/MapScreen';
  10. import SettingsScreen from '../screens/SettingsScreen';
  11. import SideMenu from '../components/SideMenu';
  12.  
  13. export const Tabs =  TabNavigator(
  14.   {
  15.     Home: {
  16.       screen: UserHome,
  17.     },
  18.     Map: {
  19.       screen: MapScreen,
  20.     },
  21.     Settings: {
  22.       screen: SettingsScreen,
  23.     },
  24.   },
  25.   {
  26.     navigationOptions: ({ navigation }) => ({
  27.       tabBarIcon: ({ focused }) => {
  28.         const { routeName } = navigation.state;
  29.         let iconName;
  30.         switch (routeName) {
  31.           case 'Home':
  32.             iconName =
  33.               Platform.OS === 'ios'
  34.                 ? `ios-information-circle${focused ? '' : '-outline'}`
  35.                 : 'md-information-circle';
  36.             break;
  37.           case 'Map':
  38.             iconName = Platform.OS === 'ios' ? `ios-link${focused ? '' : '-outline'}` : 'md-link';
  39.             break;
  40.           case 'Settings':
  41.             iconName =
  42.               Platform.OS === 'ios' ? `ios-options${focused ? '' : '-outline'}` : 'md-options';
  43.         }
  44.         return (
  45.           <Ionicons
  46.             name={iconName}
  47.             size={28}
  48.             style={{ marginBottom: -3, width: 25 }}
  49.             color={focused ? Colors.tabIconSelected : Colors.tabIconDefault}
  50.           />
  51.         );
  52.       },
  53.     }),
  54.     tabBarVisible: true,
  55.     tabBarComponent: TabBarBottom,
  56.     tabBarPosition: 'bottom',
  57.     animationEnabled: false,
  58.     swipeEnabled: false,
  59.   }
  60. );
  61.  
  62. export default DrawerNavigator({
  63.   Tabs: {
  64.     screen: Tabs,
  65.   }
  66. }, {
  67.   contentComponent: SideMenu,
  68.   backBehavior: 'none'
  69. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement