Guest User

Untitled

a guest
Oct 27th, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Ionicons } from '@expo/vector-icons';
  2. import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
  3. import { createStackNavigator } from '@react-navigation/stack';
  4. import { TransitionSpecs } from '@react-navigation/stack';
  5. import { TransitionPresets } from '@react-navigation/stack';
  6. import * as React from 'react';
  7.  
  8. import Colors from '../constants/Colors';
  9. import useColorScheme from '../hooks/useColorScheme';
  10. import TabOneScreen from '../screens/TabOneScreen';
  11. import TabTwoScreen from '../screens/TabTwoScreen';
  12. import { BottomTabParamList, TabOneParamList, TabTwoParamList } from '../types';
  13.  
  14. const BottomTab = createBottomTabNavigator<BottomTabParamList>();
  15.  
  16. export default function BottomTabNavigator() {
  17.   const colorScheme = useColorScheme();
  18.  
  19.   return (
  20.     <BottomTab.Navigator
  21.       initialRouteName="TabOne"
  22.       tabBarOptions={{ activeTintColor: Colors[colorScheme].tint }}>
  23.       <BottomTab.Screen
  24.         name="TabOne"
  25.         component={TabOneNavigator}
  26.         options={{
  27.           tabBarIcon: ({ color }) => <TabBarIcon name="ios-code" color={color} />,
  28.         }}
  29.       />
  30.       <BottomTab.Screen
  31.         name="TabTwo"
  32.         component={TabTwoNavigator}
  33.         options={{
  34.           tabBarIcon: ({ color }) => <TabBarIcon name="ios-code" color={color} />,
  35.         }}
  36.       />
  37.     </BottomTab.Navigator>
  38.   );
  39. }
  40.  
  41. // You can explore the built-in icon families and icons on the web at:
  42. // https://icons.expo.fyi/
  43. function TabBarIcon(props: { name: string; color: string }) {
  44.   return <Ionicons size={30} style={{ marginBottom: -3 }} {...props} />;
  45. }
  46.  
  47. // Each tab has its own navigation stack, you can read more about this pattern here:
  48. // https://reactnavigation.org/docs/tab-based-navigation#a-stack-navigator-for-each-tab
  49. const TabOneStack = createStackNavigator<TabOneParamList>();
  50.  
  51. function TabOneNavigator() {
  52.   return (
  53.     <TabOneStack.Navigator>
  54.       <TabOneStack.Screen
  55.         name="TabOneScreen"
  56.         component={TabOneScreen}
  57.         options={{ headerTitle: 'Tab One Title', ...TransitionPresets.ScaleFromCenterAndroid }}
  58.       />
  59.     </TabOneStack.Navigator>
  60.   );
  61. }
  62.  
  63. const TabTwoStack = createStackNavigator<TabTwoParamList>();
  64.  
  65. function TabTwoNavigator() {
  66.   return (
  67.     <TabTwoStack.Navigator>
  68.       <TabTwoStack.Screen
  69.         name="TabTwoScreen"
  70.         component={TabTwoScreen}
  71.         options={{
  72.           headerTitle: 'Tab Two Title',
  73.           ...TransitionPresets.ScaleFromCenterAndroid
  74.         }}
  75.       />
  76.     </TabTwoStack.Navigator>
  77.   );
  78. }
  79.  
Add Comment
Please, Sign In to add comment