-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
64 lines (56 loc) · 1.88 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
import React, {useState, useEffect} from "react";
import { View, StatusBar, ActivityIndicator } from "react-native";
import changeNavigationBarColor from "react-native-navigation-bar-color";;
import { NFLStatusContextProvider } from "./src/context/NFLStatusContext";
import {AllPlayersContextProvider} from './src/context/AllPlayersContext'
import { TrackPlayerContextProvider } from "./src/context/TrackPlayerContext";
import { DARK_BLACK } from "./src/components/Variables";
import { AuthContextProvider } from "./src/context/AuthContext";
import DrawerScreens from "./src/screens/DrawerScreens";
import { colors } from './src/utils/colors.js';
import TrackPlayer from 'react-native-track-player'
export default function App() {
changeNavigationBarColor(DARK_BLACK);
const [playerReady, setPlayerReady] = useState(false);
const setPlayer = async() => {
try {
await TrackPlayer.setupPlayer();
setPlayerReady(true);
} catch(e) {
console.log('Error to initialize player')
}
}
useEffect(() => {
setPlayer();
},[])
if(!playerReady) {
return (
<View style={{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:colors.DARK_BLACK}}>
<StatusBar
animated={true}
backgroundColor={colors.DARK_BLACK}
barStyle="light-content"
/>
<ActivityIndicator size="large" color={colors.LIGHT_GREEN} />
</View>
)
}
return (
<AuthContextProvider>
<AllPlayersContextProvider>
<NFLStatusContextProvider>
<TrackPlayerContextProvider>
<View style={{flex:1}}>
<StatusBar
animated={true}
backgroundColor="#0B0D0F"
barStyle="light-content"
/>
<DrawerScreens />
</View>
</TrackPlayerContextProvider>
</NFLStatusContextProvider>
</AllPlayersContextProvider>
</AuthContextProvider>
);
}