-
Notifications
You must be signed in to change notification settings - Fork 7
/
App.js
78 lines (63 loc) · 2.3 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
import React from 'react';
import Meteor from 'react-native-meteor';
import { StyleProvider, Root } from 'native-base';
import Config from './config';
import getTheme from './native-base-theme/components';
import colors from './src/styles/colors';
import MainPage from './src/shared/main.page';
import OnboardingPage from './src/shared/onboarding.page';
import StatusBar from './src/shared/containers/status-bar';
import { handleInAppNotification } from './src/user/data/notifications';
import { setAppState, hasOnboarded, adjustStatusBar } from './src/shared/data/utils';
Meteor.connect(Config.apiUrl);
Meteor.subscribe('users.me');
export default class App extends React.Component {
constructor() {
super();
this.state = {
isReady: false,
onboarded: false,
};
};
async componentWillMount() {
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'),
});
const onboarded = await hasOnboarded();
this.setState({ isReady: true, onboarded });
};
componentDidMount() {
handleInAppNotification();
if (!this.state.onboarded)
setAppState('statusBarColor', colors.background);
};
completeOnboarding = () => {
setAppState('statusBarColor', 'transparent');
this.setState({ onboarded: true });
};
// when page changes, based on which page we're on, we might want to change the status bar color
handleNavigationChange(prevState, newState, action) {
if (!action.routeName)
return;
adjustStatusBar(action.routeName);
};
render() {
if (!this.state.isReady) {
return <Expo.AppLoading />;
}
return (
<StyleProvider style={getTheme()}>
<Root>
<StatusBar />
{ this.state.onboarded ? (
<MainPage onNavigationStateChange={this.handleNavigationChange}/>
) : (
<OnboardingPage onDone={this.completeOnboarding}/>
) }
</Root>
</StyleProvider>
);
};
}