-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
66 lines (61 loc) · 2.02 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
import { Asset } from 'expo-asset';
import * as Font from 'expo-font';
import * as SplashScreen from 'expo-splash-screen';
import React, { useEffect, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import LinearBackground from './components/LinearBackground';
import MediaPlayer from './components/MediaPlayer';
import ResultsList from './components/ResultsList';
import SearchInput from './components/SearchInput';
SplashScreen.preventAutoHideAsync();
export default function App() {
useEffect(() => {
Font.loadAsync({
'barricada': require('./assets/fonts/BarricadaRegular.ttf'),
'poppins': require('./assets/fonts/Poppins-Medium.ttf'),
'poppinsLight': require('./assets/fonts/Poppins-Light.ttf'),
'poppinsSemiBold': require('./assets/fonts/Poppins-SemiBold.ttf'),
'poppinsBold': require('./assets/fonts/Poppins-Bold.ttf'),
})
.then(() => {
setFontsLoaded(true)
})
}, [])
useEffect(() => {
Asset.loadAsync([
require('./assets/play.png'),
require('./assets/play-square.png'),
require('./assets/pause-square.png'),
])
.then(() => {
setImagesLoaded(true)
})
}, [])
const [searchResults, setSearchResults] = useState([])
const [currentSong, setCurrentSong] = useState(null)
const [fontsLoaded, setFontsLoaded] = useState(false)
const [imagesLoaded, setImagesLoaded] = useState(false)
if (!fontsLoaded || !imagesLoaded) {
return null;
}
SplashScreen.hideAsync();
return (
<View style={styles.container}>
<LinearBackground>
<SearchInput setSearchResults={setSearchResults} setCurrentSong={setCurrentSong} />
<ResultsList searchResults={searchResults} currentSong={currentSong} setCurrentSong={setCurrentSong} />
</LinearBackground>
<MediaPlayer currentSong={currentSong}/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
margin: 0,
padding: 0,
},
});