-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
100 lines (89 loc) · 2.85 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
import {StyleSheet, View,} from 'react-native';
import {NavigationContainer,} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {StatusBar} from 'expo-status-bar';
import * as SplashScreen from 'expo-splash-screen'
import Search from './Search';
import {Variables} from './assets/variables';
import * as ServerStartup from './utils/ServerStartup';
import {useEffect, useState} from "react";
const Stack = createNativeStackNavigator();
let variableClass = new Variables();
variableClass.mode('white')
let colors = variableClass.colors
SplashScreen.preventAutoHideAsync().catch(() => {});
export default function App() {
const [serverUp, setServerUp] = useState(false)
// checks if server is up and running
useEffect(() => {
(async () => {
try {
const check = await ServerStartup.check()
console.log(check)
if (check.status === 200) {
setServerUp(true)
await SplashScreen.hideAsync();
}
else{
const interval = setInterval(async () => {
const check = await ServerStartup.check()
console.log(check)
if (check.status === 200) {
clearInterval(interval)
setServerUp(true)
await SplashScreen.hideAsync();
}
}, 5000)
}
} catch (e) {
console.log(e)
}
})();
}, [])
if (!serverUp) {
return null
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={({navigation}) => ({
headerStyle: {backgroundColor: '#DD5353'},
headerTintColor: colors.white,
contentStyle: {backgroundColor: colors.white},
headerTitleAlign: 'center',
headerTitleStyle: {fontSize: 40, fontWeight: 'bold', color: 'white'},
headerTitle: 'সদাই',
})}
>
<Stack.Screen name='Home' component={Home}/>
</Stack.Navigator>
<StatusBar style='light'/>
</NavigationContainer>
);
}
const Home = () => {
return (
<>
<View style={styles.container}>
<Search/>
</View>
</>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'flex-end',
marginBottom: 1,
},
brand: {
fontSize: 35,
color: colors.black
},
add_item_button_text: {
color: colors.black,
fontWeight: '400',
fontSize: 20,
}
});