-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
128 lines (119 loc) · 6.27 KB
/
App.js
File metadata and controls
128 lines (119 loc) · 6.27 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
import 'react-native-gesture-handler';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import Login from './pages/Login';
import Signup from './pages/Signup';
import Profile from './pages/Profile';
import Waiver from './pages/Waiver';
import Events from './pages/events';
import ViewEvents from './pages/ViewEvents';
import IndividualEvent from './pages/individualEvent';
import NotificationsScreen from './pages/notifications';
import ForgotPassword1 from './pages/ForgotPassword1';
import Navbar from './components/NavBar';
import CreateEventScreen from './pages/admin/createEvent';
import EditEventScreen from './pages/admin/editEvent';
import AdminEvents from './pages/admin/adminEvent';
import AdminEventDetailScreen from './pages/admin/adminIndividualEvent';
import AdminVolunteers from './pages/admin/adminVolunteers';
import VolunteerProfileAdmin from './pages/admin/VolunteerProfileAdmin';
import ArchivedEvents from './pages/admin/archivedEvents';
import { View, Text, Button } from 'react-native';
import * as Notifications from 'expo-notifications';
import { registerForPushNotificationsAsync } from './expoPushNotifications'
import React, { useState, useEffect, useRef } from 'react';
const Stack = createStackNavigator();
export default function App() {
const [expoPushToken, setExpoPushToken] = useState('');
const [initialRoute, setInitialRoute] = useState("Login");
const [notification, setNotification] = useState(false);
const notificationListener = useRef();
const responseListener = useRef();
useEffect(() => {
async function fetchData() {
await registerForPushNotificationsAsync().then(token => setExpoPushToken(token));
console.log(expoPushToken)
notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
setNotification(notification);
});
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
console.log(response);
});
// return () => {
Notifications.removeNotificationSubscription(notificationListener.current);
Notifications.removeNotificationSubscription(responseListener.current);
// };
}
fetchData().then(console.log("expo pus: " + expoPushToken));
}, []);
// persistence: getRfireeactNativePersistence(ReactNativeAsyncStorage) //async-storage in Waiver page
return (
<NavigationContainer independent={true}>
<Stack.Navigator initialRouteName={initialRoute}>
<Stack.Screen name="Login" options={{ headerShown: false, gestureEnabled: false }} >
{props => <Login {...props} expoPushToken={expoPushToken} />}
</Stack.Screen>
<Stack.Screen name="Signup" options={{ headerShown: false, gestureEnabled: false }} >
{props => <Signup {...props} expoPushToken={expoPushToken} />}
</Stack.Screen>
<Stack.Screen name="Profile" component={Profile} options={{ animationEnabled: false, headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="Volunteers" component={AdminVolunteers} options={{ animationEnabled: false, headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="Notifications" component={NotificationsScreen} options={{ animationEnabled: false, headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="Waiver" component={Waiver} options={{ headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="Events" component={Events} options={{ headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="ViewEvents" component={ViewEvents} options={{ headerShown: false, gestureEnabled: false }} />
<Stack.Screen name="IndividualEvent" component={IndividualEvent} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 100},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20},
headerTitle: "Event",
headerTintColor: "white"
}}/>
<Stack.Screen name="ForgotPassword1" component={ForgotPassword1} options={{ headerShown: false }} />
<Stack.Screen name="AdminEvents" component={AdminEvents} options={{ animationEnabled: false, headerShown: false, gestureEnabled: false}} />
<Stack.Screen name="CreateEvent" component={CreateEventScreen} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 100},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20, fontWeight: "bold"},
headerTitle: "Create Event",
headerTintColor: "white"
}}/>
<Stack.Screen name="EditEvent" component={EditEventScreen} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 100},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20},
headerTitle: "Edit Event",
headerTintColor: "white"
}}/>
<Stack.Screen name="AdminIndividualEvent" component={AdminEventDetailScreen} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 100},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20},
headerTitle: "Event",
headerTintColor: "white"
}}/>
<Stack.Screen name="AdminVolunteers" component={AdminVolunteers} options={{ headerShown: false }} />
<Stack.Screen name="VoluteerProfile" component={VolunteerProfileAdmin} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 100},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20},
headerTitle: "Volunteer Profile",
headerTintColor: "white"
}}/>
<Stack.Screen name="ArchivedEvents" component={ArchivedEvents} options={
{ headerShown: true,
headerStyle: {backgroundColor: "#6A466C", height: 110},
headerBackTitle: " ",
headerTitleStyle: {color: "#fff", fontSize: 20},
headerTitle: "Archived Events",
headerTintColor: "white"
}}/>
</Stack.Navigator>
</NavigationContainer>
);
}