forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListItem.js
More file actions
82 lines (76 loc) · 2.03 KB
/
ListItem.js
File metadata and controls
82 lines (76 loc) · 2.03 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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
TouchableHighlight,
Platform,
TouchableNativeFeedback,
View
} from 'react-native';
import { connectStyle } from 'native-base-shoutem-theme';
import mapPropsToStyleNames from '../utils/mapPropsToStyleNames';
import variable from '../theme/variables/platform';
class ListItem extends Component {
static contextTypes = {
theme: PropTypes.object
};
render() {
const variables = this.context.theme
? this.context.theme['@@shoutem.theme/themeStyle'].variables
: variable;
if (
Platform.OS === 'ios' ||
Platform.OS === 'web' ||
variables.androidRipple === false ||
(!this.props.onPress && !this.props.onLongPress) ||
Platform.Version <= 21
) {
return (
<TouchableHighlight
onPress={this.props.onPress}
onLongPress={this.props.onLongPress}
ref={c => (this._root = c)}
underlayColor={variables.listBtnUnderlayColor}
{...this.props}
style={this.props.touchableHighlightStyle}
>
<View {...this.props} testID={undefined}>
{this.props.children}
</View>
</TouchableHighlight>
);
}
return (
<TouchableNativeFeedback
ref={c => (this._root = c)}
useForeground
{...this.props}
>
<View style={{ marginLeft: -17, paddingLeft: 17 }}>
<View {...this.props} testID={undefined}>
{this.props.children}
</View>
</View>
</TouchableNativeFeedback>
);
}
}
ListItem.propTypes = {
...TouchableHighlight.propTypes,
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
PropTypes.array
]),
touchableHighlightStyle: PropTypes.oneOfType([
PropTypes.object,
PropTypes.array
]),
itemDivider: PropTypes.bool,
button: PropTypes.bool
};
const StyledListItem = connectStyle(
'NativeBase.ListItem',
{},
mapPropsToStyleNames
)(ListItem);
export { StyledListItem as ListItem };