-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
97 lines (92 loc) · 2.37 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
93
94
95
96
97
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TextInput,
ListView,
Image,
Button,
TouchableHighlight
} from 'react-native';
import Config from './constants';
import axios from 'axios';
import VideoList from './components/DisplayVideoList'
export default class YoutubeAudioConverter extends Component {
state = {
searchQuery: '',
isLoaded: false,
queryResult: ''
};
fetchVideos = (searchQuery) => {
const vm = this;
//console.log(`${Config.SEARCH_API_URL}${searchQuery}`);
axios.get(`${Config.SEARCH_API_URL}${searchQuery}`)
.then(function (response) {
console.log(response.data.items);
vm.setState({
queryResult: response.data.items,
isLoaded: true
});
return response.data;
})
.catch(function (error) {
console.log(error);
});
}
render() {
return (
<View style={styles.homeContainer}>
<View style={styles.searchContainer} >
<View style={styles.searchInputContainer}>
<TextInput
//underlineColorAndroid='transparent'
placeholder="Search YouTube"
value={this.state.searchQuery}
onChangeText={(searchQuery) => this.setState({searchQuery})}
/>
</View>
<View style={styles.searchButtonContainer} >
<TouchableHighlight
underlayColor = {'white'}
onPress= {() => this.fetchVideos(this.state.searchQuery)}>
<Image
source={require('./assets/search_icon.png')}
/>
</TouchableHighlight>
</View>
</View>
<View>
{this.state.isLoaded ? <VideoList queryResult = {this.state.queryResult} /> : null}
</View>
</View>
);
}
}
const styles = StyleSheet.create({
homeContainer: {
flex: 1,
alignItems: 'center',
paddingBottom: 100,
paddingTop: 20,
backgroundColor: 'white'
},
searchContainer: {
flexDirection: 'row',
//borderBottomWidth: 0.5,
},
searchInputContainer: {
width: 300,
height: 60
},
searchButtonContainer: {
width: 60,
height: 60
},
});