LabelLinkView.js
1.82 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
import React, {Component} from 'react';
import {
View,
Text,
TouchableOpacity
} from 'react-native';
const defaultHeight = (30);
const VPading = (6);
export default class LabelLinkView extends Component {
constructor(props) {
super(props);
this.state = {}
this.attrData = this.props.attrData;
this.extendData = (this.attrData.data && this.attrData.data.length > 0)?JSON.parse(this.attrData.data):{};
}
render() {
let {name, code, type, uom, description, isRequired, isPreview} = this.attrData;
let {placeholder, hyperlink} = this.extendData;
// 是否为超链接
let isHyperlink = !!hyperlink && hyperlink.length > 0 && (hyperlink.indexOf('http://') === 0 || hyperlink.indexOf('https://') === 0);
return (
<TouchableOpacity
style={{
width: '100%',
backgroundColor: 'rgba(245, 245, 245, 1)',
flexDirection: 'row',
alignItems: 'center',
paddingVertical: VPading,
paddingLeft: 10,
paddingRight: 15,
minHeight: defaultHeight
}}
activeOpacity={0.8}
onPress={() => {
if (isHyperlink) {
this.props.navigation.navigate("CommonWebView", {url: hyperlink})
}
}}
>
{/*{isRequired&&<Text style={{ color: "#FF3030" }}>* {" "}</Text>}*/}
{/*{!isRequired&&<Text style={{ color: "#fff" }}>* {" "}</Text>}*/}
<Text style={{fontSize: 14, color: '#999', marginLeft:10, textDecorationLine: isHyperlink?'underline':'none'}}>{placeholder||description}</Text>
</TouchableOpacity>
);
}
}