Skip to content

Commit 644eb83

Browse files
authored
Merge pull request #29 from Wayfinder-CS262-2020/code-touch-ups
Touched up the code in preparation for a final release
2 parents 8c70788 + 308a17e commit 644eb83

File tree

7 files changed

+62
-59
lines changed

7 files changed

+62
-59
lines changed

App.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
import { StatusBar } from "expo-status-bar";
21
import React, { useState } from "react";
32
import {
43
StyleSheet,
54
View,
65
TouchableWithoutFeedback,
76
Keyboard,
8-
Text,
97
} from "react-native";
108
import * as Font from "expo-font";
119

1210
import { NavigationContainer } from "@react-navigation/native";
13-
import { createStackNavigator } from "@react-navigation/stack";
14-
15-
import Header from "./components/header";
16-
import Content from "./components/content";
1711

1812
import Navigator from "./routes/homeStack";
1913
import { AppLoading } from "expo";
2014

15+
// Load the fonts
2116
const getFonts = () =>
2217
Font.loadAsync({
2318
"lusitana-bold": require("./assets/fonts/Lusitana/Lusitana-Bold.ttf"),
@@ -35,23 +30,12 @@ export default function App() {
3530
Keyboard.dismiss();
3631
}}
3732
>
38-
{/* Make a view for the background and open screens with navigator */}
39-
33+
{/* View for the background and open screens with navigator */}
4034
<View style={styles.container}>
4135
<NavigationContainer>
4236
<Navigator />
4337
</NavigationContainer>
4438
</View>
45-
46-
{/*
47-
48-
Home
49-
<View style={styles.content}>
50-
Content
51-
<LoginScreen />
52-
</View>
53-
</View>
54-
*/}
5539
</TouchableWithoutFeedback>
5640
);
5741
} else {
@@ -64,6 +48,5 @@ export default function App() {
6448
const styles = StyleSheet.create({
6549
container: {
6650
flex: 1,
67-
// backgroundColor: "yellow", //"#2D2D2D",
6851
},
6952
});

routes/homeStack.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Icon } from "react-native-elements";
1313
const Stack = createStackNavigator();
1414
export default function HomeStack() {
1515
return (
16+
// Login Screen
1617
<Stack.Navigator>
1718
<Stack.Screen
1819
name="Login"
@@ -22,13 +23,17 @@ export default function HomeStack() {
2223
headerShown: false,
2324
}}
2425
/>
26+
27+
{/* Map Screen */}
2528
<Stack.Screen
2629
name="Map"
2730
component={MapScreen}
2831
options={{
2932
headerShown: false,
3033
}}
3134
/>
35+
36+
{/* Interior Screen */}
3237
<Stack.Screen
3338
name="Interior"
3439
component={InteriorScreen}
@@ -37,6 +42,7 @@ export default function HomeStack() {
3742
headerBackImage: () => (
3843
<Icon name="keyboard-arrow-left" size={32} color="white" />
3944
),
45+
// This code customizes the header to display the building/room
4046
headerTitle: (props) => (
4147
<Text
4248
{...props}
@@ -50,6 +56,8 @@ export default function HomeStack() {
5056
),
5157
})}
5258
/>
59+
60+
{/* Sign up screen */}
5361
<Stack.Screen
5462
name="Sign Up"
5563
component={SignUpScreen}
@@ -68,6 +76,8 @@ export default function HomeStack() {
6876
),
6977
})}
7078
/>
79+
80+
{/* Info Screen */}
7181
<Stack.Screen
7282
name="Info"
7383
component={InfoScreen}

screens/infoScreen.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import { StyleSheet, Text, View, Image, ScrollView } from "react-native";
33

4-
//eslint ignore
54
<link rel="stylesheet" href="https://use.typekit.net/spw7ajb.css"></link>;
65

