-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
53 lines (46 loc) · 1.39 KB
/
App.tsx
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
import {StatusBar} from 'expo-status-bar';
import React, {useState, useEffect} from 'react';
import {ActivityIndicator, StyleSheet, View} from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage'
import OnBoarding from "./src/screens/OnBoarding";
import Home from "./src/screens/Home";
const Loading = () => {
return (
<View>
<ActivityIndicator size='large' color='#493d8a' />
</View>
)
}
export default function App() {
const [loading, setLoading] = useState(true);
const [viewedOnBoarding, setViewedOnBoarding] = useState(false);
const checkOnBoarding = async () => {
try {
const value = await AsyncStorage.getItem('@viewedOnBoarding')
if (value !== null) {
setViewedOnBoarding(true)
}
} catch (err) {
console.log('Error @checkOnBoarding: ', err);
} finally {
setLoading(false)
}
}
useEffect(() => {
checkOnBoarding().then()
}, [])
return (
<View style={styles.container}>
{loading ? <Loading/> : viewedOnBoarding ? <Home/> : <OnBoarding/>}
<StatusBar style="auto"/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});