Search.js
3.22 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import React, { Component } from 'react';
import { Image, View, Button, Text, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
import { Icon } from 'native-base';
import axios from "axios";
import { AsyncStorage } from "react-native";
const API_KEY = "2bf00f660b1a6a3ffeb6e06ac270cce3";
const NAVER_CLIENT_ID = "KqPsntd1hcPJ8FUPBGqN";
const NAVER_CLIENT_SECRET = "0GRb3uya1U";
export default class Search extends Component {
static navigationOptions = {
tabBarIcon: ({ tintColor }) => (
<Icon name='ios-search' style={{ color: tintColor }} />
)
}
state = {
movieName: "",
imgurl: []
};
/*
getNaverApi = async () => {
fetch(`https://openapi.naver.com/v1/search/movie.json?query=${this.state.movieName}`, {
headers: {
"X-Naver-Client-Id": NAVER_CLIENT_ID,
"X-Naver-Client-Secret": NAVER_CLIENT_SECRET
}
})
.then(response => response.json())
.then(json => {
this.setState({
imgurl: json.items[0].image
});
});
getMovieList = async () => {
axios
.get(
`http://www.kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=${API_KEY}&targetDt=20191129`
)
.then(response => {
for (var i = 0; i < 10; i++) {
console.log(
response.data.boxOfficeResult.dailyBoxOfficeList[i].movieNm
);
}
})
.catch(error => {
console.log(error);
});
};
}
componentDidMount() {
this.getNaverApi();
}
*/
addinput = () => {
this.setState(
)
}
handleSearchUpdate = text => {
this.setState({
searchTerm: text
});
};
render() {
return (
<View style={styles.container}>
<View style={styles.input}>
<TextInput
style={styles.inputText}
placeholder='Search'
autoCorrect={ false }
value = {this.state.movieName}
onChangeText= { (movieName) => this.setState({movieName})}
/>
<TouchableOpacity on PressOut = {this.add}>
<Icon name='ios-search'/>
</TouchableOpacity>
</View>
<Text>
{this.state.imgurl}
</Text>
</View>
)
}
controlMovie = text => {
this.setState({
movieName: text
});
}
}
const styles = StyleSheet.create({
container: {
marginLeft: 50,
marginRight: 50,
},
input: {
borderRadius: 10,
backgroundColor: "#FFF",
paddingLeft: 10,
paddingRight: 10,
height: 50,
alignItems: "center",
flexDirection: 'row',
justifyContent: 'space-between',
borderBottomColor: "#bbb",
borderBottomWidth: StyleSheet.hairlineWidth,
},
inputText: {
flex: 1,
},
addBtn: {
color: '#4169E1'
}
});