/
Tab.js
53 lines (48 loc) · 1.12 KB
/
Tab.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
/* @flow */
import React, {
Component,
PropTypes
} from 'react';
import {
ColorPropType,
processColor,
requireNativeComponent,
View
} from 'react-native';
export default class Tab extends Component {
static propTypes = {
...View.propTypes,
iconPackage: PropTypes.string,
iconResId: PropTypes.string,
iconSize: PropTypes.number,
iconUri: PropTypes.string,
name: PropTypes.string,
onTabSelected: PropTypes.func,
textColor: ColorPropType
};
onTabSelected: Function = (e) => {
if (this.props.onTabSelected) {
this.props.onTabSelected(e);
}
};
render() {
const {style, children, ...otherProps} = this.props;
const wrappedChildren = children ?
<View
children={children}
collapsable={false}
pointerEvents={'none'}
style={style}
/> : null;
return (
<AndroidTab
{...otherProps}
children={wrappedChildren}
collapsable={false}
onTabSelected={this.onTabSelected}
textColor={processColor(this.props.textColor)}
/>
);
}
}
const AndroidTab = requireNativeComponent('Tab', Tab);