-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
100 lines (93 loc) · 2.74 KB
/
index.android.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
98
99
100
// Key Differences:
// Our search box is now connected to the API call.
// When the search is submitted, the value is passed into the SearchResults component.
// When the SearchResults component receives new props, it will run a new API call with the new props.
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
TextInput,
Dimensions
} from 'react-native';
import SearchResults from './SearchResults.js';
class MovieSearchApp extends Component {
// We are setting the initial state of this.state.movie to ''.
constructor(props) {
super(props);
this.state = {
movie: '',
};
}
render() {
return (
<View style={styles.container}>
<View style={styles.header}>
<Text style={styles.title}>
<Text style={{color: 'white'}}>OMDB Movie Search</Text>
</Text>
</View>
<View>
<TextInput
autoFocus={true}
style={styles.input}
placeholderTextColor="white"
placeholder="Search"
// The onSubmitEditing function is run when the text is submitted.
// It will set this.state.movie equal to the value of the text input.
onSubmitEditing={(event) => this.setState({movie: event.nativeEvent.text})}
/>
{/*The Search term is passed into the SearchResults component as props.*/}
<SearchResults movie={this.state.movie} />
</View>
<View style={styles.footer}>
</View>
<Image source={require('./popcorn.png')} style={styles.icon}></Image>
</View>
);
}
}
const screenHeight = Dimensions.get('window').height;
const screenWidth = Dimensions.get('window').width;
const styles = StyleSheet.create({
container: {
height: screenHeight,
width: screenWidth,
},
header: {
height: 60,
backgroundColor: 'rgba(76,217,175,1)',
marginBottom: 5,
},
title: {
fontSize: 25,
textAlign: 'center',
marginTop: 12,
fontWeight: 'bold'
},
input: {
color: 'white',
margin: 10,
padding: 10,
backgroundColor: 'rgba(76,217,175,1)',
fontSize: 18,
borderRadius: 10
},
footer: {
position: 'absolute',
bottom: 10,
height: 50,
width: screenWidth,
backgroundColor: 'rgba(76,217,175,1)'
},
icon: {
width:90,
height: 90,
position: 'absolute',
left: (screenWidth/2 - 45),
bottom: 5,
}
});
AppRegistry.registerComponent('MovieSearchApp', () => MovieSearchApp);