-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
87 lines (77 loc) · 2.24 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
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, ImageBackground } from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import Colors from './constants/colors';
import { useFonts } from 'expo-font';
import AppLoading from 'expo-app-loading';
import React from 'react';
import StartGameScreen from './screens/StartGameScreen';
import GameScreen from './screens/GameScreen';
import GameOverScreen from './screens/GameOverScreen';
export default function App() {
const [expectedNumber, setExpectedNumber] = React.useState(0)
const [startConfirmed, setStartConfirmed] = React.useState(false)
const [gameIsOver, setGameIsOver] = React.useState(false)
const [rounds, setRounds] =React.useState(0)
const [fontsLoaded] = useFonts({
'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf'),
'open-sans': require('./assets/fonts/OpenSans-Regular.ttf'),
});
if (!fontsLoaded) {
return <AppLoading />;
}
function confirmExpectedNumber(number){
setExpectedNumber(number)
setStartConfirmed(true)
}
function gameOver(gameRounds){
setGameIsOver(true)
setStartConfirmed(false)
setRounds(gameRounds)
}
function newGame(){
setGameIsOver(false)
setStartConfirmed(false)
}
function returnedScreen(){
if (startConfirmed == true){
return(
<GameScreen gameOver={gameOver} confirmedNumber ={expectedNumber} />
)
}
else if(gameIsOver == true){
return(
<GameOverScreen newGame={newGame} number={expectedNumber} rounds={rounds} />
)
}
else{
return(
<StartGameScreen confirmNumber={confirmExpectedNumber} />
)
}
}
return (
<LinearGradient
colors={[Colors.primary700, Colors.accent500]}
style={styles.container}>
<ImageBackground
resizeMode='cover'
style={styles.container}
imageStyle={styles.backgroundImage}
source={require('./assets/images/background.png')}>
{returnedScreen()}
</ImageBackground>
</LinearGradient>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
backgroundImage: {
opacity: 0.15,
},
text:{
color: 'white'
}
});