-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.js
112 lines (84 loc) · 2.99 KB
/
Game.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
import * as React from 'react';
import {Text, View, Button, Alert} from 'react-native';
import { Input, Card, Header } from 'react-native-elements';
import {Container, Row} from 'react-bootstrap'
import { createStackNavigator } from '@react-navigation/stack'
import { NavigationContainer } from '@react-navigation/native'
import {styles} from './public/styles/styles'
import { GameReducer, RootReducer } from './reducers'
import Store, {ROOT_STATE} from './store'
import GameScreen from './screens/GameScreen'
import TitleScreen from './screens/TitleScreen'
import SetupScreen from './screens/SetupScreen'
import Tabuleiro from './components/Tabuleiro';
const Head = (props) => {
return (
<Header >
<Button title="mostrar" />
<Button title="tabulero" />
</Header >
)
}
const RootStack = createStackNavigator()
const TitleStack = createStackNavigator()
const GameStack = createStackNavigator()
export const RootContext = React.createContext()
const QuitAlert = () => {
return Alert.alert(
"Tem certeza que quer abandonar o jogo?",
[
{
text: "Não",
style: "cancel"
},
{ text: "Sim" }
],
{ cancelable: false }
)
}
const TitleNavigator = (props) => {
return(
<TitleStack.Navigator initialRouteName={"TitleScreen"}>
<TitleStack.Screen
name="TitleScreen"
component={TitleScreen}
/>
<TitleStack.Screen
name="SetupScreen"
component={SetupScreen}
/>
</TitleStack.Navigator>
)
}
const GameNavigator = (props) => {
const ShowBoardButton = () => {return <Button title="tabuleiro" onPress={() => props.navigation.navigate('Game', {screen:'Tabuleiro'})}/>}
const QuitButton = () => {return <Button title="quit" onPress={() => QuitAlert()}/>}
return(
<GameStack.Navigator initialRouteName="GameScreen" >
<GameStack.Screen
name="GameScreen"
component={GameScreen}
options={{headerTitleStyle:{diplay:"none"}, headerLeft: ShowBoardButton, headerRight: QuitButton}}
/>
<GameStack.Screen
name="Tabuleiro"
component={Tabuleiro}
/>
</GameStack.Navigator>
)
}
const Game = (props) => {
return(
<View style={{display:"flex", flex:"1", flexDirection:'column', justifyContent:"space-evenly"}}>
<Store>
<NavigationContainer>
<RootStack.Navigator initialRouteName= "Title">
<RootStack.Screen name="Title" component={TitleNavigator} options={{headerShown: false}}/>
<RootStack.Screen name="Game" component={GameNavigator} options={{headerShown: false}}/>
</RootStack.Navigator>
</NavigationContainer>
</Store>
</View>
)
}
export default Game