-
Notifications
You must be signed in to change notification settings - Fork 0
/
StackNavigation.js
64 lines (56 loc) · 2.38 KB
/
StackNavigation.js
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
import React, { useEffect } from 'react'
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomeScreen from './screens/HomeScreen';
import ChatScreen from './screens/ChatScreen';
import LoginScreen from './screens/LoginScreen';
import useAuth from './hooks/useAuth';
import ModalScreen from './screens/ModalScreen';
import MatchedScreen from './screens/MatchedScreen';
import MessageScreen from './screens/MessageScreen';
import * as Notifications from 'expo-notifications'
import { useNotifications } from './hooks/useNotifications';
const Stack = createNativeStackNavigator();
const StackNavigation = () => {
const { user } = useAuth();
const { registerForPushNotificationsAsync, handleNotificationResponse } = useNotifications();
useEffect(() => {
//registerForPushNotificationsAsync().then((response) => { console.log(response) })
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: true,
}),
});
const responseListener = Notifications.addNotificationResponseReceivedListener(handleNotificationResponse);
return () => {
if (responseListener) Notifications.removeNotificationSubscription(responseListener);
}
}, [])
return (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
{user ? (
<>
<Stack.Group>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Chat" component={ChatScreen} />
<Stack.Screen name="Message" component={MessageScreen} />
</Stack.Group>
<Stack.Group screenOptions={{ presentation: "modal" }}>
<Stack.Screen name="Modal" component={ModalScreen} />
</Stack.Group>
<Stack.Group screenOptions={{ presentation: "transparentModal" }}>
<Stack.Screen name="Match" component={MatchedScreen} />
</Stack.Group>
</>
) :
<Stack.Screen name="Login" component={LoginScreen} />
}
</Stack.Navigator>
)
}
export default StackNavigation