-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHyperlink.js
53 lines (43 loc) · 1.24 KB
/
Hyperlink.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
import React, {
Component,
PropTypes,
Text,
TouchableOpacity,
View,
} from 'react-native';
import {styles} from './Hyperlink.style.js';
import Theme from '../../config/theme';
const propTypes = {
enable: PropTypes.bool,
color: PropTypes.string,
onPress: PropTypes.func
};
const defaultProps = {
enable: true
};
export default class Hyperlink extends Component {
constructor(props) {
super(props);
this.state = {
};
}
onPress() {
if (this.props.enable) {
this.props.onPress();
}
}
render() {
const {enable, color, style, text, ...others} = this.props;
let linkColor = color ? color : (enable? Theme.colors.highlight : Theme.colors.foregroundDisable);
let activeOpacity = enable ? 0.5 : 1;
return (
<View style={[styles.container, style]} {...others}>
<TouchableOpacity activeOpacity={activeOpacity} onPress={this.onPress.bind(this)}>
<Text style={[styles.link, {color: linkColor, textDecorationColor: color}]}>{text}</Text>
</TouchableOpacity>
</View>
);
}
}
Hyperlink.propTypes = propTypes;
Hyperlink.defaultProps = defaultProps;