-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
55 lines (50 loc) · 1.71 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from 'react';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import App1 from './App1';
import App2 from './App2';
import { NavigationContainer } from '@react-navigation/native';
//Below requires npm install react-native-vector-icons @types/react-native-vector-icons. Using it for Tab Navigator icons
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
const Tab = createBottomTabNavigator();
const App: React.FC = () => {
//below are some optional props that can be passed to Tab.Navigator. You can try the code with and without options
const tabProps = {
initialRouteName: 'App1Screen',
tabBarOptions:{
activeTintColor: 'green',
inactiveTintColor: 'grey',
style: {
backgroundColor: '#eee',
},
backBehavior: 'history'//Behaviour when system back is touched. Options are none, initialRoute, order, history. This seems to be buggy
},
lazy: true //default is true
}
return (
<NavigationContainer>
<Tab.Navigator {...tabProps}>
<Tab.Screen
name="App1Screen"
component={App1}
options={{
tabBarLabel: 'App 1',
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons name="home" color={color} size={size} />
)
}}
/>
<Tab.Screen
name="App2Screen"
component={App2}
options={{
tabBarLabel: 'App 2',
tabBarIcon: ({ color, size }) => (
<MaterialCommunityIcons name="bell" color={color} size={size} />
)
}}
/>
</Tab.Navigator>
</NavigationContainer>
);
}
export default App