-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
54 lines (46 loc) · 1.27 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
import { StatusBar } from 'expo-status-bar';
import React, {useState, useEffect} from 'react';
import { ActivityIndicator, StyleSheet, Text, View } from 'react-native';
import Onboarding from './src/screens/Onboarding';
import HomeScreen from './src/screens/HomeScreen';
import AsyncStorage from '@react-native-async-storage/async-storage';
const Loading = () => {
return (
<View>
<ActivityIndicator size="large" />
</View>
);
};
export default 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();
},[])
return (
<View style={styles.container}>
{loading ? <Loading/> : viewedOnboarding ? <HomeScreen/> : <Onboarding/> }
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});