-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
145 lines (129 loc) · 5.25 KB
/
App.js
File metadata and controls
145 lines (129 loc) · 5.25 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import React, { Component } from 'react';
import { View, Button, Alert } from 'react-native';
import { NavigationContainer, CommonActions } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as Font from 'expo-font';
//import Toast from 'react-native-simple-toast';
import { SharedState } from 'react-native-shared-state';
import Homescreen from "./components/Homescreen";
import Auto from "./components/Auto";
import Tele from "./components/Teleop.js";
import Endgame from "./components/Endgame.js";
import QR from "./components/QR.js";
const Stack = createStackNavigator();
export const ScoutingDataState = new SharedState({
name: "", match_number: 0, match_type: "", team_number: 0, alliance: "", preload: 0, highPortAuto: 0, lowPortAuto: 0, missedAuto: 0, highPortTele: 0, lowPortTele: 0,
missedTele: 0, attitude: "", colourWheelDone: false, colourWheelLanded: false, colourWheelWasRotated: false, climb: "", balance: "", num_climbs: 0, notes: ""
});
const MyTheme = {
dark: true,
colors: {
primary: "#B3861B",
border: "#B3861B",
card: "#B3861B",
background: "#262626",
text: "#FFFFFF"
}
}
function Home({navigation}) {
return (
<View>
<Homescreen />
<View style={{ width: "90%", marginLeft: "5%", marginTop: 25}}>
<Button title="Next" color="#B3861B" onPress={() => {
if(ScoutingDataState.state.name !== "" && ScoutingDataState.state.match_number !== 0 && ScoutingDataState.state.team_number !== 0 && ScoutingDataState.state.alliance !== "") {
navigation.navigate("Step 2")
} else {
//Toast.show("Make Sure You Fill Out All Fields!", Toast.LONG);
Alert.alert("Empty Fields", "Make Sure You Fill Out All Fields!");
}
}} />
</View>
</View>
)
}
function AutoScreen({navigation}) {
return (
<View>
<Auto/>
<View style={{ width: "90%", marginLeft: "5%", marginTop: 25}}>
<Button title="Autonomous Period Done: Next" color="#B3861B" onPress={() => navigation.navigate("Step 3")} />
</View>
</View>
)
}
function TeleopScreen({navigation}) {
return (
<View>
<Tele/>
<View style={{width: "90%", marginLeft: "5%", marginTop: 40}}>
<Button title="Tap here when the robot proceeds to climb" color="#B3861B" onPress={() => {
if(ScoutingDataState.state.attitude !== "") {
navigation.navigate("Step 4")
} else {
//Toast.show("Make sure you select a Robot Attitude!", Toast.LONG);
Alert.alert("Empty Fields", "Make sure you select a Robot Attitude!");
}
}} />
</View>
</View>
)
}
function EndgameScreen({navigation}) {
return (
<View>
<Endgame/>
<View>
<View style={{width: "90%", marginLeft: "5%", marginTop: 40}}>
<Button title="Match is done" color="#B3861B" onPress={() => {
if(ScoutingDataState.state.climb !== "" && ScoutingDataState.state.balance !== "") {
navigation.navigate("Step 5")
} else {
//Toast.show("Make sure you fill out if the robot has climbed and if it's balanced!", Toast.LONG);
Alert.alert("Empty Fields", "Make sure you fill out if the robot has climbed and if it's balanced!");
}
}} />
</View>
</View>
</View>
)
}
function QRScreen({navigation}) {
return (
<View style={{flex: 1}}>
<QR/>
<View style={{width: "90%", marginLeft: "5%", marginTop: 40, marginBottom: 40}}>
<Button title="Next Match" color="#B3861B" onPress={() => navigation.reset({index: 0, routes:[{ name: 'Step 1' }]})} />
</View>
</View>
)
}
class App extends Component {
state = { fontsLoaded: false };
async componentDidMount() {
await Font.loadAsync({
"Rajdhani-Medium": require("./assets/fonts/Rajdhani-Medium.ttf"),
"Rajdhani-Bold": require("./assets/fonts/Rajdhani-Bold.ttf")
});
this.setState({fontsLoaded: true})
}
render() {
const { fontsLoaded } = this.state;
if(fontsLoaded) {
return (
<NavigationContainer theme={MyTheme}>
<Stack.Navigator>
<Stack.Screen name="Step 1" component={Home}/>
<Stack.Screen name="Step 2" component={AutoScreen}/>
<Stack.Screen name="Step 3" component={TeleopScreen}/>
<Stack.Screen name="Step 4" component={EndgameScreen}/>
<Stack.Screen name="Step 5" component={QRScreen}/>
</Stack.Navigator>
</NavigationContainer>
)
} else {
return null;
}
}
}
export default App;