forked from alibaba/rax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkDemo.js
92 lines (83 loc) · 2.15 KB
/
LinkDemo.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
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
83
84
85
86
87
88
89
90
91
92
import {createElement, Component} from 'rax';
import {
View,
Text,
Image,
Link,
TextInput,
Button,
Switch,
Video,
ScrollView,
TouchableHighlight} from 'rax-components';
class LinkDemo extends Component {
state = {
timesPressed1: 0,
timesPressed2: 0,
};
handlePress1 = () => {
this.setState({
timesPressed1: this.state.timesPressed1 + 1,
});
};
handlePress2 = () => {
this.setState({
timesPressed2: this.state.timesPressed2 + 1,
});
};
render() {
var textLog1 = '';
if (this.state.timesPressed1 > 1) {
textLog1 = this.state.timesPressed1 + 'x onPress';
} else if (this.state.timesPressed1 > 0) {
textLog1 = 'onPress';
}
var textLog2 = '';
if (this.state.timesPressed2 > 1) {
textLog2 = this.state.timesPressed2 + 'x onPress';
} else if (this.state.timesPressed2 > 0) {
textLog2 = 'onPress';
}
return (
<View>
<View style={styles.container}>
<Link onPress={this.handlePress1} href="https://github.com/alibaba/rax">Goto Github</Link>
<View style={styles.logBox}>
<Text>
{textLog1}
</Text>
</View>
</View>
<View style={styles.container}>
<Link onPress={this.handlePress2} href="https://github.com/alibaba/rax">
<Image style={{width: 400, height: 343}} source={{uri: 'https://camo.githubusercontent.com/27b9253de7b03a5e69a7c07b0bc1950c4976a5c2/68747470733a2f2f67772e616c6963646e2e636f6d2f4c312f3436312f312f343031333762363461623733613132336537386438323436636438316338333739333538633939395f343030783430302e6a7067'}} />
</Link>
<View style={styles.logBox}>
<Text>
{textLog2}
</Text>
</View>
</View>
</View>
);
}
}
let styles = {
container: {
padding: 20,
borderStyle: 'solid',
borderColor: '#dddddd',
borderWidth: 1,
marginLeft: 20,
marginRight: 20,
marginBottom: 10,
},
logBox: {
padding: 20,
margin: 10,
borderWidth: 1,
borderColor: '#f0f0f0',
backgroundColor: '#f9f9f9',
},
};
export default LinkDemo;