-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathAndroidSegmented.js
More file actions
54 lines (43 loc) · 1.29 KB
/
AndroidSegmented.js
File metadata and controls
54 lines (43 loc) · 1.29 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
'use strict';
var React = require('react-native');
var { requireNativeComponent, PropTypes, View } = React;
var NativeAndroidSegmented = requireNativeComponent('AndroidSegmented', AndroidSegmented);
class AndroidSegmented extends React.Component {
constructor() {
super();
this._onChange = this._onChange.bind(this);
}
_onChange(event) {
if (this.props.onChange) {
this.props.onChange(event.nativeEvent);
}
}
render() {
return (
<NativeAndroidSegmented
{...this.props}
onChange={this._onChange}/>
);
}
}
var colorType = function (props, propName, componentName) {
var checker = function() {
var color = props[propName];
var regex = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;
if (!regex.test(color)) {
return new Error('Only accept color formats: #RRGGBB and #AARRGGBB');
}
};
return PropTypes.string(props, propName, componentName) || checker();
}
AndroidSegmented.propTypes = {
...View.propTypes,
childText: PropTypes.arrayOf(PropTypes.oneOfType([ PropTypes.string ])),
orientation:PropTypes.string,
tintColor:PropTypes.arrayOf(PropTypes.oneOfType([ PropTypes.string ])),
selectedPosition:PropTypes.number,
onChange: PropTypes.func,
}
AndroidSegmented.defaultProps = {
};
module.exports = AndroidSegmented;