-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.jsx
95 lines (84 loc) · 3.2 KB
/
App.jsx
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
import React, { useState } from 'react';
import { View } from 'react-native';
// import { StyleSheet, Text, View } from 'react-native';
import { Provider as PaperProvider } from 'react-native-paper';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
// import { createNativeStackNavigator } from '@react-navigation/native-stack';
import Icon from 'react-native-vector-icons/FontAwesome';
import LoginPage from './screens/LoginPage';
import HomePage from './screens/HomePage';
import RentPage from './screens/RentPage';
import SellPage from './screens/SellPage';
import ShopPage from './screens/ShopPage';
import PersonalPage from './screens/PersonalPage';
import firebase from './firebase';
const { auth } = firebase;
// const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();
function MainApp() {
return (
<NavigationContainer>
<Tab.Navigator
initialRouteName="首頁"
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
const rn = route.name;
if (rn === '首頁') {
iconName = focused ? 'home' : 'home';
} else if (rn === '收購/租借') {
iconName = focused ? 'shopping-bag' : 'shopping-bag';
} else if (rn === '發文') {
iconName = focused ? 'plus' : 'plus';
} else if (rn === '購買') {
iconName = focused ? 'shopping-cart' : 'shopping-cart';
} else if (rn === '個人') {
iconName = focused ? 'user' : 'user';
}
return <Icon name={iconName} size={size} color={color} />;
},
activeTintColor: '#E0E0E0',
inactiveTintColor: '#454545',
labelStyle: { paddingBottom: 10, fontSize: 13 },
style: { padding: 10, height: 60 }
,
})}
>
<Tab.Screen options={{ headerShown: false }} name="首頁" component={HomePage} />
<Tab.Screen options={{ headerShown: false }} name="收購/租借" component={RentPage} />
<Tab.Screen options={{ headerShown: false }} name="發文" component={SellPage} />
<Tab.Screen options={{ headerShown: false }} name="購買" component={ShopPage} />
<Tab.Screen options={{ headerShown: false }} name="個人" component={PersonalPage} />
</Tab.Navigator>
</NavigationContainer>
);
}
export default function App() {
const [currentUser, setcurrentUser] = useState();
auth.onAuthStateChanged((user) => {
setcurrentUser(user);
});
if (currentUser === undefined) {
return (<View />);
}
return (
<PaperProvider>
{ currentUser ? <MainApp /> : <LoginPage />}
</PaperProvider>
// <NavigationContainer>
// <Stack.Navigator>
// <Stack.Screen options={{ headerShown: false }} name="Login" component={LoginPage} />
// <Stack.Screen name="Home" component={HomePage} />
// </Stack.Navigator>
// </NavigationContainer>
);
}
// const styles = StyleSheet.create({
// container: {
// flex: 1,
// backgroundColor: '#fff',
// alignItems: 'center',
// justifyContent: 'center',
// },
// });