-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
68 lines (60 loc) · 1.66 KB
/
App.tsx
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
import {
Roboto_300Light,
Roboto_400Regular,
Roboto_500Medium,
Roboto_900Black,
} from '@expo-google-fonts/roboto';
import { useFonts } from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import React, { useCallback, useEffect, useState } from 'react';
import { ScrollView, StatusBar, StyleSheet, View } from 'react-native';
import TrackPlayer from 'react-native-track-player';
import VideoSelector from './src/components/VideoSelector';
import { colors } from './src/colors';
import LocalizationProvider from './src/providers/LocalizationProvider';
SplashScreen.preventAutoHideAsync();
const App = () => {
const [isSetUp, setIsSetUp] = useState(false);
const [fontsLoaded, fontError] = useFonts({
Roboto_300Light,
Roboto_400Regular,
Roboto_500Medium,
Roboto_900Black,
});
useEffect(() => {
return () => {
try {
TrackPlayer.reset();
} catch (e) {}
};
}, []);
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded || fontError) {
await SplashScreen.hideAsync().then(async () => {
if (!isSetUp) {
setIsSetUp(true);
await TrackPlayer.setupPlayer();
}
});
}
}, [fontsLoaded, fontError, isSetUp]);
if (!fontsLoaded && !fontError) {
return null;
}
return (
<ScrollView style={styles.container} onLayout={onLayoutRootView}>
<StatusBar barStyle="light-content" />
<LocalizationProvider>
<VideoSelector />
</LocalizationProvider>
</ScrollView>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
minHeight: '100%',
backgroundColor: colors.darkBlue,
},
});