ScreenSubCell.js
1.71 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import DeviceInfo from 'react-native-device-info';
const {
View,
Text,
TouchableOpacity,
Dimensions,
StyleSheet,
Platform,
Image,
} = ReactNative;
export default class ScreenSubCell extends React.Component {
constructor(props) {
super (props);
}
render() {
let resource = this.props.resource?this.props.resource:null;
let keys = this.props.keys?this.props.keys:null;
if (!resource) {
return null;
}
let isSelect = resource.isSelect;
let key = resource.key;
let name = resource.name;
return (
<View style={styles.container}>
<TouchableOpacity onPress={() => {this.props.selectItem && this.props.selectItem(resource,keys)}} >
<View style={styles.cell}>
<Text style={styles.name}>{name}</Text>
{isSelect?<Image style={styles.arrow} source={require('../../images/select_icon_20_h.png')}/>:null}
</View>
<View style={{width: width,height: 0.5,backgroundColor: 'rgb(235, 235, 235)'}}/>
</TouchableOpacity>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let backgroundWidth = width;
let backgroundHeight = 40;
let styles = StyleSheet.create({
container: {
width: backgroundWidth,
height: backgroundHeight,
alignItems: 'center',
},
cell: {
width: backgroundWidth,
height: backgroundHeight-0.5,
backgroundColor: '#f0f0f0',
flexDirection: 'row',
alignItems: 'center',
},
name: {
marginLeft: 10,
color: 'rgb(146, 146, 146)'
},
arrow: {
width: 15,
height: 15,
position: 'absolute',
marginVertical: (backgroundHeight - 15 )/2,
right: 10,
},
});