forked from axilis/react-native-responsive-layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-fixed-size-elements.js
61 lines (57 loc) · 1.6 KB
/
4-fixed-size-elements.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
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Grid, Section, Block } from 'react-native-responsive-layout';
const styles = StyleSheet.create({
element: {
height: 100,
justifyContent: 'center',
},
text: {
textAlign: 'center',
color: '#02326b',
fontSize: 30,
},
whiteText: {
textAlign: 'center',
color: 'white',
fontSize: 30,
},
});
export default () => (
<Grid>
<Section>
<Block size={100}>
<View style={[styles.element, { backgroundColor: '#a1cbfd' }]}>
<Text style={styles.text}>100pt</Text>
</View>
</Block>
<Block size="stretch">
<View style={[styles.element, { backgroundColor: '#80b9fd' }]}>
<Text style={styles.text}>stretch</Text>
</View>
</Block>
<Block size="1/4">
<View style={[styles.element, { backgroundColor: '#5fa6fc' }]}>
<Text style={styles.text}>1/4</Text>
</View>
</Block>
<Block size="25%">
<View style={[styles.element, { backgroundColor: '#3d94fc' }]}>
<Text style={styles.text}>25%</Text>
</View>
</Block>
</Section>
<Section>
<Block size={150}>
<View style={[styles.element, { backgroundColor: '#02418d' }]}>
<Text style={styles.whiteText}>150pt{'\n'}fixed</Text>
</View>
</Block>
<Block size="stretch">
<View style={[styles.element, { backgroundColor: '#02326b' }]}>
<Text style={styles.whiteText}>stretch{'\n'}remaining width</Text>
</View>
</Block>
</Section>
</Grid>
);