-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
114 lines (102 loc) · 2.91 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
109
110
111
112
113
114
import React, { useState, useEffect } from "react";
import { View, Text } from "react-native";
import { createStackNavigator } from "@react-navigation/stack";
import Login from "./screens/Login";
import * as Font from 'expo-font';
import HomeLoader from "./components/HomeLoader";
import Tabs from './navigation/tabs'
import { NavigationContainer } from "@react-navigation/native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import axios from "axios";
const App = () => {
const Stack = createStackNavigator();
const [isLoading, setIsLoading] = useState(true);
const [checker, setChecker] = useState("Login");
const [loaded] = Font.useFonts({
'Courgette': require('./assets/fonts/Courgette.ttf'),
'Tangerine': require('./assets/fonts/Tangerine.ttf'),
'Monoton': require('./assets/fonts/Monoton.ttf'),
});
useEffect(() => {
const fetchData = async () => {
const storedValue =
(await AsyncStorage.getItem("@Annoncement:Annoncer")) || "null";
const id = (await AsyncStorage.getItem("Annoncement:Annoncer")) || "null";
if (storedValue !== "null" && id !== "null") {
try{
let checking=await axios.post("YOUR BACK-END",{
id:id,
})
if(Object.values(checking.data).length>=1)
{
setChecker("Home");
}
else{
setChecker("Login");
}
}catch(err){console.log(err)}
} else {
setChecker("Login");
}
setIsLoading(false);
};
fetchData();
const timer = setTimeout(() => {
setIsLoading(false);
}, 1000);
function loaders(){
clearTimeout(timer);
}
loaders()
}, []);
return (
<>
{isLoading || !loaded ? (
<View
style={{
height: "100%",
justifyContent: "center",
alignItems: "center",
backgroundColor: "black",
}}
>
<Text style={{fontSize: 35, color: "white", fontWeight: "900" }}>
Annoncement
</Text>
<Text style={{ fontSize: 35, color: "white", fontWeight: "900" }}>
Annoncer
</Text>
<View style={{
marginTop: 150,
width: 50,
height: 50,
}}>
<HomeLoader />
</View>
</View>
) : (
<NavigationContainer >
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
initialRouteName={checker}
>
<Stack.Screen
name="Home"
component={Tabs}
options={{ headerShown:false,
}}
/>
<Stack.Screen
name="Login"
options={{ headerShown: false }}
component={Login}
/>
</Stack.Navigator>
</NavigationContainer>
)}
</>
);
};
export default App;