-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
72 lines (68 loc) · 2.17 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
import React, { Component } from "react";
import { Text, View, SafeAreaView } from "react-native";
import LaunchScreen from "./src/LaunchScreen";
import { BlackTextButtonComponent } from "./src/Buttons";
import PlayBox from "./src/PlayBox";
import styles from "./src/styles";
import emoji from "node-emoji";
import { initialState } from "./src/constants";
export default class App extends Component {
constructor(props) {
super(props);
this.state = initialState;
}
onPress = stateChange => {
return () => this.setState(stateChange);
};
renderPlayScreen() {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={styles.container}>
<View style={styles.titleContainer}>
<Text style={[{ fontSize: 50 }, styles.blackFont]}>
LET'S PLAY!
</Text>
<BlackTextButtonComponent
text={emoji.emojify(":point_left: RESTART ")}
fontSize={15}
onPress={this.onPress(initialState)}
/>
</View>
<PlayBox
updatePlayerTally={this.onPress({
playerTally: this.state.playerTally + 1
})}
updateComputerTally={this.onPress({
computerTally: this.state.computerTally + 1
})}
/>
<View style={styles.tallyContainer}>
<View style={styles.tallyName}>
<Text style={styles.tallyNameText}>PLAYER</Text>
</View>
<View style={styles.tallyPoints}>
<Text style={styles.tallyPointsText}>
{this.state.playerTally}
</Text>
</View>
<View style={styles.tallyPoints}>
<Text style={styles.tallyPointsText}>
{this.state.computerTally}
</Text>
</View>
<View style={styles.tallyName}>
<Text style={styles.tallyNameText}>COMPUTER</Text>
</View>
</View>
</View>
</SafeAreaView>
);
}
render() {
if (this.state.launch) {
return <LaunchScreen onPress={this.onPress({ launch: false })} />;
} else {
return this.renderPlayScreen();
}
}
}