forked from umhan35/react-native-search-bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchBar.coffee
53 lines (40 loc) · 1.3 KB
/
SearchBar.coffee
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
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: (e) ->
@props.onChange? e
@props.onChangeText? e.nativeEvent.text
_onPress: (e) ->
button = e.nativeEvent.button
if button == 'search'
@props.onSearchButtonPress? e.nativeEvent.searchText
else if button == 'cancel'
@props.onCancelButtonPress?()
blur: ->
NativeModules.RNSearchBarManager.blur React.findNodeHandle(this)
focus: ->
NativeModules.RNSearchBarManager.focus React.findNodeHandle(this)
render: ->
`<RNSearchBar
style={{height: NativeModules.RNSearchBarManager.ComponentHeight}}
onChange={this._onChange}
onPress={this._onPress}
{...this.props}
/>`
module.exports = SearchBar