mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-04-20 17:01:22 +08:00
Compare commits
No commits in common. "master" and "v0.9.3.5-beta" have entirely different histories.
master
...
v0.9.3.5-b
10 changed files with 1466 additions and 488 deletions
1403
package-lock.json
generated
1403
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -26,7 +26,7 @@
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"moti": "^0.25.3",
|
"moti": "^0.25.3",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-native": "0.71.14",
|
"react-native": "0.71.13",
|
||||||
"react-native-bouncy-checkbox": "^3.0.7",
|
"react-native-bouncy-checkbox": "^3.0.7",
|
||||||
"react-native-dropdown-picker": "^5.4.6",
|
"react-native-dropdown-picker": "^5.4.6",
|
||||||
"react-native-gesture-handler": "~2.9.0",
|
"react-native-gesture-handler": "~2.9.0",
|
||||||
|
|
|
@ -143,7 +143,7 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
<DrawerButton
|
<DrawerButton
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
// We don't clear student statuses when logging out on debug
|
// We don't clear student statuses when logging out on debug
|
||||||
if (debug) {
|
if (!debug) {
|
||||||
queryClient.clear();
|
queryClient.clear();
|
||||||
dispatch(logout());
|
dispatch(logout());
|
||||||
await AsyncStorage.clear();
|
await AsyncStorage.clear();
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { IconProps } from "../../interfaces/Interfaces";
|
||||||
import { Svg, Path } from "react-native-svg";
|
import { Svg, Path } from "react-native-svg";
|
||||||
import { colors } from "../../styles";
|
import { colors } from "../../styles";
|
||||||
|
|
||||||
export default function CaretRightIcon(props: IconProps) {
|
export default function CaretLeftIcon(props: IconProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Svg
|
<Svg
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
import * as React from "react";
|
|
||||||
import { IconProps } from "../../interfaces/Interfaces";
|
|
||||||
import { Svg, Path } from "react-native-svg";
|
|
||||||
import { colors } from "../../styles";
|
|
||||||
|
|
||||||
export default function CaretRightIcon(props: IconProps) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Svg
|
|
||||||
height={props.size + "px"}
|
|
||||||
width={props.size + "px"}
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="2"
|
|
||||||
stroke={colors.icon_color}
|
|
||||||
fill="none"
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
>
|
|
||||||
<Path stroke="none" d="M0 0h24v24H0z" fill="none"></Path>
|
|
||||||
<Path
|
|
||||||
d="M13.883 5.007l.058 -.005h.118l.058 .005l.06 .009l.052 .01l.108 .032l.067 .027l.132 .07l.09 .065l.081 .073l.083 .094l.054 .077l.054 .096l.017 .036l.027 .067l.032 .108l.01 .053l.01 .06l.004 .057l.002 .059v12c0 .852 -.986 1.297 -1.623 .783l-.084 -.076l-6 -6a1 1 0 0 1 -.083 -1.32l.083 -.094l6 -6l.094 -.083l.077 -.054l.096 -.054l.036 -.017l.067 -.027l.108 -.032l.053 -.01l.06 -.01z"
|
|
||||||
stroke-width="0"
|
|
||||||
fill={colors.icon_color}
|
|
||||||
></Path>
|
|
||||||
</Svg>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { ActivityIndicator, Image, Pressable } from "react-native";
|
import { ActivityIndicator, Image } from "react-native";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
|
@ -36,7 +36,6 @@ import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContai
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { RootState } from "../../features/redux/Store/Store";
|
import { RootState } from "../../features/redux/Store/Store";
|
||||||
import CaretRightIcon from "../../icons/CaretLeftIcon/CaretLeftIcon";
|
|
||||||
|
|
||||||
export default function ConversationPage() {
|
export default function ConversationPage() {
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
@ -71,7 +70,6 @@ export default function ConversationPage() {
|
||||||
enabled:
|
enabled:
|
||||||
student_status?.study_group != "" && student_status?.study_group != null,
|
student_status?.study_group != "" && student_status?.study_group != null,
|
||||||
queryKey: ["study_group"],
|
queryKey: ["study_group"],
|
||||||
refetchInterval: 10000,
|
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const data = await GetStudyGroup(student_status?.study_group || "");
|
const data = await GetStudyGroup(student_status?.study_group || "");
|
||||||
if (data[0] == false) {
|
if (data[0] == false) {
|
||||||
|
@ -129,7 +127,7 @@ export default function ConversationPage() {
|
||||||
// Avatar List
|
// Avatar List
|
||||||
const [users, setUsers] = useState<GroupMessageAvatarType[]>([]);
|
const [users, setUsers] = useState<GroupMessageAvatarType[]>([]);
|
||||||
const AvatarsQuery = useQuery({
|
const AvatarsQuery = useQuery({
|
||||||
refetchInterval: 10000,
|
refetchInterval: 3000,
|
||||||
enabled:
|
enabled:
|
||||||
student_status?.study_group != null ||
|
student_status?.study_group != null ||
|
||||||
(student_status?.study_group != "" &&
|
(student_status?.study_group != "" &&
|
||||||
|
@ -164,7 +162,7 @@ export default function ConversationPage() {
|
||||||
mutationFn: async (info: MessagePostType) => {
|
mutationFn: async (info: MessagePostType) => {
|
||||||
const data = await PostMessage(info);
|
const data = await PostMessage(info);
|
||||||
if (data[0] != true) {
|
if (data[0] != true) {
|
||||||
return Promise.reject(new Error(data[1]));
|
return Promise.reject(new Error());
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -200,17 +198,9 @@ export default function ConversationPage() {
|
||||||
>
|
>
|
||||||
<View style={styles.flex_row}>
|
<View style={styles.flex_row}>
|
||||||
<Text style={{ ...styles.text_white_medium }}>
|
<Text style={{ ...styles.text_white_medium }}>
|
||||||
{`Group: ${studygroup?.name ? studygroup.name : "Loading..."}`}
|
{`Group: ${studygroup?.name ? studygroup.name : ""}`}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={{...styles.text_white_tiny_bold,...{textAlign:'left'}}}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View style={{ ...styles.flex_row }}>
|
<View style={{ ...styles.flex_row }}>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
|
@ -219,9 +209,7 @@ export default function ConversationPage() {
|
||||||
paddingRight: 4,
|
paddingRight: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!StudyGroupQuery.isFetching
|
{studygroup.students.length} studying
|
||||||
? studygroup.students.length + " studying"
|
|
||||||
: "Loading"}
|
|
||||||
</Text>
|
</Text>
|
||||||
{users.map((user: GroupMessageAvatarType, index: number) => {
|
{users.map((user: GroupMessageAvatarType, index: number) => {
|
||||||
if (index > 6) {
|
if (index > 6) {
|
||||||
|
@ -305,7 +293,6 @@ export default function ConversationPage() {
|
||||||
<Text style={styles.text_white_small}>There are no messages</Text>
|
<Text style={styles.text_white_small}>There are no messages</Text>
|
||||||
)}
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<View style={styles.flex_row}>
|
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.chatbox}
|
style={styles.chatbox}
|
||||||
placeholder="Send a message..."
|
placeholder="Send a message..."
|
||||||
|
@ -323,23 +310,6 @@ export default function ConversationPage() {
|
||||||
setMessage("");
|
setMessage("");
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Pressable
|
|
||||||
style={{
|
|
||||||
backgroundColor: colors.secondary_3,
|
|
||||||
borderRadius: 16,
|
|
||||||
alignSelf: "center",
|
|
||||||
marginLeft: 16,
|
|
||||||
}}
|
|
||||||
onPress={() => {
|
|
||||||
send_message.mutate({
|
|
||||||
message_content: message,
|
|
||||||
});
|
|
||||||
setMessage("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<CaretRightIcon size={48} />
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
</AnimatedContainer>
|
</AnimatedContainer>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,7 +24,6 @@ import MapView, { UrlTile, Marker } from "react-native-maps";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
import CaretLeftIcon from "../../icons/CaretLeftIcon/CaretLeftIcon";
|
import CaretLeftIcon from "../../icons/CaretLeftIcon/CaretLeftIcon";
|
||||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
|
||||||
|
|
||||||
export default function CreateGroup({ route }: any) {
|
export default function CreateGroup({ route }: any) {
|
||||||
const { location, subject } = route.params;
|
const { location, subject } = route.params;
|
||||||
|
@ -83,9 +82,9 @@ export default function CreateGroup({ route }: any) {
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
// Set a delay before going back to conversation page to hopefully let the queries refresh in time
|
// Set a delay before going back to homepage to hopefully let the queries refresh in time
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
navigation.navigate("Conversation");
|
navigation.navigate("Home");
|
||||||
}, 200);
|
}, 200);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
|
@ -101,7 +100,7 @@ export default function CreateGroup({ route }: any) {
|
||||||
if (location) {
|
if (location) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainer>
|
<AnimatedContainerNoScroll>
|
||||||
<View style={{ zIndex: -1 }}>
|
<View style={{ zIndex: -1 }}>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
||||||
|
@ -184,7 +183,7 @@ export default function CreateGroup({ route }: any) {
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
</AnimatedContainer>
|
</AnimatedContainerNoScroll>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,10 @@ import {
|
||||||
ScrollView,
|
ScrollView,
|
||||||
Switch,
|
Switch,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
TouchableHighlight,
|
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import MapView, { Callout, Circle, Marker, UrlTile } from "react-native-maps";
|
import MapView, { Circle, Marker, UrlTile } from "react-native-maps";
|
||||||
import * as Location from "expo-location";
|
import * as Location from "expo-location";
|
||||||
import GetDistance from "../../components/GetDistance/GetDistance";
|
import GetDistance from "../../components/GetDistance/GetDistance";
|
||||||
import Button from "../../components/Button/Button";
|
import Button from "../../components/Button/Button";
|
||||||
|
@ -45,8 +44,6 @@ import Modal from "react-native-modal";
|
||||||
import DropdownIcon from "../../icons/CaretDownIcon/CaretDownIcon";
|
import DropdownIcon from "../../icons/CaretDownIcon/CaretDownIcon";
|
||||||
import CaretUpIcon from "../../icons/CaretUpIcon/CaretUpIcon";
|
import CaretUpIcon from "../../icons/CaretUpIcon/CaretUpIcon";
|
||||||
import RefreshIcon from "../../icons/RefreshIcon/RefreshIcon";
|
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() {
|
export default function Home() {
|
||||||
// Switch this condition to see the main map when debugging
|
// Switch this condition to see the main map when debugging
|
||||||
|
@ -64,7 +61,7 @@ export default function Home() {
|
||||||
const [modalOpen, setModalOpen] = useState(false);
|
const [modalOpen, setModalOpen] = useState(false);
|
||||||
const [modalByGroup, setModalByGroup] = useState(false);
|
const [modalByGroup, setModalByGroup] = useState(false);
|
||||||
|
|
||||||
async function requestLocationPermission() {
|
async function requestLocation() {
|
||||||
const { status } = await Location.requestForegroundPermissionsAsync();
|
const { status } = await Location.requestForegroundPermissionsAsync();
|
||||||
if (status !== "granted") {
|
if (status !== "granted") {
|
||||||
setFeedback("Allow location permissions to continue");
|
setFeedback("Allow location permissions to continue");
|
||||||
|
@ -78,32 +75,44 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
if (status == "granted") {
|
||||||
|
if (locationPermitted === false) {
|
||||||
setLocationPermitted(true);
|
setLocationPermitted(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function requestLocation() {
|
|
||||||
if (locationPermitted) {
|
|
||||||
let newLocation = await Location.getCurrentPositionAsync();
|
let newLocation = await Location.getCurrentPositionAsync();
|
||||||
|
if (newLocation) {
|
||||||
|
// Only update location state if user's location has changed
|
||||||
|
if (
|
||||||
|
!location ||
|
||||||
|
newLocation.coords.latitude !== location.coords.latitude ||
|
||||||
|
newLocation.coords.longitude !== location.coords.longitude
|
||||||
|
) {
|
||||||
setLocation(newLocation);
|
setLocation(newLocation);
|
||||||
await DistanceHandler(newLocation);
|
await DistanceHandler(newLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
// Refresh every 10 seconds
|
||||||
// console.log("Location Update");
|
|
||||||
// console.log(locationPermitted);
|
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, [locationPermitted]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
requestLocationPermission();
|
|
||||||
// Refresh every 30 seconds
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
setTimeout(() => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["user_status_list"],
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["study_group_list"],
|
||||||
|
});
|
||||||
|
requestLocation();
|
||||||
|
}, 2000);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -111,8 +120,8 @@ export default function Home() {
|
||||||
async function DistanceHandler(location: RawLocationType) {
|
async function DistanceHandler(location: RawLocationType) {
|
||||||
let dist = GetDistanceFromUSTP(location.coords);
|
let dist = GetDistanceFromUSTP(location.coords);
|
||||||
setDist(dist);
|
setDist(dist);
|
||||||
// Deactivate student status if too far away from USTP and still studying
|
// Deactivate student status if too far away and still studying
|
||||||
if (dist >= 1 && !map_distance_override && studying && !stopping_toofar) {
|
if (dist >= 2 && !map_distance_override && studying && !stopping_toofar) {
|
||||||
stop_studying.mutate({
|
stop_studying.mutate({
|
||||||
active: false,
|
active: false,
|
||||||
});
|
});
|
||||||
|
@ -120,9 +129,6 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clear_messages_notification_cache() {
|
|
||||||
AsyncStorage.setItem("messages", "");
|
|
||||||
}
|
|
||||||
// Student Status
|
// Student Status
|
||||||
const [studying, setStudying] = useState(false);
|
const [studying, setStudying] = useState(false);
|
||||||
const [subject, setSubject] = useState("");
|
const [subject, setSubject] = useState("");
|
||||||
|
@ -146,22 +152,6 @@ export default function Home() {
|
||||||
setSubject(data[1].subject);
|
setSubject(data[1].subject);
|
||||||
setStudying(data[1].active);
|
setStudying(data[1].active);
|
||||||
setStudentStatus(data[1]);
|
setStudentStatus(data[1]);
|
||||||
// Deactivate student status if too far away from current location you are studying in
|
|
||||||
if (student_status && location) {
|
|
||||||
const dist = GetDistance(
|
|
||||||
student_status.location.latitude,
|
|
||||||
student_status.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
);
|
|
||||||
if (dist > 0.5 && studying && !stopping_toofar) {
|
|
||||||
console.log("Too far from current studying location");
|
|
||||||
stop_studying.mutate({
|
|
||||||
active: false,
|
|
||||||
});
|
|
||||||
setStopping(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
@ -177,7 +167,7 @@ export default function Home() {
|
||||||
mutationFn: async (info: StudentStatusPatchType) => {
|
mutationFn: async (info: StudentStatusPatchType) => {
|
||||||
const data = await PatchStudentStatus(info);
|
const data = await PatchStudentStatus(info);
|
||||||
if (data[0] != true) {
|
if (data[0] != true) {
|
||||||
return Promise.reject(new Error(JSON.stringify(data[1])));
|
return Promise.reject(new Error());
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -207,7 +197,9 @@ export default function Home() {
|
||||||
}, 500);
|
}, 500);
|
||||||
setStudyGroups([]);
|
setStudyGroups([]);
|
||||||
setStudying(false);
|
setStudying(false);
|
||||||
|
if (stopping_toofar) {
|
||||||
setStopping(false);
|
setStopping(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
@ -228,7 +220,7 @@ export default function Home() {
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
if (student_status?.study_group == "") {
|
if (student_status?.study_group) {
|
||||||
// Display separate toast if you stop studying while in a study group
|
// Display separate toast if you stop studying while in a study group
|
||||||
toast.show("You left study group \n" + student_status?.study_group, {
|
toast.show("You left study group \n" + student_status?.study_group, {
|
||||||
type: "success",
|
type: "success",
|
||||||
|
@ -236,9 +228,7 @@ export default function Home() {
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
clear_messages_notification_cache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
|
||||||
// Delay refetching for study groups since backend still needs to delete groups without students after leaving a study group
|
// Delay refetching for study groups since backend still needs to delete groups without students after leaving a study group
|
||||||
|
@ -390,27 +380,12 @@ export default function Home() {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
(!StudentStatusQuery.isSuccess &&
|
(StudentStatusQuery.isFetching && studying) ||
|
||||||
studying &&
|
StudentStatusListQuery.isFetching ||
|
||||||
!StudentStatusListQuery.isSuccess &&
|
StudyGroupQuery.isFetching ||
|
||||||
!StudyGroupQuery.isSuccess) ||
|
(StudentStatusQuery.isFetching && !studying) ||
|
||||||
(!StudentStatusQuery.isSuccess &&
|
StudentStatusListGlobalQuery.isFetching ||
|
||||||
!studying &&
|
StudyGroupGlobalQuery.isFetching
|
||||||
!StudentStatusListGlobalQuery.isSuccess &&
|
|
||||||
!StudyGroupGlobalQuery.isSuccess)
|
|
||||||
) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<View style={{ paddingVertical: 8 }} />
|
|
||||||
<ActivityIndicator size={96} color={colors.secondary_1} />
|
|
||||||
<Text style={styles.text_white_medium}>Loading...</Text>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
} else if (
|
|
||||||
study_groups == undefined ||
|
|
||||||
study_groups_global == undefined ||
|
|
||||||
student_statuses == undefined ||
|
|
||||||
student_statuses_global == undefined
|
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -420,9 +395,25 @@ export default function Home() {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else if (dist && location) {
|
} else if (dist && location) {
|
||||||
if (dist <= 0.25 || map_distance_override) {
|
if (dist <= 1 || map_distance_override) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<View style={{ alignSelf: "flex-end" }}>
|
||||||
|
<Pressable
|
||||||
|
onPress={() => {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["user_status_list"],
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["study_group_list"],
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RefreshIcon size={32} />
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
<MapView
|
<MapView
|
||||||
mapType={"none"}
|
mapType={"none"}
|
||||||
style={styles.map}
|
style={styles.map}
|
||||||
|
@ -479,7 +470,6 @@ export default function Home() {
|
||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
toast.hideAll();
|
toast.hideAll();
|
||||||
|
|
||||||
toast.show(
|
toast.show(
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
@ -508,26 +498,7 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<Callout>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
Student: {student_status.user}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{`Studying ${student_status.subject}`}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
GetDistance(
|
|
||||||
student_status.location.latitude,
|
|
||||||
student_status.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
) * 1000
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
</Callout>
|
|
||||||
</Marker>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -608,7 +579,6 @@ export default function Home() {
|
||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
toast.hideAll();
|
toast.hideAll();
|
||||||
|
|
||||||
toast.show(
|
toast.show(
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
@ -620,13 +590,6 @@ export default function Home() {
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
Study Group: {studygroup.name}
|
Study Group: {studygroup.name}
|
||||||
</Text>
|
</Text>
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
{`Studying ${studygroup.subject}`}
|
{`Studying ${studygroup.subject}`}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -651,7 +614,6 @@ export default function Home() {
|
||||||
study_group: studygroup.name,
|
study_group: studygroup.name,
|
||||||
subject: studygroup.subject,
|
subject: studygroup.subject,
|
||||||
});
|
});
|
||||||
navigation.navigate("Conversation");
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
|
@ -691,35 +653,7 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<Callout>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
Study Group: {studygroup.name}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
Studying: {studygroup.subject}
|
|
||||||
</Text>
|
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${studygroup.students.length} ${
|
|
||||||
studygroup.students.length > 1
|
|
||||||
? "students"
|
|
||||||
: "student"
|
|
||||||
} studying`}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
studygroup.distance * 1000
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
</Callout>
|
|
||||||
</Marker>
|
|
||||||
<Circle
|
<Circle
|
||||||
center={studygroup.location}
|
center={studygroup.location}
|
||||||
radius={studygroup.radius}
|
radius={studygroup.radius}
|
||||||
|
@ -762,13 +696,6 @@ export default function Home() {
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
Study Group: {studygroup.name}
|
Study Group: {studygroup.name}
|
||||||
</Text>
|
</Text>
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
{`Studying ${studygroup.subject}`}
|
{`Studying ${studygroup.subject}`}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -801,40 +728,7 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<Callout>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
Study Group: {studygroup.name}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
Studying: {studygroup.subject}
|
|
||||||
</Text>
|
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${studygroup.students.length} ${
|
|
||||||
studygroup.students.length > 1
|
|
||||||
? "students"
|
|
||||||
: "student"
|
|
||||||
} studying`}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
GetDistance(
|
|
||||||
studygroup.location.latitude,
|
|
||||||
studygroup.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
)
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
</Callout>
|
|
||||||
</Marker>
|
|
||||||
<Circle
|
<Circle
|
||||||
center={studygroup.location}
|
center={studygroup.location}
|
||||||
radius={studygroup.radius}
|
radius={studygroup.radius}
|
||||||
|
@ -984,40 +878,9 @@ export default function Home() {
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_small}>{buttonLabel}</Text>
|
<Text style={styles.text_white_small}>{buttonLabel}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
backgroundColor: colors.secondary_3,
|
|
||||||
borderRadius: 16,
|
|
||||||
alignSelf: "center",
|
|
||||||
marginHorizontal: 8,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Pressable
|
|
||||||
onPress={() => {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: ["user_status"],
|
|
||||||
});
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: ["user_status_list"],
|
|
||||||
});
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: ["study_group_list"],
|
|
||||||
});
|
|
||||||
toast.show("Refreshed", {
|
|
||||||
type: "success",
|
|
||||||
placement: "top",
|
|
||||||
duration: 2000,
|
|
||||||
animationType: "slide-in",
|
|
||||||
});
|
|
||||||
requestLocation();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<RefreshIcon size={32} />
|
|
||||||
</Pressable>
|
|
||||||
</View>
|
|
||||||
<Pressable
|
<Pressable
|
||||||
style={{
|
style={{
|
||||||
|
display: modalOpen ? "none" : "flex",
|
||||||
backgroundColor: colors.secondary_3,
|
backgroundColor: colors.secondary_3,
|
||||||
borderRadius: 16,
|
borderRadius: 16,
|
||||||
alignSelf: "center",
|
alignSelf: "center",
|
||||||
|
@ -1026,7 +889,7 @@ export default function Home() {
|
||||||
setModalOpen(true);
|
setModalOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CaretUpIcon size={32} />
|
{studying ? <CaretUpIcon size={32} /> : <></>}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
{student_status?.active && !student_status?.study_group ? (
|
{student_status?.active && !student_status?.study_group ? (
|
||||||
|
@ -1055,8 +918,6 @@ export default function Home() {
|
||||||
return <MapRendererFar location={location.coords} dist={dist} />;
|
return <MapRendererFar location={location.coords} dist={dist} />;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requestLocationPermission();
|
|
||||||
requestLocation();
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={{ paddingVertical: 8 }} />
|
<View style={{ paddingVertical: 8 }} />
|
||||||
|
@ -1085,15 +946,14 @@ export default function Home() {
|
||||||
>
|
>
|
||||||
<DropdownIcon size={32} />
|
<DropdownIcon size={32} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<View style={styles.flex_column}>
|
<View style={styles.flex_row}>
|
||||||
<Text style={styles.text_white_medium}>List View</Text>
|
|
||||||
<Switch
|
<Switch
|
||||||
value={modalByGroup}
|
value={modalByGroup}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
setModalByGroup(!modalByGroup);
|
setModalByGroup(!modalByGroup);
|
||||||
}}
|
}}
|
||||||
style={{ alignSelf: "center" }}
|
|
||||||
/>
|
/>
|
||||||
|
<Text style={styles.text_white_medium}>List View</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
|
@ -1112,7 +972,6 @@ export default function Home() {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderRadius: 16,
|
borderRadius: 16,
|
||||||
width: 256,
|
width: 256,
|
||||||
marginVertical: 4,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
|
@ -1124,20 +983,6 @@ export default function Home() {
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
{`${Math.round(student_status.distance * 1000)}m away`}
|
{`${Math.round(student_status.distance * 1000)}m away`}
|
||||||
</Text>
|
</Text>
|
||||||
{location && location.coords ? (
|
|
||||||
<Text style={styles.text_black_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
GetDistance(
|
|
||||||
student_status.location.latitude,
|
|
||||||
student_status.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
)
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1159,19 +1004,11 @@ export default function Home() {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderRadius: 16,
|
borderRadius: 16,
|
||||||
width: 256,
|
width: 256,
|
||||||
marginVertical: 4,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
Group Name: {studygroup.name}
|
Group Name: {studygroup.name}
|
||||||
</Text>
|
</Text>
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
{`Studying ${studygroup.subject}`}
|
{`Studying ${studygroup.subject}`}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -1196,7 +1033,6 @@ export default function Home() {
|
||||||
study_group: studygroup.name,
|
study_group: studygroup.name,
|
||||||
subject: studygroup.subject,
|
subject: studygroup.subject,
|
||||||
});
|
});
|
||||||
navigation.navigate("Conversation");
|
|
||||||
setModalOpen(!modalOpen);
|
setModalOpen(!modalOpen);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -1236,138 +1072,6 @@ export default function Home() {
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</AnimatedContainer>
|
</AnimatedContainer>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal
|
|
||||||
coverScreen={false}
|
|
||||||
isVisible={modalOpen && !studying}
|
|
||||||
style={{ opacity: 0.85 }}
|
|
||||||
hasBackdrop={false}
|
|
||||||
>
|
|
||||||
<AnimatedContainer>
|
|
||||||
<Pressable
|
|
||||||
style={{
|
|
||||||
alignContent: "flex-start",
|
|
||||||
backgroundColor: colors.secondary_3,
|
|
||||||
borderRadius: 16,
|
|
||||||
}}
|
|
||||||
onPress={() => setModalOpen(false)}
|
|
||||||
>
|
|
||||||
<DropdownIcon size={32} />
|
|
||||||
</Pressable>
|
|
||||||
<View style={styles.flex_column}>
|
|
||||||
<Text style={styles.text_white_medium}>List View</Text>
|
|
||||||
<Switch
|
|
||||||
value={modalByGroup}
|
|
||||||
onChange={() => {
|
|
||||||
setModalByGroup(!modalByGroup);
|
|
||||||
}}
|
|
||||||
style={{ alignSelf: "center" }}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<ScrollView>
|
|
||||||
{!modalByGroup ? (
|
|
||||||
student_statuses_global.map(
|
|
||||||
(student_status: StudentStatusFilterType, index: number) => {
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
key={index}
|
|
||||||
style={{
|
|
||||||
alignContent: "center",
|
|
||||||
alignSelf: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
backgroundColor: colors.secondary_3,
|
|
||||||
borderColor: colors.primary_2,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderRadius: 16,
|
|
||||||
width: 256,
|
|
||||||
marginVertical: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
Student: {student_status.user}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{`Studying ${student_status.subject}`}
|
|
||||||
</Text>
|
|
||||||
{location && location.coords ? (
|
|
||||||
<Text style={styles.text_white_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
GetDistance(
|
|
||||||
student_status.location.latitude,
|
|
||||||
student_status.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
)
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
{modalByGroup ? (
|
|
||||||
study_groups_global.map(
|
|
||||||
(studygroup: StudyGroupType, index: number) => {
|
|
||||||
return (
|
|
||||||
<View
|
|
||||||
key={index}
|
|
||||||
style={{
|
|
||||||
alignContent: "center",
|
|
||||||
alignSelf: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
backgroundColor: colors.secondary_3,
|
|
||||||
borderColor: colors.primary_2,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderRadius: 16,
|
|
||||||
width: 256,
|
|
||||||
marginVertical: 4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
Group Name: {studygroup.name}
|
|
||||||
</Text>
|
|
||||||
{studygroup.landmark ? (
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{studygroup.landmark}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
{`Studying ${studygroup.subject}`}
|
|
||||||
</Text>
|
|
||||||
<Text style={styles.text_white_tiny_bold}>
|
|
||||||
Students Studying: {studygroup.students.length}
|
|
||||||
</Text>
|
|
||||||
{location && location.coords ? (
|
|
||||||
<Text style={styles.text_white_tiny}>
|
|
||||||
{`${Math.round(
|
|
||||||
GetDistance(
|
|
||||||
studygroup.location.latitude,
|
|
||||||
studygroup.location.longitude,
|
|
||||||
location.coords.latitude,
|
|
||||||
location.coords.longitude
|
|
||||||
)
|
|
||||||
)}m away`}
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
</ScrollView>
|
|
||||||
</AnimatedContainer>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<AnimatedContainer>
|
<AnimatedContainer>
|
||||||
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
||||||
|
|
|
@ -17,7 +17,6 @@ import { UserRegister } from "../../components/Api/Api";
|
||||||
import IsNumber from "../../components/IsNumber/IsNumber";
|
import IsNumber from "../../components/IsNumber/IsNumber";
|
||||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
import { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
import { ScrollView } from "react-native-gesture-handler";
|
|
||||||
|
|
||||||
export default function Register() {
|
export default function Register() {
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
|
|
|
@ -44,9 +44,8 @@ const styles = StyleSheet.create({
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
flexGrow: 1,
|
flex: 1,
|
||||||
paddingHorizontal: 4,
|
paddingHorizontal: 4,
|
||||||
paddingVertical: 32,
|
|
||||||
},
|
},
|
||||||
flex_row: {
|
flex_row: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|
Loading…
Add table
Reference in a new issue