-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
executable file
·92 lines (81 loc) · 2.54 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Imports: Dependencies
import React from 'react';
import { View, Text, Image } from 'react-native';
import { PersistGate } from 'redux-persist/es/integration/react'
import { Provider } from 'react-redux';
import { AppLoading } from 'expo';
import TrackPlayer from 'react-native-track-player';
import * as Font from 'expo-font';
// import * as Font from 'expo-font';
/*import { AppLoading } from 'expo';
import * as Font from 'expo-font';
import { Asset } from 'expo-asset';*/
import { FontAwesome, Ionicons, AntDesign, MaterialIcons } from '@expo/vector-icons';
import { StyleProvider, Root } from 'native-base';
import getTheme from './app/theme/components';
import material from './app/theme/variables/material';
// Imports: Navigation
import ReduxNavigation from './app/navigation/ReduxNavigation';
// Imports: Redux Persist Persister
import { store, persistor } from './app/store/store';
// import { I18nManager } from 'react-native';
// I18nManager.forceRTL(false);
console.disableYellowBox = true;
function cacheImages(images) {
return images.map(image => {
if (typeof image === 'string') {
return Image.prefetch(image);
} else {
return Asset.fromModule(image).downloadAsync();
}
});
}
function cacheFonts(fonts) {
return fonts.map(font => Font.loadAsync(font));
}
// React Native: App
export default class App extends React.Component {
constructor(){
super();
this.state = {
isReady: false,
}
}
async componentWillMount() {
TrackPlayer.registerPlaybackService(() => require('./app/components/service.js'));
await Font.loadAsync({
// 'Ionicons': require('native-base/Fonts/Ionicons.ttf'),
...Ionicons.font,
...FontAwesome.font,
...AntDesign.font,
...MaterialIcons.font,
'Font-Light': require('./app/assets/fonts/Montserrat-Light.ttf'),
'Font-Regular': require('./app/assets/fonts/Montserrat-Regular.ttf'),
'Font-Semibold': require('./app/assets/fonts/Montserrat-SemiBold.ttf'),
'Font-Bold': require('./app/assets/fonts/Montserrat-Bold.ttf'),
});
this.setState({isReady: true});
}
render() {
if (!this.state.isReady) {
return (
<AppLoading />
);
}
return (
// Redux: Global Store
<Provider store={store}>
<PersistGate
loading={<AppLoading />}
persistor={persistor}
>
<StyleProvider style={getTheme(material)}>
<Root>
<ReduxNavigation />
</Root>
</StyleProvider>
</PersistGate>
</Provider>
);
}
};