-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppNavigator.js
More file actions
135 lines (126 loc) · 5.24 KB
/
AppNavigator.js
File metadata and controls
135 lines (126 loc) · 5.24 KB
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
129
130
131
132
133
134
135
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import ListSanPham from "./Screen/ListSanPham";
import ChiTietSanPham from "./Screen/ChiTietSanPham";
import Home from './Screen/Home';
import DanhMuc from './Screen/Danhmuc';
import Cart from './Screen/Cart';
import User from './Screen/User';
import Banner from './Screen/Banner';
import Login from './Screen/Login';
import Register from './Screen/Register';
import EditUser from './Screen/EditUser';
import Splash from './Screen/Splash';
import SearchResults from './Screen/SearchResults';
import DoiMatKhau from './Screen/DoiMatKhau';
import ThanhToan from './Screen/ThanhToan';
const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
import * as Animatable from 'react-native-animatable';
import React, { useRef, useEffect } from 'react';
import { View, TouchableWithoutFeedback } from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
function TabButton({ onPress, accessibilityState, children }) {
const viewRef = useRef(null);
useEffect(() => {
if (accessibilityState.selected) {
viewRef.current.animate({ 0: { scale: .5,rotate:'0deg' }, 1: { scale: 1.5,rotate:'360deg' } });
} else {
viewRef.current.animate({0: { scale: .5,rotate:'360deg' }, 1: { scale: 1.5,rotate:'0deg' } });
}
}, [accessibilityState.selected]);
return (
<TouchableWithoutFeedback onPress={onPress} style={{ flex: 1 }}>
<Animatable.View ref={viewRef} duration={500} style={{ flex: 1 }}>
{children}
</Animatable.View>
</TouchableWithoutFeedback>
);
}
function TabNavigator() {
return (
<Tab.Navigator
screenOptions={{
tabBarStyle: {
height: 50,
position: 'absolute',
bottom: 10,
left: 10,
right: 10,
borderRadius: 50,
}
}}
>
<Tab.Screen
name="Home"
component={ListSanPham}
options={{
tabBarShowLabel: false,
title: 'Chào mừng bạn',
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="home" color={color} size={20} />
),
tabBarButton: (props) => <TabButton {...props} />
}}
/>
<Tab.Screen
name="DanhMuc"
component={DanhMuc}
options={{
tabBarShowLabel: false,
title: 'Danh Mục',
tabBarIcon: ({ color }) => (
<Icon name="th-large" size={18} color={color} />
),
tabBarButton: (props) => <TabButton {...props} />
}}
/>
<Tab.Screen
name="Cart"
component={Cart}
options={{
tabBarShowLabel: false,
title: 'Cart',
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="cart" color={color} size={20} />
),
tabBarButton: (props) => <TabButton {...props} />
}}
/>
<Tab.Screen
name="User"
component={User}
options={{
tabBarShowLabel: false,
title: 'User',
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="account" color={color} size={20} />
),
tabBarButton: (props) => <TabButton {...props} />
}}
/>
</Tab.Navigator>
);
}
export default function AppNavigator() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Splash'>
<Stack.Screen name="Splash" component={Splash} options={{ headerShown: false }} />
<Stack.Screen name="Login" component={Login} options={{ headerShown: false }}/>
<Stack.Screen name="Register" component={Register} />
<Stack.Screen name="EditUser" component={EditUser} options={{
title: 'Cập nhật thông tin'
}} />
<Stack.Screen name="Home" component={TabNavigator} options={{ headerShown: false }} />
<Stack.Screen name="ChiTietSanPham" component={ChiTietSanPham} />
<Stack.Screen name="SearchResults" component={SearchResults} />
<Stack.Screen name="DoiMatKhau" component={DoiMatKhau} />
<Stack.Screen name="ThanhToan" component={ThanhToan} />
</Stack.Navigator>
</NavigationContainer>
);
}