-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp3.js
114 lines (101 loc) · 2.89 KB
/
App3.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
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import {NavigationContainer, useNavigation} from '@react-navigation/native';
import { StyleSheet, Text, View} from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';
import { Button } from 'react-native-elements';
import Icon from 'react-native-vector-icons/FontAwesome';
function LoginScreen({navigation}) {
return (
<View style={{
flex: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
}}>
{/*<Text style={styles.text}>Login Screen</Text>*/}
<Button
icon={{ name: "arrow-right", size: 35, color: "white" }}
title="StartGame"
onPress={() => navigation.navigate('Play')}
/>
</View>
);
}
function PlayScreen({navigation}) {
let [state, setState] = React.useState(state);
state = {
count: 0,
top: randomNumber(0,700),
left: randomNumber(-190,90),
}
const onPress = () => {
setState({
count: state.count + 1,
top: randomNumber(0,700),
left: randomNumber(-190,90),
});
}
return (
<View style={styles.buttonContainer} >
<View style={{position: 'absolute',
flex: 1,
height: 80,
width: 80,
margin: 10,
top: state.top,
left: state.left,
zIndex: 999,
// right:this.state.right,
// bottom:this.state.bottom,
}}>
<Button title="TESTE" onPress={onPress()} />
</View>
</View>
);
}
function GameOverScreen({navigation}) {
return (
<View style={{
flex: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
}}>
<Text style={styles.text}>Game Over</Text>
<Button
icon={{ name: "arrow-left", size: 35, color: "white" }}
title="Back"
onPress={() => navigation.replace('Login')}
/>
</View>
);
}
const Stack = createStackNavigator();
export default function App3() {
return (
<NavigationContainer>
<Stack.Navigator initalRouteName="Login">
<Stack.Screen name=" " component={LoginScreen} />
<Stack.Screen name="Play" component={PlayScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
fontSize: 50,
},
buttonContainer: {
flexDirection: 'row',
marginTop: 20,
},
});