diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx
index d854b88..ea7a5a1 100644
--- a/src/routes/Home/Home.tsx
+++ b/src/routes/Home/Home.tsx
@@ -6,10 +6,11 @@ import {
ScrollView,
Switch,
ActivityIndicator,
+ TouchableHighlight,
} from "react-native";
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
import { useState, useEffect } from "react";
-import MapView, { Circle, Marker, UrlTile } from "react-native-maps";
+import MapView, { Callout, Circle, Marker, UrlTile } from "react-native-maps";
import * as Location from "expo-location";
import GetDistance from "../../components/GetDistance/GetDistance";
import Button from "../../components/Button/Button";
@@ -45,6 +46,7 @@ import DropdownIcon from "../../icons/CaretDownIcon/CaretDownIcon";
import CaretUpIcon from "../../icons/CaretUpIcon/CaretUpIcon";
import RefreshIcon from "../../icons/RefreshIcon/RefreshIcon";
import AsyncStorage from "@react-native-async-storage/async-storage";
+import AnimatedContainerNoScroll from "../../components/AnimatedContainer/AnimatedContainerNoScroll";
export default function Home() {
// Switch this condition to see the main map when debugging
@@ -84,16 +86,15 @@ export default function Home() {
async function requestLocation() {
if (locationPermitted) {
let newLocation = await Location.getCurrentPositionAsync();
- if (newLocation) {
- setLocation(newLocation);
- await DistanceHandler(newLocation);
- }
+
+ setLocation(newLocation);
+ await DistanceHandler(newLocation);
}
}
useEffect(() => {
- console.log("changed");
- console.log(locationPermitted);
+ // console.log("Location Update");
+ // console.log(locationPermitted);
requestLocation();
}, [locationPermitted]);
@@ -111,7 +112,7 @@ export default function Home() {
let dist = GetDistanceFromUSTP(location.coords);
setDist(dist);
// Deactivate student status if too far away from USTP and still studying
- if (dist >= 2 && !map_distance_override && studying && !stopping_toofar) {
+ if (dist >= 1 && !map_distance_override && studying && !stopping_toofar) {
stop_studying.mutate({
active: false,
});
@@ -153,14 +154,7 @@ export default function Home() {
location.coords.latitude,
location.coords.longitude
);
- console.log("Distance:", dist);
- console.log(
- student_status.location.latitude,
- student_status.location.longitude,
- location.coords.latitude,
- location.coords.longitude
- );
- if (dist > 0.02 && studying && !stopping_toofar) {
+ if (dist > 0.5 && studying && !stopping_toofar) {
console.log("Too far from current studying location");
stop_studying.mutate({
active: false,
@@ -412,8 +406,21 @@ export default function Home() {
Loading...
>
);
+ } else if (
+ study_groups == undefined ||
+ study_groups_global == undefined ||
+ student_statuses == undefined ||
+ student_statuses_global == undefined
+ ) {
+ return (
+ <>
+
+
+ Loading...
+ >
+ );
} else if (dist && location) {
- if (dist <= 1 || map_distance_override) {
+ if (dist <= 0.25 || map_distance_override) {
return (
<>
{
toast.hideAll();
+
toast.show(
+ >
+
+
+ Student: {student_status.user}
+
+
+ {`Studying ${student_status.subject}`}
+
+
+ {`${Math.round(
+ GetDistance(
+ student_status.location.latitude,
+ student_status.location.longitude,
+ location.coords.latitude,
+ location.coords.longitude
+ ) * 1000
+ )}m away`}
+
+
+
);
}
)
@@ -581,6 +608,7 @@ export default function Home() {
zIndex={1000}
onPress={() => {
toast.hideAll();
+
toast.show(
+ >
+
+
+ Study Group: {studygroup.name}
+
+
+ Studying: {studygroup.subject}
+
+ {studygroup.landmark ? (
+
+ {studygroup.landmark}
+
+ ) : (
+ <>>
+ )}
+
+ {`${studygroup.students.length} ${
+ studygroup.students.length > 1
+ ? "students"
+ : "student"
+ } studying`}
+
+
+ {`${Math.round(
+ studygroup.distance * 1000
+ )}m away`}
+
+
+
+ >
+
+
+ Study Group: {studygroup.name}
+
+
+ Studying: {studygroup.subject}
+
+ {studygroup.landmark ? (
+
+ {studygroup.landmark}
+
+ ) : (
+ <>>
+ )}
+
+ {`${studygroup.students.length} ${
+ studygroup.students.length > 1
+ ? "students"
+ : "student"
+ } studying`}
+
+
+ {`${Math.round(
+ GetDistance(
+ studygroup.location.latitude,
+ studygroup.location.longitude,
+ location.coords.latitude,
+ location.coords.longitude
+ )
+ )}m away`}
+
+
+
{`${Math.round(student_status.distance * 1000)}m away`}
+ {location && location.coords ? (
+
+ {`${Math.round(
+ GetDistance(
+ student_status.location.latitude,
+ student_status.location.longitude,
+ location.coords.latitude,
+ location.coords.longitude
+ )
+ )}m away`}
+
+ ) : (
+ <>>
+ )}
);
}
@@ -1063,12 +1166,12 @@ export default function Home() {
Group Name: {studygroup.name}
{studygroup.landmark ? (
-
- {studygroup.landmark}
-
- ) : (
- <>>
- )}
+
+ {studygroup.landmark}
+
+ ) : (
+ <>>
+ )}
{`Studying ${studygroup.subject}`}
@@ -1186,6 +1289,20 @@ export default function Home() {
{`Studying ${student_status.subject}`}
+ {location && location.coords ? (
+
+ {`${Math.round(
+ GetDistance(
+ student_status.location.latitude,
+ student_status.location.longitude,
+ location.coords.latitude,
+ location.coords.longitude
+ )
+ )}m away`}
+
+ ) : (
+ <>>
+ )}
);
}
@@ -1215,18 +1332,32 @@ export default function Home() {
Group Name: {studygroup.name}
{studygroup.landmark ? (
-
- {studygroup.landmark}
-
- ) : (
- <>>
- )}
+
+ {studygroup.landmark}
+
+ ) : (
+ <>>
+ )}
{`Studying ${studygroup.subject}`}
Students Studying: {studygroup.students.length}
+ {location && location.coords ? (
+
+ {`${Math.round(
+ GetDistance(
+ studygroup.location.latitude,
+ studygroup.location.longitude,
+ location.coords.latitude,
+ location.coords.longitude
+ )
+ )}m away`}
+
+ ) : (
+ <>>
+ )}
);
}
@@ -1237,6 +1368,7 @@ export default function Home() {
+