/
index.jsx
105 lines (102 loc) · 2.74 KB
/
index.jsx
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
93
94
95
96
97
98
99
100
101
102
103
104
105
import React from 'react';
import {
ScrollView,
Text,
View,
StyleSheet,
} from '@hippy/react';
import imageUrl from './defaultSource.jpg';
const styles = StyleSheet.create({
itemTitle: {
alignItems: 'flex-start',
justifyContent: 'center',
height: 40,
borderWidth: 1,
borderStyle: 'solid',
borderColor: '#e0e0e0',
borderRadius: 2,
backgroundColor: '#fafafa',
padding: 10,
marginTop: 10,
},
rectangle: {
width: 160,
height: 80,
marginVertical: 10,
},
bigRectangle: {
width: 200,
height: 100,
borderColor: '#eee',
borderWidth: 1,
borderStyle: 'solid',
padding: 10,
marginVertical: 10,
},
smallRectangle: {
width: 40,
height: 40,
borderRadius: 10,
},
});
export default function ViewExpo() {
const renderTitle = title => (
<View style={styles.itemTitle}>
<Text>{title}</Text>
</View>
);
return (
<ScrollView style={{ paddingHorizontal: 10 }}>
{renderTitle('backgroundColor')}
<View style={[styles.rectangle, { backgroundColor: '#4c9afa' }]} />
{renderTitle('backgroundImage')}
<View style={[styles.rectangle, {
alignItems: 'center',
justifyContent: 'center',
marginTop: 20,
backgroundImage: imageUrl,
}]}
accessible={true}
accessibilityLabel={'背景图'}
accessibilityRole={'image'}
accessibilityState={{
disabled: false,
selected: true,
checked: false,
expanded: false,
busy: true,
}}
accessibilityValue={{
min: 1,
max: 10,
now: 5,
text: 'middle',
}}
><Text style={{ color: 'white' }}>背景图</Text></View>
{renderTitle('backgroundImage linear-gradient')}
<View style={[styles.rectangle, {
alignItems: 'center',
justifyContent: 'center',
marginTop: 20,
borderWidth: 2,
borderStyle: 'solid',
borderColor: 'black',
borderRadius: 2,
backgroundImage: 'linear-gradient(30deg, blue 10%, yellow 40%, red 50%);',
}]} ><Text style={{ color: 'white' }}>渐变色</Text></View>
{renderTitle('border props')}
<View style={[styles.rectangle, { borderColor: '#242424', borderRadius: 4, borderWidth: 1, borderStyle: 'solid' }]} />
{renderTitle('flex props')}
<View style={[styles.bigRectangle, {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
}]}
>
<View style={[styles.smallRectangle, { backgroundColor: 'yellow' }]} />
<View style={[styles.smallRectangle, { backgroundColor: 'blue' }]} />
<View style={[styles.smallRectangle, { backgroundColor: 'green' }]} />
</View>
</ScrollView>
);
}