-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.js
87 lines (78 loc) · 2.62 KB
/
App.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from 'react';
import { StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Home from '@screens/Home';
import { StatusBar } from 'react-native';
import Search from '@screens/Search';
import Favorites from '@screens/Favorites';
import Profile from '@screens/Profile';
import Product from '@screens/Product';
const RootStack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
const App = () => {
return (
<SafeAreaProvider>
<StatusBar backgroundColor={'white'} barStyle={'dark-content'} />
<NavigationContainer>
<RootStackScreens />
</NavigationContainer>
</SafeAreaProvider>
);
};
const RootStackScreens = () => (
<RootStack.Navigator screenOptions={{ headerShown: false }}>
<RootStack.Screen name="HomeTabs" component={HomeTabs} />
<RootStack.Screen name="Product" component={Product} />
</RootStack.Navigator>
);
const HomeTabs = () => {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
headerShown: false,
tabBarShowLabel: false,
tabBarStyle: styles.tabBarStyle,
tabBarIcon: ({ focused, color }) => {
return <TabIcon name={route.name} focused={focused} color={color} />;
},
tabBarActiveTintColor: '#000000',
tabBarInactiveTintColor: '#C7C6CC',
})}>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="Search" component={Search} />
<Tab.Screen name="Favorites" component={Favorites} />
<Tab.Screen name="Profile" component={Profile} />
</Tab.Navigator>
);
};
const TabIcon = ({ name, focused, color }) => {
const iconName = getIconName(name, focused);
return <Ionicons name={iconName} size={22} color={color} />;
};
const getIconName = (name, focused) => {
switch (name) {
case 'Home':
return focused ? 'md-home-sharp' : 'md-home-outline';
case 'Search':
return focused ? 'md-search' : 'md-search-outline';
case 'Favorites':
return focused ? 'ios-heart' : 'ios-heart-outline';
case 'Profile':
return focused ? 'person-circle' : 'person-circle-outline';
default:
return 'help-sharp';
}
};
const styles = StyleSheet.create({
tabBarStyle: {
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
height: 70,
position: 'absolute',
},
});
export default App;