forked from NCUAppTeam/NCU-App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
150 lines (143 loc) · 4.3 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import React, { useState } from 'react';
import { View } from 'react-native';
import firebase from 'firebase';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Provider as PaperProvider } from 'react-native-paper';
import { Icon, NativeBaseProvider } from 'native-base';
import AwesomeIcon from '@expo/vector-icons/FontAwesome5';
import { MaterialCommunityIcons, Ionicons } from '@expo/vector-icons';
import AuthScreen from './screens/Auth';
import DashboardScreen from './screens/Dashboard';
import CalendarScreen from './screens/Calendar';
import MapScreen from './screens/Map';
import SaleScreen from './screens/Sale';
import EventScreen from './screens/Event';
const firebaseConfig = {
apiKey: 'AIzaSyA8GH6yj1i4gJM0H_ZTsurYG3Dqn4-nIS8',
authDomain: 'ncu-app-test.firebaseapp.com',
projectId: 'ncu-app-test',
storageBucket: 'ncu-app-test.appspot.com',
messagingSenderId: '739839700130',
appId: '1:739839700130:web:37591d0118a440488cfbfb',
};
const Tab = createBottomTabNavigator();
function MainApp() {
return (
<NativeBaseProvider>
<NavigationContainer>
<Tab.Navigator
initialRouteName="Dashboard"
screenOptions={{
tabBarStyle: { height: '8%' },
}}
tabBarOptions={{
activeTintColor: '#E5EBF1',
inactiveTintColor: '#28527A',
activeBackgroundColor: '#28527A',
inactiveBackgroundColor: '#E5EBF1',
}}
>
<Tab.Screen
name="Dashboard"
component={DashboardScreen}
options={{
headerShown: false,
tabBarLabel: '首頁',
tabBarIcon: ({ focused }) => (
<Icon
as={MaterialCommunityIcons}
name="home-outline"
color={focused ? '#E5EBF1' : '#28527A'}
/>
),
}}
/>
<Tab.Screen
name="Calendar"
component={CalendarScreen}
options={{
headerShown: false,
tabBarLabel: '行事曆',
tabBarIcon: ({ focused }) => (
<Icon
as={MaterialCommunityIcons}
name="calendar-month"
color={focused ? '#E5EBF1' : '#28527A'}
/>
),
}}
/>
<Tab.Screen
name="Event"
component={EventScreen}
options={{
headerShown: false,
tabBarLabel: '活動',
tabBarIcon: ({ focused }) => (
<Icon
as={Ionicons}
name="game-controller-outline"
color={focused ? '#E5EBF1' : '#28527A'}
/>
),
}}
/>
<Tab.Screen
name="Map"
component={MapScreen}
options={{
headerShown: false,
tabBarLabel: '地圖',
tabBarIcon: ({ focused }) => (
<Icon
as={MaterialCommunityIcons}
name="map-outline"
color={focused ? '#E5EBF1' : '#28527A'}
/>
),
}}
/>
<Tab.Screen
name="Sales"
component={SaleScreen}
options={{
headerShown: false,
tabBarLabel: '拍賣',
tabBarIcon: ({ focused }) => (
<Icon
as={MaterialCommunityIcons}
name="cart-outline"
color={focused ? '#E5EBF1' : '#28527A'}
/>
),
}}
/>
</Tab.Navigator>
</NavigationContainer>
</NativeBaseProvider>
);
}
export default function App() {
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
} else {
firebase.app();
}
const [auth, setAuth] = useState();
firebase.auth().onAuthStateChanged((user) => {
setAuth(user);
});
if (auth === undefined) {
return (<View />);
}
return (
<PaperProvider
settings={{
icon: (props) => <AwesomeIcon {...props} />,
}}
>
{ auth ? <MainApp /> : <AuthScreen />}
</PaperProvider>
);
}