SelectItemView.js
2.88 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
import React, {Component} from 'react';
import {
View,
Text,
TouchableOpacity,
Image,
} from "react-native";
const defaultHeight = (72);
const titleViewHeight = (24);
const HPading = (16);
const VPading = (6);
export default class SelectItemView extends Component {
constructor(props) {
super(props);
this.state = {
selectText: '',
autoIncrease:20,
loadMore: false,
refreshing:false
}
this.attrData = this.props.attrData;
this.extendData = JSON.parse(this.attrData.data);
this.navigation = this.props.navigation;
}
componentWillMount() {
}
render() {
let {name, code, type, uom, description, isRequired, isPreview} = this.attrData;
let {placeholder} = this.extendData;
return (
<View style={{width: '100%',minHeight:defaultHeight,paddingTop: VPading,paddingHorizontal:HPading,backgroundColor:'#fff'}}>
<TouchableOpacity
style={{
flex:1,
flexDirection: 'row',
width: '100%',
backgroundColor: '#fff',
alignItems: 'center'
}}
activeOpacity={0.8}
onPress={() => {
this.navigation.navigate("SelectItemList", {name: name, type: type, extentData: this.extendData,
callback:(selectValue, showContent)=>{
this.setState({
selectText: showContent
});
this.attrData.value = selectValue;
}
})
}}
>
<View style={{flex: 1}}>
<View style={{flexDirection: 'row',height:titleViewHeight,backgroundColor:'#fff'}}>
{isRequired&&<Text style={{ color: "#FF3030" }}>* {" "}</Text>}
{!isRequired&&<Text style={{ color: "#fff" }}>* {" "}</Text>}
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)', marginBottom: 5}}>{name||""}</Text>
</View>
<Text style={{
fontSize: 14,
marginLeft:10,
color: !!this.state.selectText?'black':'#999',
padding: 5,
backgroundColor: '#fff',
textAlign: 'left'}}>{this.state.selectText||placeholder||'请选择'}</Text>
</View>
<Image style={{width: 16, height: 16}} source={require('../img/bread.png')} resizeMode={'contain'}/>
</TouchableOpacity>
</View>
);
}
}