forked from court-me/court-me
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
85 lines (68 loc) · 1.84 KB
/
App.tsx
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
import "./firebaseConfig";
import React from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { useAuth } from "./src/contexts/AuthContext";
import { AuthProvider } from "./src/contexts/AuthContext";
import HomeScreen from "./screens/HomeScreen";
import LoginScreen from "./screens/LoginScreen";
const Stack = createNativeStackNavigator();
const AppNavigator = () => {
const { currentUser } = useAuth();
return (
<AuthProvider>
<NavigationContainer>
<Stack.Navigator>
{currentUser ? (
<Stack.Screen name="Home" component={HomeScreen} />
) : (
<Stack.Screen name="Login" component={LoginScreen} />
)}
</Stack.Navigator>
</NavigationContainer>
</AuthProvider>
);
};
export default AppNavigator;
/*
import Auth, {AuthEventEmitter, AuthEvents} from 'react-native-firebaseui-auth';
...
componentDidMount() {
this.eventListener = AuthEventEmitter.addListener(
AuthEvents.AUTH_STATE_CHANGED,
event => {
console.log('user:', event.user);
}
);
}
componentWillUnmount() {
this.eventListener.remove(); //Removes the listener
}
...
const config = {
providers: [
'anonymous',
'facebook',
'google',
'email',
'phone',
'apple',
'yahoo',
'github',
'twitter',
'microsoft'
],
tosUrl: 'https://example.com/tos.htm',
privacyPolicyUrl: 'https://example.com/privacypolicy.htm',
};
Auth.signIn(config)
.then(user => console.log(user))
.catch(err => console.log(err));
...
Auth.getCurrentUser().then(user => console.log(user));
...
Auth.signOut().then(res => console.log(res));
...
Auth.deleteUser().then(res => console.log(res));
...
*/