신승민

Search UI and Poster

This diff is collapsed. Click to expand it.
1 +import React, { Component } from 'react';
2 +import { Image, View, Button, Text, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
3 +import { Icon } from 'native-base';
4 +import axios from "axios";
5 +import { AsyncStorage } from "react-native";
6 +
7 +const API_KEY = "2bf00f660b1a6a3ffeb6e06ac270cce3";
8 +const NAVER_CLIENT_ID = "KqPsntd1hcPJ8FUPBGqN";
9 +const NAVER_CLIENT_SECRET = "0GRb3uya1U";
10 +
11 +export default class Search extends Component {
12 + static navigationOptions = {
13 + tabBarIcon: ({ tintColor }) => (
14 + <Icon name='ios-search' style={{ color: tintColor }} />
15 + )
16 + }
17 +
18 + state = {
19 + movieName: "",
20 + imgurl: []
21 + };
22 +/*
23 + getNaverApi = async () => {
24 + fetch(`https://openapi.naver.com/v1/search/movie.json?query=${this.state.movieName}`, {
25 + headers: {
26 + "X-Naver-Client-Id": NAVER_CLIENT_ID,
27 + "X-Naver-Client-Secret": NAVER_CLIENT_SECRET
28 + }
29 + })
30 + .then(response => response.json())
31 + .then(json => {
32 + this.setState({
33 + imgurl: json.items[0].image
34 + });
35 + });
36 + getMovieList = async () => {
37 + axios
38 + .get(
39 + `http://www.kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json?key=${API_KEY}&targetDt=20191129`
40 + )
41 + .then(response => {
42 + for (var i = 0; i < 10; i++) {
43 + console.log(
44 + response.data.boxOfficeResult.dailyBoxOfficeList[i].movieNm
45 + );
46 + }
47 + })
48 + .catch(error => {
49 + console.log(error);
50 + });
51 + };
52 + }
53 + componentDidMount() {
54 + this.getNaverApi();
55 + }
56 +*/
57 + addinput = () => {
58 + this.setState(
59 +
60 + )
61 + }
62 +
63 + handleSearchUpdate = text => {
64 + this.setState({
65 + searchTerm: text
66 + });
67 + };
68 +
69 +
70 + render() {
71 + return (
72 + <View style={styles.container}>
73 + <View style={styles.input}>
74 + <TextInput
75 + style={styles.inputText}
76 + placeholder='Search'
77 + autoCorrect={ false }
78 + value = {this.state.movieName}
79 + onChangeText= { (movieName) => this.setState({movieName})}
80 + />
81 + <TouchableOpacity on PressOut = {this.add}>
82 + <Icon name='ios-search'/>
83 + </TouchableOpacity>
84 +
85 + </View>
86 + <Text>
87 + {this.state.imgurl}
88 + </Text>
89 + </View>
90 + )
91 + }
92 + controlMovie = text => {
93 + this.setState({
94 + movieName: text
95 + });
96 + }
97 +}
98 +
99 +const styles = StyleSheet.create({
100 + container: {
101 + marginLeft: 50,
102 + marginRight: 50,
103 + },
104 + input: {
105 + borderRadius: 10,
106 + backgroundColor: "#FFF",
107 + paddingLeft: 10,
108 + paddingRight: 10,
109 + height: 50,
110 + alignItems: "center",
111 + flexDirection: 'row',
112 + justifyContent: 'space-between',
113 + borderBottomColor: "#bbb",
114 + borderBottomWidth: StyleSheet.hairlineWidth,
115 + },
116 + inputText: {
117 + flex: 1,
118 + },
119 + addBtn: {
120 + color: '#4169E1'
121 + }
122 +});
...\ No newline at end of file ...\ No newline at end of file
1 import React, { Component } from 'react'; 1 import React, { Component } from 'react';
2 -import { StyleSheet, Text, View } from 'react-native'; 2 +import { StyleSheet, Text, View, Button } from 'react-native';
3 import { Icon } from 'native-base'; // 추가된 코드 3 import { Icon } from 'native-base'; // 추가된 코드
4 import { createAppContainer } from 'react-navigation'; 4 import { createAppContainer } from 'react-navigation';
5 import { createMaterialTopTabNavigator } from 'react-navigation-tabs'; 5 import { createMaterialTopTabNavigator } from 'react-navigation-tabs';
6 import SeenMovieTab from './AppTabNavigator/MovieRankingTab'; 6 import SeenMovieTab from './AppTabNavigator/MovieRankingTab';
7 import MovieRankingTab from './AppTabNavigator/WantToWatchTab'; 7 import MovieRankingTab from './AppTabNavigator/WantToWatchTab';
8 import WantToWatchTab from './AppTabNavigator/SeenMovieTab'; 8 import WantToWatchTab from './AppTabNavigator/SeenMovieTab';
9 +import Search from './/AppTabNavigator/Search';
9 import { Platform } from 'react-native' 10 import { Platform } from 'react-native'
10 //import { Ionicons } from '@expo/vector-icons'; 11 //import { Ionicons } from '@expo/vector-icons';
11 12
12 13
13 const AppTabNavigator = createMaterialTopTabNavigator({ 14 const AppTabNavigator = createMaterialTopTabNavigator({
14 - "SeenMovieTab":{ screen: SeenMovieTab }, 15 + SeenMovieTab:{ screen: SeenMovieTab },
15 - "MovieRankingTab":{ screen: MovieRankingTab }, 16 + MovieRankingTab:{ screen: MovieRankingTab },
16 - "WantToWatchTab":{ screen: WantToWatchTab } 17 + WantToWatchTab:{ screen: WantToWatchTab },
18 + Search: { screen: Search }
17 }, { 19 }, {
18 animationEnabled: true, 20 animationEnabled: true,
19 swipeEnabled: true, 21 swipeEnabled: true,
...@@ -41,9 +43,9 @@ export default class MainScreen extends Component { ...@@ -41,9 +43,9 @@ export default class MainScreen extends Component {
41 // navigationOptions 코드 추가 43 // navigationOptions 코드 추가
42 static navigationOptions = { 44 static navigationOptions = {
43 //headerLeft: <Icon name='ios-camera' style={{ paddingLeft:10 }}/>, 45 //headerLeft: <Icon name='ios-camera' style={{ paddingLeft:10 }}/>,
44 - title: 'PoketMovie', 46 + title: 'PoketMovie'
45 - headerRight: <Icon name='ios-search' style={{ paddingRight:10 }}/>, 47 +
46 - } 48 +}
47 49
48 render() { 50 render() {
49 return <AppTabContainet/>; // AppTabContainet 컴포넌트를 리턴한다. 51 return <AppTabContainet/>; // AppTabContainet 컴포넌트를 리턴한다.
...@@ -55,5 +57,5 @@ const styles = StyleSheet.create({ ...@@ -55,5 +57,5 @@ const styles = StyleSheet.create({
55 flex: 1, 57 flex: 1,
56 alignItems: 'center', 58 alignItems: 'center',
57 justifyContent: 'center', 59 justifyContent: 'center',
58 - }, 60 + }
59 }); 61 });
...\ No newline at end of file ...\ No newline at end of file
......