-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
46 lines (35 loc) · 1.56 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
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import IntroPage from "./app/screens/Intro";
import { useEffect, useState } from "react";
import AsyncStorage from '@react-native-async-storage/async-storage';
import ListScreen from "./app/screens/ListScreen";
import PasswordTouched from "./app/components/PasswordTouched";
import PasswordProvider from "./app/context/PasswordProvider";
import * as SplashScreen from 'expo-splash-screen';
SplashScreen.preventAutoHideAsync();
setTimeout(SplashScreen.hideAsync, 5000)
const Stack = createNativeStackNavigator();
export default function App() {
const [user, setUser] = useState({})
const [runningFirstTime, setRunningFirstTime] = useState(false)
const findUser = async () => {
const result = await AsyncStorage.getItem('user')
if (result === null) return setRunningFirstTime(true)
setUser(JSON.parse(result))
setRunningFirstTime(false)
}
useEffect(() => {
findUser()
}, [])
const RenderListScreen = (props) => <ListScreen {...props} user={user} />
if (runningFirstTime) return <IntroPage onFinish={findUser} />
return <NavigationContainer>
<PasswordProvider>
<Stack.Navigator screenOptions={{ headerTitle: "", headerTransparent: true }}>
<Stack.Screen component={RenderListScreen} name="ListScreen" options={{ headerShown: false }} />
<Stack.Screen component={PasswordTouched} name="PasswordTouched" />
</Stack.Navigator>
</PasswordProvider>
</NavigationContainer>
}