-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.js
More file actions
69 lines (64 loc) · 1.94 KB
/
header.js
File metadata and controls
69 lines (64 loc) · 1.94 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
import React, {Component} from "react";
import {View, Text, StyleSheet, TextInput, TouchableOpacity} from "react-native";
import {Icon} from 'react-native-elements'
import judge from '../NBA/teamdata/judge'
class Header extends Component {
constructor(props){
super(props)
this.state={
data:''
}
this._onPress = this._onPress.bind(this)
}
_onPress = () => {
if(this.state.data===''){
alert('Wrong team name')
}
else{
this.props.navigation.navigate('Details',{name:this.state.data})}
}
change = (text) =>{
var name = text.toLowerCase();
var flag = name in judge;
if(flag){
this.setState({
data:judge[name]
})
}
}
render (){
return(
<View style={{flexDirection:'row'}}>
<View style={styles.header}>
<TouchableOpacity onPress={this._onPress}>
<Icon name='search' type='material' color='#ccc'/>
</TouchableOpacity>
<TextInput
onChangeText={(text)=>{this.change(text)}}
onSubmitEditing={() => this._onPress}
placeholder="Which team you want to know?"
blurOnSubmit={false}
returnKeyType="done"
style={styles.input}/>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
header: {
paddingHorizontal: 16,
flexDirection: "row",
justifyContent: "space-around",
alignItems: "center"
},
toggleIcon: {
fontSize: 30,
color: "#CCC"
},
input: {
marginLeft: 16,
height: 40,
}
})
export default Header;