-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
128 lines (110 loc) · 3.35 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React, { useEffect, useState } from 'react';
import { StyleSheet } from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { NavigationContainer } from '@react-navigation/native';
import { Ionicons } from '@expo/vector-icons';
import * as Haptics from 'expo-haptics';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
import Home from './screens/Home';
import Cart from './screens/Cart';
import Profile from './screens/Profile';
import Setting from './screens/setting';
const Tab = createBottomTabNavigator();
const HomeStack = createStackNavigator();
const CartStack = createStackNavigator();
const ProfileStack = createStackNavigator();
const SettingStack = createStackNavigator(); // tạo StackNavigator cho màn hình mới
const HomeStackScreen = () => (
<HomeStack.Navigator>
<HomeStack.Screen name="Home" component={Home} />
</HomeStack.Navigator>
);
const CartStackScreen = () => (
<CartStack.Navigator>
<CartStack.Screen name="Cart" component={Cart} />
</CartStack.Navigator>
);
const ProfileStackScreen = () => (
<ProfileStack.Navigator>
<ProfileStack.Screen name="Profile" component={Profile} />
</ProfileStack.Navigator>
);
const MyNewScreenStackScreen = () => (
<SettingStack.Navigator>
<SettingStack.Screen name="Setting" component={Setting} />
</SettingStack.Navigator>
);
const tabStyles = StyleSheet.create({
tabBarIcon: {
marginBottom: -3,
},
});
export default function App(): JSX.Element {
const handleHapticFeedback = () => {
Haptics.selectionAsync();
};
return (
<NavigationContainer>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = focused ? 'home' : 'home-outline';
} else if (route.name === 'Cart') {
iconName = focused ? 'cart' : 'cart-outline';
} else if (route.name === 'Profile') {
iconName = focused ? 'person' : 'person-outline';
}
return (
<Ionicons
name={iconName}
size={size}
color={color}
style={tabStyles.tabBarIcon}
/>
);
},
})}
>
<Tab.Screen
name="Home"
component={Home}
options={{
tabBarLabel: 'Home',
tabBarActiveTintColor: 'tomato',
tabBarInactiveTintColor: 'gray',
}}
listeners={{
tabPress: handleHapticFeedback,
}}
/>
<Tab.Screen
name="Cart"
component={Cart}
options={{
tabBarLabel: 'Cart',
tabBarActiveTintColor: 'tomato',
tabBarInactiveTintColor: 'gray',
}}
listeners={{
tabPress: handleHapticFeedback,
}}
/>
<Tab.Screen
name="Profile"
component={Profile}
options={{
tabBarLabel: 'Profile',
tabBarActiveTintColor: 'tomato',
tabBarInactiveTintColor: 'gray',
}}
listeners={{
tabPress: handleHapticFeedback,
}}
/>
</Tab.Navigator>
</NavigationContainer>
);
}