-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
59 lines (52 loc) · 1.39 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
import React, { useState } from 'react';
import { SafeAreaView, StyleSheet } from 'react-native';
import StartScreen from './screens/StartScreen';
import ConfirmScreen from './screens/ConfirmScreen';
import GameScreen from './screens/GameScreen';
export default function App() {
const appName = 'Welcome';
const [userInfo, setUserInfo] = useState(null);
const [showConfirm, setShowConfirm] = useState(false);
const [gameStarted, setGameStarted] = useState(false);
const handleRegister = (userInfo) => {
setUserInfo(userInfo);
setShowConfirm(true);
};
const handleEdit = () => {
setShowConfirm(false);
};
const handleContinue = () => {
setShowConfirm(false);
setGameStarted(true);
};
const handleRestart = () => {
setUserInfo(null);
setGameStarted(false);
};
return (
<SafeAreaView style={styles.container}>
{gameStarted ? (
<GameScreen userInfo={userInfo} onRestart={handleRestart} />
) : (
<>
<StartScreen
appName={appName}
onRegister={handleRegister}
userInfo={userInfo}
/>
<ConfirmScreen
visible={showConfirm}
userInfo={userInfo}
onEdit={handleEdit}
onContinue={handleContinue}
/>
</>
)}
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});