-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
97 lines (86 loc) · 2.4 KB
/
App.js
File metadata and controls
97 lines (86 loc) · 2.4 KB
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
// @flow
import * as React from 'react';
import { StatusBar, Platform } from 'react-native';
import { createSwitchNavigator, createAppContainer } from 'react-navigation';
import { reducer } from './src/main/reducers/reducer';
import * as Font from 'expo-font';
import {
Images,
loadIcons,
ThemeProvider,
StateProvider
} from './src/components';
import { Welcome, PushContainer } from './src/welcome';
import { CareerNavigator } from './src/main';
// $FlowFixMe
const SFProTextBold = require('./assets/fonts/SF-Pro-Text-Bold.otf');
// // $FlowFixMe
const SFProTextSemibold = require('./assets/fonts/SF-Pro-Text-Semibold.otf');
// // $FlowFixMe
const SFProTextRegular = require('./assets/fonts/SF-Pro-Text-Regular.otf');
const onNavigationStateChange = () => undefined;
type AppProps = {};
type AppState = {
isReady: boolean
};
export default class App extends React.Component<AppProps, AppState> {
state = {
isReady: false
};
ready() {
this.setState({ isReady: true });
}
async componentDidMount(): Promise<void> {
StatusBar.setBarStyle('dark-content');
if (Platform.OS === 'android') {
StatusBar.setBackgroundColor('white');
}
const fonts = Font.loadAsync({
'SFProText-Bold': SFProTextBold,
'SFProText-Semibold': SFProTextSemibold,
'SFProText-Regular': SFProTextRegular
});
const images = Images.downloadAsync();
const icons = loadIcons();
try {
await Promise.all([fonts, ...images, icons]);
} catch (e) {
// Do nothing
}
this.ready();
}
render(): React.Node {
const { isReady } = this.state;
if (!isReady) {
return (
<React.Fragment>
<StatusBar
translucent
backgroundColor="transparent"
barStyle="dark-content"
/>
</React.Fragment>
);
}
return (
<React.Fragment>
<StatusBar
translucent
backgroundColor="transparent"
barStyle="light-content"
/>
<StateProvider reducer={reducer}>
<ThemeProvider>
<AppNavigator {...{ onNavigationStateChange }} />
</ThemeProvider>
</StateProvider>
</React.Fragment>
);
}
}
const MainNavigator = createSwitchNavigator({
Welcome: { screen: Welcome },
Career: { screen: CareerNavigator },
PushContainer: { screen: PushContainer }
});
const AppNavigator = createAppContainer(MainNavigator);