This repository has been archived by the owner on Mar 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
67 lines (58 loc) · 1.83 KB
/
App.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
import React, {Component} from 'react';
import {AppRegistry, StyleSheet, Text, View} from 'react-native';
import Toggle from './Toggle'
export default class App extends Component {
state = {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}
render() {
const {flexDirection, alignItems, justifyContent} = this.state
const layoutStyle = {flexDirection, justifyContent, alignItems}
const primaryAxis = flexDirection === 'row' ? 'Horizontal' : 'Vertical'
const secondaryAxis = flexDirection === 'row' ? 'Vertical' : 'Horizontal'
return (
<View style={styles.container}>
<Toggle
label={'Primary axis (flexDirection)'}
value={flexDirection}
options={['row', 'column']}
onChange={(option) => this.setState({flexDirection: option})}
/>
<Toggle
label={primaryAxis + ' distribution (justifyContent)'}
value={justifyContent}
options={['flex-start', 'center', 'flex-end', 'space-around', 'space-between']}
onChange={(option) => this.setState({justifyContent: option})}
/>
<Toggle
label={secondaryAxis + ' alignment (alignItems)'}
value={alignItems}
options={['flex-start', 'center', 'flex-end', 'stretch']}
onChange={(option) => this.setState({alignItems: option})}
/>
<View style={[styles.layout, layoutStyle]}>
<View style={styles.box} />
<View style={styles.box} />
<View style={styles.box} />
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
layout: {
flex: 1,
backgroundColor: 'rgba(0,0,0,0.05)',
},
box: {
padding: 25,
backgroundColor: 'steelblue',
margin: 5,
},
})
AppRegistry.registerComponent('App', () => App)