-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathSearchBar.js
124 lines (106 loc) · 2.57 KB
/
SearchBar.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'use strict';
var React = require('react-native');
var {
Image,
PixelRatio,
StyleSheet,
Text,
Platform,
TextInput,
View,
Dimensions,
TouchableHighlight,
TouchableNativeFeedback,
} = React;
var SearchScreen = require("./SearchScreen");
var titleBarHeight = Dimensions.get('window').height / 12;
var textInputHeight = titleBarHeight - 20;
var titleBarMarginTop = 0;
if (Platform.OS === 'ios') {
titleBarMarginTop = 10;
}
var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
TouchableElement = TouchableNativeFeedback;
}
var SearchBar = React.createClass({
_onPressSearchButton: function(){
},
_onPressBackButton: function() {
if (this.props.navigator) {
this.props.navigator.pop();
}
},
render: function() {
return (
<View>
<View style={styles.container}>
<TouchableElement onPress={this._onPressBackButton}>
<View style={styles.actionItem}>
<Image
style={styles.searchButton}
source={require('./images/ic_back.png')}
resizeMode='contain' />
</View>
</TouchableElement>
<TextInput
style={styles.textInput}
placeholder="输入您想看的电影..."
placeholderTextColor="#888888"
underlineColorAndroid="transparent"
autoFocus={true}
multiline={false} />
<TouchableElement onPress={this.props.onSearchPress}>
<View style={styles.actionItem}>
<Image
style={styles.searchButton}
source={require('./images/ic_search_white_48dp.png')}
resizeMode='contain' />
</View>
</TouchableElement>
</View>
<View style={styles.titleBarSplitLine} />
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex:1,
flexDirection: "row",
marginTop: titleBarMarginTop,
alignItems: 'center',
height: titleBarHeight,
backgroundColor: '3e9ce9',
},
titleText: {
fontSize: 18,
marginLeft: 10,
color: 'white'
},
titleBarSplitLine: {
height: 0,
backgroundColor: '#e5e5e5',
},
searchButton: {
width: 32,
height: 32,
marginLeft: 8,
marginRight: 8,
},
actionItem: {
height: 56,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
paddingLeft: 8,
paddingRight: 8,
},
textInput: {
flex: 1,
color: 'white',
backgroundColor: 'white',
height: textInputHeight,
}
});
module.exports = SearchBar;