-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathApp.js
69 lines (53 loc) · 1.78 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
import Expo from 'expo';
import React from 'react';
import {AsyncStorage} from 'react-native';
import {StyleProvider, Root} from 'native-base';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
import config from './config';
import Onboarding from './js/onboarding';
import App from './js/App';
import StoryBook from './storybook';
// XXX change false -> true if you want sb
const AppToLoad = false ? StoryBook : App; //eslint-disable-line
class App1 extends React.Component {
state = {
ready: false,
onboarding: true
};
async componentWillMount() {
if (__DEV__) await AsyncStorage.multiRemove(['onboardingDone', 'session', 'liked']);
const onboardingDone = await AsyncStorage.getItem('onboardingDone');
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
Ionicons: require('@expo/vector-icons/fonts/Ionicons.ttf')
});
if (!__DEV__) Expo.Amplitude.initialize(config.AMPLITUDE_KEY);
Expo.Amplitude.logEvent('Load');
if (onboardingDone === null) {
Expo.Amplitude.logEvent('Onboarding.Start');
}
this.setState({
ready: true,
onboarding: onboardingDone === null
});
}
onOnboardingDone = () => {
Expo.Amplitude.logEvent('Onboarding.Done');
AsyncStorage.setItem('onboardingDone', '1');
this.setState({onboarding: false});
}
render() {
if (!this.state.ready) return <Expo.AppLoading />;
if (this.state.onboarding) return <Onboarding onDone={this.onOnboardingDone} />;
return (
<StyleProvider style={getTheme(material)}>
<Root>
<AppToLoad />
</Root>
</StyleProvider>
);
}
}
export default App1;