-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
134 lines (119 loc) · 2.58 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import {
Platform,
StyleSheet,
Text,
View,
StatusBar,
TouchableOpacity,
Dimensions,
} from 'react-native';
import CrappyLayout from './src/layouts/CrappyLayout';
// Task 1: Complete Houseparty Layout
import HousepartyLayout from './src/layouts/HousepartyLayout';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
numMembers: 2,
};
}
onAddMember = () => {
this.setState((currentState) => {
if (currentState.numMembers >= 4) return currentState;
return {
numMembers: (currentState.numMembers += 1),
};
});
};
onSubtractMember = () => {
this.setState((currentState) => {
if (currentState.numMembers <= 1) return currentState;
return {
numMembers: (currentState.numMembers -= 1),
};
});
};
render() {
console.disableYellowBox = true;
StatusBar.setHidden(true);
return (
<View style={styles.container}>
<CrappyLayout numMembers={this.state.numMembers} />
<TouchableOpacity style={styles.bottomWrapperStyle} activeOpacity={0.7}>
<Text style={styles.textStyle}>Start Game</Text>
</TouchableOpacity>
<View style={styles.buttonWrapperStyle}>
<TouchableOpacity
style={styles.addMemberWrapper}
activeOpacity={0.7}
onPress={this.onSubtractMember}>
<Text style={styles.textStyle}>-</Text>
</TouchableOpacity>
<TouchableOpacity
style={styles.subtractMemberWrapper}
activeOpacity={0.7}
onPress={this.onAddMember}>
<Text style={styles.textStyle}>+</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
bottomWrapperStyle: {
width: 150,
justifyContent: 'center',
textAlign: 'center',
height: 40,
position: 'absolute',
bottom: 5,
backgroundColor: 'black',
borderRadius: 30,
opacity: 0.8,
},
textStyle: {
fontSize: 18,
color: 'white',
fontFamily: 'AvenirNext-Regular',
fontWeight: '900',
textAlign: 'center',
},
addMemberWrapper: {
flex: 1,
justifyContent: 'center',
textAlign: 'center',
backgroundColor: 'black',
borderRadius: 30,
opacity: 0.8,
},
subtractMemberWrapper: {
justifyContent: 'center',
textAlign: 'center',
backgroundColor: 'black',
borderRadius: 30,
opacity: 0.8,
flex: 1,
},
buttonWrapperStyle: {
position: 'absolute',
bottom: 5,
right: 5,
height: 40,
width: 80,
flexDirection: 'row',
},
});