-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathApp.js
76 lines (68 loc) · 1.83 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
import React, { Component } from 'react';
import { ActivityIndicator, Animated, Easing, View, StyleSheet } from 'react-native';
import { Font } from 'expo';
import { Provider, Client } from 'urql'; // Version can be specified in package.json
import { StackNavigator } from 'react-navigation'; // Version can be specified in package.json
import PokemonList from './PokemonList';
import PokemonDetail from './PokemonDetail';
import cache from './cache'
const client = new Client({
cache,
url: 'https://graphql-pokemon.now.sh',
});
const RouteStack = StackNavigator(
{
Home: {
screen: PokemonList,
},
Details: {
screen: PokemonDetail,
},
},
{
initialRouteName: 'Home',
headerMode: 'none',
transitionConfig: () => ({
transitionSpec: {
duration: 0,
timing: Animated.timing,
easing: Easing.step0,
},
}),
}
);
export default class App extends Component {
state = {
currentIndex: 0,
fontsLoaded: false,
};
componentDidMount = async () => {
await Font.loadAsync({
regular: require('./assets/fonts/DINNextLTPro-Regular.otf'),
bold: require('./assets/fonts/DINNextLTPro-Heavy.otf'),
black: require('./assets/fonts/DINNextLTPro-Black.otf'),
light: require('./assets/fonts/DINNextLTPro-Light.otf'),
'ultra-light': require('./assets/fonts/DINNextLTPro-UltraLight.otf'),
});
this.setState({ fontsLoaded: true });
};
render() {
return (
<Provider client={client}>
{this.state.fontsLoaded
? <RouteStack />
: <View style={styles.loader}>
<ActivityIndicator color="black" />
</View>}
</Provider>
);
}
}
const styles = StyleSheet.create({
loader: {
flex: 1,
backgroundColor: 'white',
justifyContent: 'center',
alignItems: 'center',
},
});