This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
168 lines (153 loc) · 5.09 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import React from 'react';
import { Animated, Image, Platform, StatusBar, StyleSheet, View } from 'react-native';
import { Asset, Font, Icon, SplashScreen } from 'expo';
import AppNavigator from './navigation/AppNavigator';
console.disableYellowBox = true;
export default class App extends React.Component {
state = {
isLoadingComplete: false,
splashAnimation: new Animated.Value(0),
splashAnimationComplete: false,
};
componentDidMount() {
SplashScreen.preventAutoHide();
this._loadAsync();
}
_loadAsync = async () => {
try {
await this._loadResourcesAsync();
} catch (e) {
this._handleLoadingError(e);
} finally {
this._handleFinishLoading();
}
};
render() {
if (!this.state.isLoadingComplete) {
return <View />;
}
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
{this._maybeRenderLoadingImage()}
</View>
);
}
_maybeRenderLoadingImage = () => {
if (this.state.splashAnimationComplete) {
return null;
}
return (
<Animated.View
style={{
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#fff',
opacity: this.state.splashAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
}),
}}>
<Animated.Image
source={require('./assets/images/splash.png')}
style={{
width: undefined,
height: undefined,
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
resizeMode: 'cover',
transform: [
{
scale: this.state.splashAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 4],
}),
},
],
}}
onLoadEnd={this._animateOut}
/>
</Animated.View>
);
};
_animateOut = () => {
SplashScreen.hide();
Animated.timing(this.state.splashAnimation, {
toValue: 1,
duration: 1000,
useNativeDriver: true,
}).start(() => {
this.setState({ splashAnimationComplete: true });
});
};
_loadResourcesAsync = async () => {
return Promise.all([
Asset.loadAsync([
/* appp assets */
require('./assets/images/splash.png'),
require('./assets/images/logos/CrushIt_LogoV2small.png'),
require("./assets/images/coin.png"),
/* credit card debt 1 */
require("./assets/images/credit-card-debt/ready.gif"),
require("./assets/images/credit-card-debt/good-work.gif"),
/* credit card debt 2*/
require("./assets/images/credit-card-debt/dwight.gif"),
require("./assets/images/credit-card-debt/minion.gif"),
require("./assets/images/credit-card-debt/kanye.gif"),
/* credit card debt 3*/
require("./assets/images/credit-card-debt/dog.gif"),
require("./assets/images/credit-card-debt/im-rich.gif"),
require("./assets/images/credit-card-debt/poor.gif"),
require("./assets/images/credit-card-debt/bear.gif"),
/*Partner Screen */
require("./assets/images/partners/amazon.jpg"),
require("./assets/images/partners/grubhub.jpg"),
require("./assets/images/partners/lyft.png"),
require("./assets/images/partners/starbucks.jpg"),
require("./assets/images/partners/target.jpg"),
require("./assets/images/partners/urban.png"),
require("./assets/images/credit-card-debt/im-watching-you.gif"),
require("./assets/images/credit-card-debt/cap.png"),
require("./assets/images/credit-card-debt/shit.png"),
require("./assets/images/credit-card-debt/interest.png"),
require("./assets/images/credit-card-debt/woman-tipping-hand.png"),
require("./assets/images/credit-card-debt/secret.png"),
require("./assets/images/credit-card-debt/impoor.gif"),
require("./assets/images/credit-card-debt/shrug.png"),
require("./assets/images/credit-card-debt/good-work.gif"),
require("./assets/images/credit-card-debt/watchout.png"),
require("./assets/images/credit-card-debt/apr.png"),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Icon.Ionicons.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
}),
]);
};
_handleLoadingError = error => {
// In this case, you might want to report the error to your error
// reporting service, for example Sentry
console.warn(error);
};
_handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
});