-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
108 lines (96 loc) · 3.36 KB
/
App.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
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
import React, { useEffect, useState ,Component} from 'react';
import {StyleSheet} from 'react-native';
import todoo from './screens/todoo';
import Home from './screens/Home';
import leaderboard from './screens/leaderboard';
import login from './screens/login';
import Registration from './screens/Registration';
import profile from './screens/profile';
import player from './screens/player';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
import EvilIconsIcon from "react-native-vector-icons/EvilIcons";
//import { set } from 'react-native-reanimated';
import { firebase } from './screens/config';
const Stack = createStackNavigator()
const Tab = createMaterialBottomTabNavigator()
function Sakar(){
return(
<Tab.Navigator barStyle = {{ backgroundColor : '#481480' }}>
<Tab.Screen
name = 'Home' component = {Home} options={{
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor }) => (
<EvilIconsIcon name="tag" style={styles.icon} color={tintColor} size={25} />
)}} />
<Tab.Screen name='todoo' component={todoo} options={{
tabBarLabel: 'To Do',
tabBarIcon: ({ tintColor }) => (
<EvilIconsIcon name="pencil" style={styles.icon} color={tintColor} size={25} />
)}}/>
<Tab.Screen name='Leaderboard' component={ leaderboard } options={{
tabBarLabel: 'Leaderboard',
tabBarIcon: ({ tintColor }) => (
<EvilIconsIcon name="trophy" style={styles.icon} color={tintColor} size={25} />
)}}/>
<Tab.Screen
name = 'profile' component = {profile} options={{
tabBarLabel: 'Profile',
tabBarIcon: ({ tintColor }) => (
<EvilIconsIcon name="user" style={styles.icon} color={tintColor} size={25} />
)}} />
</Tab.Navigator>
);
}
export default function App() {
const [loading, setLoading] = useState(true)
const [user, setUser] = useState(null)
useEffect(() => {
const usersRef = firebase.firestore().collection('users');
firebase
.auth().onAuthStateChanged((user) => {
if(user){
usersRef
.doc(user.uid)
.get()
.then((document) => {
const userData = document.data()
setLoading(false)
setUser(userData)
//console.log(userData);
})
.catch((error) => {
setLoading(false)
});
} else {
setLoading(false)
}
})
})
return (
<NavigationContainer>
<Stack.Navigator>
{ user?(
<>
<Stack.Screen name = 'Sakar' component = {Sakar} options ={{headerShown:false}}/>
</>
):
(
<>
<Stack.Screen name= 'Registration' component={Registration} options ={{headerShown:false}}/>
</>
)}
<Stack.Screen name = 'Welcome to Sakar!' component = { login} options ={{headerShown:false}}/>
<Stack.Screen name = 'player' component = {player} options ={{headerShown:false}}/>
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
icon: {
color: "white",
justifyContent:'center',
alignSelf: "center"
},
});