76
export default function InfoScreen({ navigation }) {

screens/interiorScreen.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ import { useRoute } from "@react-navigation/native";
1515
const assets = require("../assets/assets.js");
1616

1717
export default function interiorScreen(navigation, route) {
18+
const debug = false;
19+
1820
// Route fix
1921
route = useRoute();
22+
23+
// Grabe the building code from the provided pamrameters
2024
const buildingCode = route.params.code;
25+
26+
// Set the initial floor to the provided floor number if it exists, otherwise set it to 1
2127
const [currentFloor, setCurrentFloor] = useState(
2228
String(buildingCode) +
2329
(route.params.floor !== undefined ? String(route.params.floor) : "1")
@@ -48,12 +54,19 @@ export default function interiorScreen(navigation, route) {
4854
setCurrentFloor(newFloor);
4955
}
5056
};
51-
useEffect(() => {
52-
console.log(currentFloor.substring(2, 3));
53-
console.log(route.params.floor);
54-
console.log(route.params.floor <= parseInt(currentFloor.substring(2, 3)));
55-
});
56-
console.log(route.params.xCoord - 64, route.params.yCoord - 32);
57+
58+
debug &&
59+
useEffect(() => {
60+
debug && console.log(currentFloor.substring(2, 3));
61+
debug && console.log(route.params.floor);
62+
debug &&
63+
console.log(
64+
route.params.floor <= parseInt(currentFloor.substring(2, 3))
65+
);
66+
});
67+
68+
debug && console.log(route.params.xCoord - 64, route.params.yCoord - 32);
69+
5770
return (
5871
// Main interior screen
5972
<View style={styles.main}>
@@ -93,7 +106,6 @@ export default function interiorScreen(navigation, route) {
93106
</View>
94107

95108
{/* Up button */}
96-
{/* <View style={styles.button, route.params.floor <= parseInt(currentFloor.substring(2, 3)) ? styles.dark : styles.light}> */}
97109
<View style={styles.button}>
98110
<TouchableOpacity onPress={() => goUp()}>
99111
<Icon
@@ -140,7 +152,6 @@ const styles = StyleSheet.create({
140152
buttonContainer: {
141153
marginLeft: Dimensions.get("window").width * 0.8,
142154
marginTop: Dimensions.get("window").height * 0.65,
143-
// justifyContent: "space-around",
144155
position: "absolute",
145156
},
146157
button: {
@@ -164,7 +175,6 @@ const styles = StyleSheet.create({
164175
marginBottom: 10,
165176
},
166177
chip: {
167-
// justify: "center",
168178
color: "white",
169179
padding: 14,
170180
paddingLeft: 20,

screens/loginScreen.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ import {
1515
} from "react-native";
1616
import { Icon } from "react-native-elements";
1717

18-
//eslint ignore
1918
<link rel="stylesheet" href="https://use.typekit.net/spw7ajb.css"></link>;
2019

2120
export default function LoginScreen({ navigation }) {
21+
const debug = false;
22+
2223
const [username, setUsername] = useState("");
2324
const [password, setPassword] = useState("");
2425

@@ -41,17 +42,22 @@ export default function LoginScreen({ navigation }) {
4142
password: password,
4243
}),
4344
};
45+
46+
// Fetch the login information from the service
4447
await fetch(
4548
"https://wayfinder-service.herokuapp.com/auth/login/",
4649
requestOptions
4750
)
4851
.then((request) => request.json())
52+
53+
// Log user in if they have a valid access token
4954
.then((data) => {
50-
console.log(data);
55+
debug && console.log(data);
5156
if (data.accessToken !== undefined) {
5257
navigation.navigate("Map");
5358
}
5459
})
60+
// User does not have a valid access token
5561
.catch((err) =>
5662
Alert.alert(
5763
"Error",
@@ -60,6 +66,7 @@ export default function LoginScreen({ navigation }) {
6066
)
6167
);
6268
} else {
69+
// User did not input a valid username/password
6370
setUsername(username.toLowerCase());
6471
Alert.alert(
6572
"Error",

0 commit comments

Comments
 (0)