-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
84 lines (72 loc) · 1.96 KB
/
index.js
File metadata and controls
84 lines (72 loc) · 1.96 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Created by QiaoYiFei on 2018/7/31
*/
// MapView.js
import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {requireNativeComponent} from 'react-native';
class TextInputIOS extends Component {
componentDidMount () {
if (this.props.autoFocus) {
this._textInput.focus()
}
}
_onChange = (event) => {
// Make sure to fire the mostRecentEventCount first so it is already set on
// native when the text value is set.
var text = event.nativeEvent.text;
this.props.onChange && this.props.onChange(event);
this.props.onChangeText && this.props.onChangeText(text);
if (!this._textInput) {
// calling `this.props.onChange` or `this.props.onChangeText`
// may clean up the input itself. Exits here.
return;
}
}
_onFocus = (event) => {
}
_onBlur = (event) => {
this._textInput.focus()
}
_getText = () => {
const {defaultValue, value} = this.props
return value || defaultValue || ''
}
render() {
return <RNGTextField ref={component => this._textInput = component}
style={{width: 400, height: 50}} {...this.props}
text={this._getText()}
onChange={this._onChange}
onFocus={this._onFocus}
onBlur={this._onBlur}/>;
}
}
TextInputIOS.propTypes = {
placeholder: PropTypes.string,
placeholderTextColor: PropTypes.string,
maxLength: PropTypes.number,
onChange: PropTypes.func,
onChangeText: PropTypes.func,
defaultValue: PropTypes.string,
value: PropTypes.string,
returnKeyType: PropTypes.oneOf([
'done',
'go',
'next',
'search',
'send',
'default',
'emergency-call',
'google',
'join',
'route',
'yahoo',
]),
autoFocus: PropTypes.bool,
text: PropTypes.string,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onEndEditing: PropTypes.func
};
var RNGTextField = requireNativeComponent('RNGTextField', TextInputIOS);
module.exports = TextInputIOS;