forked from umhan35/react-native-search-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchBar.js
59 lines (53 loc) · 1.83 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
var NativeModules, PropTypes, RNSearchBar, React, SearchBar;
React = require('react-native');
RNSearchBar = React.requireNativeComponent('RNSearchBar', null);
PropTypes = React.PropTypes;
NativeModules = React.NativeModules;
SearchBar = React.createClass({
propTypes: {
placeholder: PropTypes.string,
text: PropTypes.string,
barTintColor: PropTypes.string,
tintColor: PropTypes.string,
textFieldBackgroundColor: PropTypes.string,
showsCancelButton: PropTypes.bool,
onChange: PropTypes.func,
onChangeText: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onSearchButtonPress: PropTypes.func,
onCancelButtonPress: PropTypes.func,
hideBackground: PropTypes.bool
},
_onChange: function(e) {
var base, base1;
if (typeof (base = this.props).onChange === "function") {
base.onChange(e);
}
return typeof (base1 = this.props).onChangeText === "function" ? base1.onChangeText(e.nativeEvent.text) : void 0;
},
_onPress: function(e) {
var base, base1, button;
button = e.nativeEvent.button;
if (button === 'search') {
return typeof (base = this.props).onSearchButtonPress === "function" ? base.onSearchButtonPress(e.nativeEvent.searchText) : void 0;
} else if (button === 'cancel') {
return typeof (base1 = this.props).onCancelButtonPress === "function" ? base1.onCancelButtonPress() : void 0;
}
},
blur: function(){
NativeModules.RNSearchBarManager.blur(React.findNodeHandle(this));
},
focus: function(){
NativeModules.RNSearchBarManager.focus(React.findNodeHandle(this));
},
render: function() {
return <RNSearchBar
style={{height: NativeModules.RNSearchBarManager.ComponentHeight}}
onChange={this._onChange}
onPress={this._onPress}
{...this.props}
/>;
}
});
module.exports = SearchBar;