-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
73 lines (64 loc) · 1.81 KB
/
Copy pathApp.js
File metadata and controls
73 lines (64 loc) · 1.81 KB
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
import { StatusBar } from 'expo-status-bar';
import React, { useState, useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaView, StatusBar as RNStatusBar, StyleSheet, View, Image, Dimensions } from 'react-native';
import { enableScreens } from 'react-native-screens';
import { AuthProvider, useAuth } from './app/context/AuthContext';
import { LanguageProvider } from './app/context/LanguageContext';
import TabNavigator from './app/navigation/TabNavigator';
import LoginScreen from './app/screens/LoginScreen';
enableScreens(false);
const { width, height } = Dimensions.get('window');
function AppContent() {
const [isShowSplash, setIsShowSplash] = useState(true);
const { user } = useAuth();
useEffect(() => {
const timer = setTimeout(() => {
setIsShowSplash(false);
}, 3000);
return () => clearTimeout(timer);
}, []);
if (isShowSplash) {
return (
<View style={styles.splashContainer}>
<StatusBar style="light" />
<Image
source={require('./assets/splash_logo.png')}
style={styles.splashImage}
resizeMode="cover"
/>
</View>
);
}
return (
<SafeAreaView style={styles.container}>
<RNStatusBar barStyle="dark-content" backgroundColor="#fff" />
<NavigationContainer>
{user ? <TabNavigator /> : <LoginScreen />}
</NavigationContainer>
</SafeAreaView>
);
}
export default function App() {
return (
<LanguageProvider>
<AuthProvider>
<AppContent />
</AuthProvider>
</LanguageProvider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
splashContainer: {
flex: 1,
backgroundColor: '#fff',
},
splashImage: {
width: '100%',
height: '100%',
},
});