This repository has been archived by the owner on Apr 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
70 lines (64 loc) · 1.83 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { Component } from "react";
import { StyleSheet, View, ActivityIndicator } from "react-native";
import AsyncStorage from "@react-native-community/async-storage";
import AppIntroSlider from "react-native-app-intro-slider";
import MainNavigator from "./src/navigations";
import IntroSlides from "./src/components/introSlides";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
isLoading: true,
showRealApp: false
};
}
_onDone = () => {
// User finished the introduction. Show real app through
// navigation or simply by controlling state
this.setState({ showRealApp: true });
};
_onSkip = () => {
this.setState({ showRealApp: true });
};
componentDidMount() {
AsyncStorage.getItem("@alreadyUsed").then(value => {
console.log("Already used", value);
if (value === null) {
AsyncStorage.setItem("@alreadyUsed", "true");
AsyncStorage.setItem("@lastUpdated", new Date().toLocaleDateString());
this.setState({ isLoading: false });
} else {
console.log(AsyncStorage.getItem("@lastUpdated"));
this.setState({ showRealApp: true, isLoading: false });
}
});
}
render() {
//console.log(this.state);
if (this.state.isLoading) {
return (
<View style={styles.mainContainer}>
<ActivityIndicator size="large" animating={this.state.isLoading} />
</View>
);
} else {
if (this.state.showRealApp) {
return <MainNavigator />;
} else {
return (
<AppIntroSlider
slides={IntroSlides}
onDone={this._onDone}
showSkipButton={true}
onSkip={this._onSkip}
/>
);
}
}
}
}
const styles = StyleSheet.create({
maincontainer: {
flex: 1
}
});