Skip to content

Commit d9bc074

Browse files
committed
Migrate to React Navigation v5
1 parent ae28955 commit d9bc074

File tree

4 files changed

+35
-50
lines changed

4 files changed

+35
-50
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dependencies": {
5151
"@expo/vector-icons": "^10.0.6",
5252
"@react-native-community/masked-view": "0.1.5",
53+
"@react-navigation/bottom-tabs": "^5.0.0-alpha.34",
5354
"@react-navigation/native": "^5.0.0-alpha.27",
5455
"@react-navigation/stack": "^5.0.0-alpha.58",
5556
"axios": "^0.19.1",

src/navigation/Home/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const HomeNavigator = () => (
3030

3131
const HomeIcon = {
3232
tabBarIcon: ({ tintColor }) => (
33-
<Icon name="ios-home" size={40} color={tintColor} />
33+
<Icon name="ios-home" size={32} color={tintColor} />
3434
),
3535
};
3636

src/navigation/RootNavigator.js

Lines changed: 23 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
import React from 'react';
22
import { NavigationNativeContainer } from '@react-navigation/native';
3+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
34
import { createStackNavigator } from '@react-navigation/stack';
4-
import { HomeNavigator, HomeIcon } from './Home';
55
import { colors } from '../components/common/theme';
66

7-
const Stack = createStackNavigator();
7+
import { HomeNavigator, HomeIcon } from './Home';
88

9-
const RootNavigator = () => (
10-
<NavigationNativeContainer>
11-
<Stack.Navigator
12-
headerMode="none"
13-
screenOptions={{
14-
gestureEnabled: false,
15-
}}
16-
>
17-
<Stack.Screen component={HomeNavigator} />
18-
</Stack.Navigator>
19-
</NavigationNativeContainer>
20-
);
9+
const Tab = createBottomTabNavigator();
10+
const Stack = createStackNavigator();
2111

22-
/* const TabBarNavigator = createBottomTabNavigator(
23-
{
24-
Home: { screen: HomeNavigator },
25-
},
26-
{
27-
initialRouteName: 'Home',
28-
defaultNavigationOptions: () => HomeIcon,
29-
tabBarOptions: {
12+
const TabNavigator = () => (
13+
<Tab.Navigator
14+
screenOptions={() => HomeIcon}
15+
tabBarOptions={{
3016
inactiveTintColor: colors.mediumGray,
3117
showIcon: true,
3218
showLabel: false,
@@ -38,35 +24,23 @@ const RootNavigator = () => (
3824
height: 70,
3925
backgroundColor: colors.white,
4026
},
41-
},
42-
}
27+
}}
28+
>
29+
<Tab.Screen component={HomeNavigator} />
30+
</Tab.Navigator>
4331
);
4432

45-
const MainNavigator = createStackNavigator(
46-
{
47-
Home: { screen: TabBarNavigator },
48-
},
49-
{
50-
initialRouteName: 'Home',
51-
headerMode: 'none',
52-
cardStyle: { shadowColor: 'transparent' },
53-
}
33+
const RootNavigator = () => (
34+
<NavigationNativeContainer>
35+
<Stack.Navigator
36+
headerMode="none"
37+
screenOptions={{
38+
gestureEnabled: false,
39+
}}
40+
>
41+
<Stack.Screen component={TabNavigator} />
42+
</Stack.Navigator>
43+
</NavigationNativeContainer>
5444
);
5545

56-
const RootNavigator = createAppContainer(
57-
createStackNavigator(
58-
{
59-
Main: { screen: MainNavigator },
60-
},
61-
{
62-
headerMode: 'none',
63-
cardStyle: { shadowColor: 'transparent' },
64-
mode: 'modal',
65-
defaultNavigationOptions: {
66-
gesturesEnabled: false,
67-
},
68-
}
69-
)
70-
); */
71-
7246
export default RootNavigator;

0 commit comments

Comments
 (0)