-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathApp.js
54 lines (52 loc) · 1.54 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
import React, { Component } from "react";
import { View, Button } from "react-native";
export default class FlexDirectionBasics extends Component {
constructor(props) {
super(props);
this.state = { justContent: "center", alItems: "flex-start" };
}
render() {
return (
<View style={{ flex: 1 }}>
<View style={{ paddingTop: 50 }}>
<Button
title="Show Space in between"
onPress={() => {
if (this.state.justContent == "center") {
this.setState({ justContent: "space-between" });
} else {
this.setState({ justContent: "center" });
}
}}
/>
<Button
title="Show Center"
onPress={() => {
if (this.state.alItems == "flex-start") {
this.setState({ alItems: "center" });
} else {
this.setState({ alItems: "flex-start" });
}
}}
/>
</View>
<View
style={{
flex: 1,
flexDirection: "column",
justifyContent: this.state.justContent,
alignItems: this.state.alItems
}}
>
<View style={{ width: 100, height: 100, backgroundColor: "red" }} />
<View
style={{ width: 100, height: 100, backgroundColor: "skyblue" }}
/>
<View
style={{ width: 100, height: 100, backgroundColor: "lightgreen" }}
/>
</View>
</View>
);
}
}