-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathApp.tsx
More file actions
50 lines (44 loc) · 1.43 KB
/
Copy pathApp.tsx
File metadata and controls
50 lines (44 loc) · 1.43 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
// App.tsx
import React, { useEffect, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { StatusBar, ActivityIndicator, View } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
import AppNavigator from './src/navigation/AppNavigator';
import { AuthProvider } from './src/context/AuthContext';
import Colors from '@/utils/constants/colors';
const App = () => {
const [isLoading, setIsLoading] = useState(true);
const [isFirstLaunch, setIsFirstLaunch] = useState<boolean | null>(null);
useEffect(() => {
const init = async () => {
try {
const hasLaunched = await AsyncStorage.getItem('hasLaunched');
setIsFirstLaunch(hasLaunched === null);
} catch (e) {
console.log('Init error:', e);
setIsFirstLaunch(false);
} finally {
setIsLoading(false);
}
};
init();
}, []);
if (isLoading || isFirstLaunch === null) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<ActivityIndicator size="large" color={Colors.primary} />
</View>
);
}
return (
<>
<StatusBar barStyle="dark-content" backgroundColor={Colors.background} />
<AuthProvider>
<NavigationContainer>
<AppNavigator isFirstLaunch={isFirstLaunch} />
</NavigationContainer>
</AuthProvider>
</>
);
};
export default App;