-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
66 lines (59 loc) · 1.68 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
/* eslint-disable class-methods-use-this */
/* eslint-disable global-require */
import React from 'react';
import NativeTachyons from 'react-native-style-tachyons';
import { StyleSheet } from 'react-native';
import { Root } from 'native-base';
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import { TokenProvider } from './src/context';
import { LetheApolloClient } from './src/components/LetheApolloClient';
import { AppContainer } from './src/navigator';
NativeTachyons.build(
{
colors: {
palette: {
white: '#FFFFFF',
offWhite: '#e1e1e1',
green: '#BFEB88',
ltext: '#666',
},
},
},
StyleSheet,
);
export default () => {
const [isReady, setIsReady] = React.useState(false);
const loadFontsAsync = () =>
Font.loadAsync({
// Roboto fonts are required for native-base and pre-loading them here
// avoids a potential race condition of attempting to render some NB
// component before the fonts have been loaded.
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
});
const handleLoadingFailure = (err) => {
// TODO: report to error service?
// eslint-disable-next-line no-console
console.error(err);
};
const handleLoadingSuccess = () => setIsReady(true);
if (!isReady) {
return (
<AppLoading
startAsync={loadFontsAsync}
onError={handleLoadingFailure}
onFinish={handleLoadingSuccess}
/>
);
}
return (
<Root>
<TokenProvider>
<LetheApolloClient>
<AppContainer />
</LetheApolloClient>
</TokenProvider>
</Root>
);
};