mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-04-20 08:51:21 +08:00
Compare commits
44 commits
v0.9.1-bet
...
master
Author | SHA1 | Date | |
---|---|---|---|
0b3af716a5 | |||
05cee78d31 | |||
cbd82a05f9 | |||
d2aecbd89c | |||
51b7b24430 | |||
c0a8a8efc8 | |||
7cd549cad7 | |||
|
0cad7458be | ||
2603741aab | |||
5d7327ef26 | |||
856621fe06 | |||
8a32d2b32c | |||
a65a3a84aa | |||
88d8ce05b8 | |||
bd42b5418e | |||
3891f12f5d | |||
6564b52dc0 | |||
946e455b83 | |||
e354335590 | |||
a0d27aaa38 | |||
f098db0dca | |||
e501bc2c91 | |||
a11c9dff65 | |||
ecf62a1008 | |||
b82b9d332f | |||
be21689639 | |||
8867306bd0 | |||
de33fe30fd | |||
22820e139e | |||
a11ff2ee6f | |||
4caf86c6be | |||
8e5e0546df | |||
0c9f53b84d | |||
02eabd2b41 | |||
7b175c44df | |||
e54fe893a0 | |||
963eaef628 | |||
4a406957b5 | |||
ec693a7bb6 | |||
f9c3a5c5d4 | |||
369a00a0b3 | |||
6e63f86805 | |||
7ac6a6745f | |||
64cb7aabdd |
19 changed files with 1027 additions and 1649 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.13",
|
"react-native": "0.71.14",
|
||||||
"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",
|
||||||
|
|
|
@ -17,7 +17,10 @@ export default function Button({ disabled = false, ...props }: props) {
|
||||||
<Pressable
|
<Pressable
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onPress={props.onPress}
|
onPress={props.onPress}
|
||||||
style={{ ...styles.button_template, ...{ backgroundColor: props.color } }}
|
style={({ pressed }) => [
|
||||||
|
styles.button_template,
|
||||||
|
{ backgroundColor: pressed ? colors.primary_2 : props.color },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</Pressable>
|
</Pressable>
|
||||||
|
|
|
@ -24,6 +24,7 @@ import SubjectIcon from "../../icons/SubjectIcon/SubjectIcon";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { PatchStudentStatus } from "../Api/Api";
|
import { PatchStudentStatus } from "../Api/Api";
|
||||||
import { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
|
import MessageIcon from "../../icons/MessageIcon/MessageIcon";
|
||||||
|
|
||||||
export default function CustomDrawerContent(props: {}) {
|
export default function CustomDrawerContent(props: {}) {
|
||||||
const debug = false;
|
const debug = false;
|
||||||
|
@ -136,13 +137,13 @@ export default function CustomDrawerContent(props: {}) {
|
||||||
navigation.navigate("Conversation");
|
navigation.navigate("Conversation");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SubjectIcon size={32} />
|
<MessageIcon size={32} />
|
||||||
<Text style={styles.text_white_medium}>Conversation</Text>
|
<Text style={styles.text_white_medium}>Conversation</Text>
|
||||||
</DrawerButton>
|
</DrawerButton>
|
||||||
<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();
|
||||||
|
|
17
src/components/LoadingFeedback/LoadingFeedback.tsx
Normal file
17
src/components/LoadingFeedback/LoadingFeedback.tsx
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import * as React from "react";
|
||||||
|
import styles from "../../styles";
|
||||||
|
import { View, Text, ActivityIndicator } from "react-native";
|
||||||
|
import { colors } from "../../styles";
|
||||||
|
import AnimatedContainer from "../AnimatedContainer/AnimatedContainer";
|
||||||
|
|
||||||
|
export default function LoadingFeedback() {
|
||||||
|
return (
|
||||||
|
<View style={styles.background}>
|
||||||
|
<AnimatedContainer>
|
||||||
|
<View style={{ paddingVertical: 8 }} />
|
||||||
|
<ActivityIndicator size={128} color={colors.secondary_1} />
|
||||||
|
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||||
|
</AnimatedContainer>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
28
src/icons/CaretLeftIcon/CaretLeftIcon.tsx
Normal file
28
src/icons/CaretLeftIcon/CaretLeftIcon.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
28
src/icons/CaretRightIcon/CaretRightIcon.tsx
Normal file
28
src/icons/CaretRightIcon/CaretRightIcon.tsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
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>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
29
src/icons/MessageIcon/MessageIcon.tsx
Normal file
29
src/icons/MessageIcon/MessageIcon.tsx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import * as React from "react";
|
||||||
|
import { IconProps } from "../../interfaces/Interfaces";
|
||||||
|
|
||||||
|
import { Svg, Path } from "react-native-svg";
|
||||||
|
import { colors } from "../../styles";
|
||||||
|
|
||||||
|
export default function MessageIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
strokeWidth="2"
|
||||||
|
stroke={colors.icon_color}
|
||||||
|
fill="none"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
>
|
||||||
|
<Path stroke="none" d="M0 0h24v24H0z" fill="none"></Path>
|
||||||
|
<Path d="M8 9h8"></Path>
|
||||||
|
<Path d="M8 13h6"></Path>
|
||||||
|
<Path d="M12.5 20.5l-.5 .5l-3 -3h-3a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v4"></Path>
|
||||||
|
<Path d="M21.121 20.121a3 3 0 1 0 -4.242 0c.418 .419 1.125 1.045 2.121 1.879c1.051 -.89 1.759 -1.516 2.121 -1.879z"></Path>
|
||||||
|
<Path d="M19 18v.01"></Path>
|
||||||
|
</Svg>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
26
src/icons/RefreshIcon/RefreshIcon.tsx
Normal file
26
src/icons/RefreshIcon/RefreshIcon.tsx
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import * as React from "react";
|
||||||
|
import { IconProps } from "../../interfaces/Interfaces";
|
||||||
|
|
||||||
|
import { Svg, Path } from "react-native-svg";
|
||||||
|
import { colors } from "../../styles";
|
||||||
|
|
||||||
|
export default function RefreshIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Svg
|
||||||
|
width={props.size}
|
||||||
|
height={props.size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
strokeWidth="2"
|
||||||
|
stroke={colors.icon_color}
|
||||||
|
fill="none"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
>
|
||||||
|
<Path stroke="none" d="M0 0h24v24H0z" fill="none"></Path>
|
||||||
|
<Path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"></Path>
|
||||||
|
<Path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"></Path>
|
||||||
|
</Svg>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { ActivityIndicator, Image } from "react-native";
|
import { ActivityIndicator, Image, Pressable } from "react-native";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
import {
|
import {
|
||||||
View,
|
View,
|
||||||
|
@ -34,9 +34,13 @@ import { useToast } from "react-native-toast-notifications";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
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();
|
||||||
|
const user = useSelector((state: RootState) => state.user);
|
||||||
// Student Status
|
// Student Status
|
||||||
const [student_status, setStudentStatus] = useState<StudentStatusType>();
|
const [student_status, setStudentStatus] = useState<StudentStatusType>();
|
||||||
const StudentStatusQuery = useQuery({
|
const StudentStatusQuery = useQuery({
|
||||||
|
@ -67,6 +71,7 @@ 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) {
|
||||||
|
@ -124,7 +129,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: 3000,
|
refetchInterval: 10000,
|
||||||
enabled:
|
enabled:
|
||||||
student_status?.study_group != null ||
|
student_status?.study_group != null ||
|
||||||
(student_status?.study_group != "" &&
|
(student_status?.study_group != "" &&
|
||||||
|
@ -159,7 +164,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());
|
return Promise.reject(new Error(data[1]));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -195,9 +200,17 @@ 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 : ""}`}
|
{`Group: ${studygroup?.name ? studygroup.name : "Loading..."}`}
|
||||||
</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={{
|
||||||
|
@ -206,7 +219,9 @@ export default function ConversationPage() {
|
||||||
paddingRight: 4,
|
paddingRight: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{studygroup.students.length} studying
|
{!StudyGroupQuery.isFetching
|
||||||
|
? 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) {
|
||||||
|
@ -248,7 +263,10 @@ export default function ConversationPage() {
|
||||||
key={message.id}
|
key={message.id}
|
||||||
style={{
|
style={{
|
||||||
...styles.message_contentContainer,
|
...styles.message_contentContainer,
|
||||||
alignItems: index % 2 == 0 ? "flex-end" : "flex-start",
|
alignItems:
|
||||||
|
message.user === user.user.username
|
||||||
|
? "flex-end"
|
||||||
|
: "flex-start",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View style={styles.flex_row}>
|
<View style={styles.flex_row}>
|
||||||
|
@ -287,23 +305,41 @@ 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>
|
||||||
<TextInput
|
<View style={styles.flex_row}>
|
||||||
style={styles.chatbox}
|
<TextInput
|
||||||
placeholder="Send a message..."
|
style={styles.chatbox}
|
||||||
placeholderTextColor="white"
|
placeholder="Send a message..."
|
||||||
value={message}
|
placeholderTextColor="white"
|
||||||
onChange={(
|
value={message}
|
||||||
e: NativeSyntheticEvent<TextInputChangeEventData>
|
onChange={(
|
||||||
): void => {
|
e: NativeSyntheticEvent<TextInputChangeEventData>
|
||||||
setMessage(e.nativeEvent.text);
|
): void => {
|
||||||
}}
|
setMessage(e.nativeEvent.text);
|
||||||
onSubmitEditing={() => {
|
}}
|
||||||
send_message.mutate({
|
onSubmitEditing={() => {
|
||||||
message_content: message,
|
send_message.mutate({
|
||||||
});
|
message_content: message,
|
||||||
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>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
TextInput,
|
TextInput,
|
||||||
NativeSyntheticEvent,
|
NativeSyntheticEvent,
|
||||||
TextInputChangeEventData,
|
TextInputChangeEventData,
|
||||||
|
Pressable,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
@ -22,6 +23,8 @@ import { urlProvider } from "../../components/Api/Api";
|
||||||
import MapView, { UrlTile, Marker } from "react-native-maps";
|
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 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;
|
||||||
|
@ -41,7 +44,6 @@ export default function CreateGroup({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
|
||||||
student_status_patch.mutate({
|
student_status_patch.mutate({
|
||||||
study_group: name,
|
study_group: name,
|
||||||
});
|
});
|
||||||
|
@ -73,13 +75,18 @@ export default function CreateGroup({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status_list"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
||||||
toast.show(`Joined group ${name} successfully`, {
|
toast.show(`Joined group ${name} successfully`, {
|
||||||
type: "success",
|
type: "success",
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
// Set a delay before going back to conversation page to hopefully let the queries refresh in time
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Conversation");
|
||||||
|
}, 200);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
@ -94,54 +101,56 @@ export default function CreateGroup({ route }: any) {
|
||||||
if (location) {
|
if (location) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainerNoScroll>
|
<AnimatedContainer>
|
||||||
<View style={{ zIndex: -1 }}>
|
<View style={{ zIndex: -1 }}>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
<MapView
|
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
||||||
style={{
|
<MapView
|
||||||
height: Viewport.height * 0.4,
|
style={{
|
||||||
width: Viewport.width * 0.8,
|
height: Viewport.height * 0.4,
|
||||||
alignSelf: "center",
|
width: Viewport.width * 0.8,
|
||||||
}}
|
alignSelf: "center",
|
||||||
customMapStyle={[
|
}}
|
||||||
{
|
customMapStyle={[
|
||||||
featureType: "poi",
|
{
|
||||||
stylers: [
|
featureType: "poi",
|
||||||
{
|
stylers: [
|
||||||
visibility: "off",
|
{
|
||||||
},
|
visibility: "off",
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
]}
|
},
|
||||||
mapType="none"
|
]}
|
||||||
scrollEnabled={false}
|
mapType="none"
|
||||||
zoomEnabled={false}
|
scrollEnabled={false}
|
||||||
toolbarEnabled={false}
|
zoomEnabled={false}
|
||||||
rotateEnabled={false}
|
toolbarEnabled={false}
|
||||||
minZoomLevel={18}
|
rotateEnabled={false}
|
||||||
initialRegion={{
|
minZoomLevel={18}
|
||||||
latitude: location.latitude,
|
initialRegion={{
|
||||||
longitude: location.longitude,
|
|
||||||
latitudeDelta: 0.0922,
|
|
||||||
longitudeDelta: 0.0421,
|
|
||||||
}}
|
|
||||||
loadingBackgroundColor={colors.secondary_2}
|
|
||||||
>
|
|
||||||
<UrlTile
|
|
||||||
urlTemplate={urlProvider}
|
|
||||||
shouldReplaceMapContent={true}
|
|
||||||
maximumZ={19}
|
|
||||||
flipY={false}
|
|
||||||
zIndex={1}
|
|
||||||
/>
|
|
||||||
<Marker
|
|
||||||
coordinate={{
|
|
||||||
latitude: location.latitude,
|
latitude: location.latitude,
|
||||||
longitude: location.longitude,
|
longitude: location.longitude,
|
||||||
|
latitudeDelta: 0.0922,
|
||||||
|
longitudeDelta: 0.0421,
|
||||||
}}
|
}}
|
||||||
pinColor={colors.primary_1}
|
loadingBackgroundColor={colors.secondary_2}
|
||||||
/>
|
>
|
||||||
</MapView>
|
<UrlTile
|
||||||
|
urlTemplate={urlProvider}
|
||||||
|
shouldReplaceMapContent={true}
|
||||||
|
maximumZ={19}
|
||||||
|
flipY={false}
|
||||||
|
zIndex={1}
|
||||||
|
/>
|
||||||
|
<Marker
|
||||||
|
coordinate={{
|
||||||
|
latitude: location.latitude,
|
||||||
|
longitude: location.longitude,
|
||||||
|
}}
|
||||||
|
pinColor={colors.primary_1}
|
||||||
|
/>
|
||||||
|
</MapView>
|
||||||
|
</View>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
</View>
|
</View>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
@ -157,19 +166,25 @@ export default function CreateGroup({ route }: any) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
<Button
|
<View style={styles.flex_row}>
|
||||||
onPress={() => {
|
<Pressable onPress={() => navigation.navigate("Home")}>
|
||||||
study_group_create.mutate({
|
<CaretLeftIcon size={32} />
|
||||||
name: name,
|
</Pressable>
|
||||||
location: location,
|
<Button
|
||||||
subject: subject,
|
onPress={() => {
|
||||||
});
|
study_group_create.mutate({
|
||||||
}}
|
name: name,
|
||||||
>
|
location: location,
|
||||||
<Text style={styles.text_white_small}>Start Studying</Text>
|
subject: subject,
|
||||||
</Button>
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.text_white_small}>Start Studying</Text>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
</AnimatedContainerNoScroll>
|
</AnimatedContainer>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
import styles, { colors } from "../../styles";
|
import styles, { colors } from "../../styles";
|
||||||
import { View, Text, Pressable, ScrollView, Switch } from "react-native";
|
import {
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
Pressable,
|
||||||
|
ScrollView,
|
||||||
|
Switch,
|
||||||
|
ActivityIndicator,
|
||||||
|
TouchableHighlight,
|
||||||
|
} 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, { Circle, Marker, UrlTile } from "react-native-maps";
|
import MapView, { Callout, 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";
|
||||||
|
@ -36,12 +44,16 @@ import GetDistanceFromUSTP from "../../components/GetDistance/GetDistanceFromUST
|
||||||
import Modal from "react-native-modal";
|
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 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
|
||||||
const map_distance_override = false;
|
const map_distance_override = false;
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
const [location, setLocation] = useState<RawLocationType | null>(null);
|
const [location, setLocation] = useState<RawLocationType | null>(null);
|
||||||
|
const [locationPermitted, setLocationPermitted] = useState(false);
|
||||||
const [dist, setDist] = useState<number | null>(null);
|
const [dist, setDist] = useState<number | null>(null);
|
||||||
const [feedback, setFeedback] = useState(
|
const [feedback, setFeedback] = useState(
|
||||||
"To continue, please allow Stud-E permission to location services"
|
"To continue, please allow Stud-E permission to location services"
|
||||||
|
@ -52,7 +64,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 requestLocation() {
|
async function requestLocationPermission() {
|
||||||
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");
|
||||||
|
@ -66,47 +78,51 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
if (status == "granted") {
|
setLocationPermitted(true);
|
||||||
let newLocation = await Location.getCurrentPositionAsync({});
|
}
|
||||||
if (newLocation) {
|
}
|
||||||
// Only update location state if user's location has changed
|
|
||||||
if (
|
async function requestLocation() {
|
||||||
!location ||
|
if (locationPermitted) {
|
||||||
newLocation.coords.latitude !== location.coords.latitude ||
|
let newLocation = await Location.getCurrentPositionAsync();
|
||||||
newLocation.coords.longitude !== location.coords.longitude
|
|
||||||
) {
|
setLocation(newLocation);
|
||||||
setLocation(newLocation);
|
await DistanceHandler(newLocation);
|
||||||
DistanceHandler(newLocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh every 15 seconds
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// console.log("Location Update");
|
||||||
|
// console.log(locationPermitted);
|
||||||
|
requestLocation();
|
||||||
|
}, [locationPermitted]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
requestLocationPermission();
|
||||||
|
// Refresh every 30 seconds
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
requestLocation();
|
requestLocation();
|
||||||
}, 15000);
|
}, 30000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
});
|
|
||||||
|
|
||||||
// Refresh when screen loads
|
|
||||||
useEffect(() => {
|
|
||||||
requestLocation();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [stopping_toofar, setStopping] = useState(false);
|
||||||
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 and still studying
|
// Deactivate student status if too far away from USTP and still studying
|
||||||
if (dist >= 2 && !map_distance_override && studying)
|
if (dist >= 1 && !map_distance_override && studying && !stopping_toofar) {
|
||||||
stop_studying.mutate({
|
stop_studying.mutate({
|
||||||
active: false,
|
active: false,
|
||||||
});
|
});
|
||||||
|
setStopping(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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("");
|
||||||
|
@ -130,6 +146,22 @@ 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), {
|
||||||
|
@ -145,7 +177,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());
|
return Promise.reject(new Error(JSON.stringify(data[1])));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -175,6 +207,7 @@ export default function Home() {
|
||||||
}, 500);
|
}, 500);
|
||||||
setStudyGroups([]);
|
setStudyGroups([]);
|
||||||
setStudying(false);
|
setStudying(false);
|
||||||
|
setStopping(false);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
@ -195,7 +228,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",
|
||||||
|
@ -203,7 +236,9 @@ 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
|
||||||
|
@ -345,11 +380,51 @@ export default function Home() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function CustomMap() {
|
function CustomMap() {
|
||||||
if (dist && location) {
|
if (!locationPermitted) {
|
||||||
if (dist <= 1 || map_distance_override) {
|
return (
|
||||||
|
<>
|
||||||
|
<Text style={styles.text_white_medium}>{feedback}</Text>
|
||||||
|
<Button onPress={async () => await requestLocation()}>
|
||||||
|
<Text style={styles.text_white_medium}>Allow Access</Text>
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
(!StudentStatusQuery.isSuccess &&
|
||||||
|
studying &&
|
||||||
|
!StudentStatusListQuery.isSuccess &&
|
||||||
|
!StudyGroupQuery.isSuccess) ||
|
||||||
|
(!StudentStatusQuery.isSuccess &&
|
||||||
|
!studying &&
|
||||||
|
!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 (
|
||||||
|
<>
|
||||||
|
<View style={{ paddingVertical: 8 }} />
|
||||||
|
<ActivityIndicator size={96} color={colors.secondary_1} />
|
||||||
|
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
} else if (dist && location) {
|
||||||
|
if (dist <= 0.25 || map_distance_override) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MapView
|
<MapView
|
||||||
|
mapType={"none"}
|
||||||
style={styles.map}
|
style={styles.map}
|
||||||
customMapStyle={[
|
customMapStyle={[
|
||||||
{
|
{
|
||||||
|
@ -404,6 +479,7 @@ export default function Home() {
|
||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
toast.hideAll();
|
toast.hideAll();
|
||||||
|
|
||||||
toast.show(
|
toast.show(
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
@ -432,7 +508,26 @@ 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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -513,6 +608,7 @@ export default function Home() {
|
||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
toast.hideAll();
|
toast.hideAll();
|
||||||
|
|
||||||
toast.show(
|
toast.show(
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
|
@ -524,6 +620,13 @@ 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>
|
||||||
|
@ -548,6 +651,7 @@ 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}>
|
||||||
|
@ -587,7 +691,35 @@ 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}
|
||||||
|
@ -630,6 +762,13 @@ 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>
|
||||||
|
@ -662,7 +801,40 @@ 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}
|
||||||
|
@ -812,9 +984,40 @@ 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",
|
||||||
|
@ -823,10 +1026,28 @@ export default function Home() {
|
||||||
setModalOpen(true);
|
setModalOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{studying ? <CaretUpIcon size={32} /> : <></>}
|
<CaretUpIcon size={32} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
|
{student_status?.active && !student_status?.study_group ? (
|
||||||
|
<Button
|
||||||
|
onPress={() => {
|
||||||
|
if (student_status?.subject) {
|
||||||
|
navigation.navigate("Create Group", {
|
||||||
|
location: {
|
||||||
|
latitude: student_status?.location.latitude,
|
||||||
|
longitude: student_status?.location.longitude,
|
||||||
|
},
|
||||||
|
subject: student_status?.subject,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.text_white_tiny_bold}>Create Group</Text>
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -834,12 +1055,13 @@ export default function Home() {
|
||||||
return <MapRendererFar location={location.coords} dist={dist} />;
|
return <MapRendererFar location={location.coords} dist={dist} />;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
requestLocationPermission();
|
||||||
|
requestLocation();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Text style={styles.text_white_medium}>{feedback}</Text>
|
<View style={{ paddingVertical: 8 }} />
|
||||||
<Button onPress={async () => await requestLocation()}>
|
<ActivityIndicator size={96} color={colors.secondary_1} />
|
||||||
<Text style={styles.text_white_medium}>Allow Access</Text>
|
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -863,14 +1085,15 @@ export default function Home() {
|
||||||
>
|
>
|
||||||
<DropdownIcon size={32} />
|
<DropdownIcon size={32} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<View style={styles.flex_row}>
|
<View style={styles.flex_column}>
|
||||||
|
<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>
|
||||||
|
@ -889,6 +1112,7 @@ 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}>
|
||||||
|
@ -900,6 +1124,20 @@ 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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -921,11 +1159,19 @@ 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>
|
||||||
|
@ -939,6 +1185,48 @@ export default function Home() {
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
|
{student_status?.study_group != studygroup.name ? (
|
||||||
|
<Pressable
|
||||||
|
style={{
|
||||||
|
...styles.button_template,
|
||||||
|
backgroundColor: colors.secondary_2,
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
change_study_group.mutate({
|
||||||
|
study_group: studygroup.name,
|
||||||
|
subject: studygroup.subject,
|
||||||
|
});
|
||||||
|
navigation.navigate("Conversation");
|
||||||
|
setModalOpen(!modalOpen);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
|
Join Group
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
{student_status?.study_group == studygroup.name ? (
|
||||||
|
<Pressable
|
||||||
|
style={{
|
||||||
|
...styles.button_template,
|
||||||
|
backgroundColor: colors.secondary_2,
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
change_study_group.mutate({
|
||||||
|
study_group: "",
|
||||||
|
});
|
||||||
|
setModalOpen(!modalOpen);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.text_white_tiny_bold}>
|
||||||
|
Leave Group
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
@ -948,8 +1236,143 @@ 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>
|
||||||
<CustomMap />
|
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
||||||
|
<CustomMap />
|
||||||
|
</View>
|
||||||
</AnimatedContainer>
|
</AnimatedContainer>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,8 +7,8 @@ import {
|
||||||
NativeSyntheticEvent,
|
NativeSyntheticEvent,
|
||||||
TextInputChangeEventData,
|
TextInputChangeEventData,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import LoginIcon from "../../icons/LoginIcon/LoginIcon";
|
import LoginIcon from "../../icons/LoginIcon/LoginIcon";
|
||||||
import Button from "../../components/Button/Button";
|
import Button from "../../components/Button/Button";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
@ -22,15 +22,23 @@ import {
|
||||||
unsetOnboarding,
|
unsetOnboarding,
|
||||||
} from "../../features/redux/slices/StatusSlice/StatusSlice";
|
} from "../../features/redux/slices/StatusSlice/StatusSlice";
|
||||||
import { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
|
import { RootState } from "../../features/redux/Store/Store";
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
|
const status = useSelector((state: RootState) => state.status);
|
||||||
|
const [logging_in, setLoggingIn] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [creds, setCreds] = useState({
|
const [creds, setCreds] = useState({
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
});
|
});
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
useEffect(() => {
|
||||||
|
if (status.logged_in) {
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainer>
|
<AnimatedContainer>
|
||||||
|
@ -69,49 +77,52 @@ export default function Login() {
|
||||||
<View style={{ paddingVertical: 4 }} />
|
<View style={{ paddingVertical: 4 }} />
|
||||||
<Button
|
<Button
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await UserLogin({
|
if (!logging_in) {
|
||||||
username: creds.username,
|
await UserLogin({
|
||||||
password: creds.password,
|
username: creds.username,
|
||||||
}).then(async (result) => {
|
password: creds.password,
|
||||||
if (result[0]) {
|
}).then(async (result) => {
|
||||||
setUser({ ...creds, username: "", password: "", error: "" });
|
if (result[0]) {
|
||||||
let user_info = await GetUserInfo();
|
setUser({ ...creds, username: "", password: "", error: "" });
|
||||||
dispatch(login());
|
let user_info = await GetUserInfo();
|
||||||
dispatch(setUser(user_info[1]));
|
dispatch(login());
|
||||||
// Redirect to onboarding if no year level, course, or semester specified
|
dispatch(setUser(user_info[1]));
|
||||||
if (
|
// Redirect to onboarding if no year level, course, or semester specified
|
||||||
user_info[1].year_level == null ||
|
if (
|
||||||
user_info[1].course == null ||
|
user_info[1].year_level == null ||
|
||||||
user_info[1].semester == null
|
user_info[1].course == null ||
|
||||||
) {
|
user_info[1].semester == null
|
||||||
dispatch(setOnboarding());
|
) {
|
||||||
navigation.navigate("Onboarding");
|
dispatch(setOnboarding());
|
||||||
toast.show("Successfully logged in", {
|
navigation.navigate("Onboarding");
|
||||||
type: "success",
|
toast.show("Successfully logged in", {
|
||||||
placement: "top",
|
type: "success",
|
||||||
duration: 2000,
|
placement: "top",
|
||||||
animationType: "slide-in",
|
duration: 2000,
|
||||||
});
|
animationType: "slide-in",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch(unsetOnboarding());
|
||||||
|
toast.show("Successfully logged in", {
|
||||||
|
type: "success",
|
||||||
|
placement: "top",
|
||||||
|
duration: 2000,
|
||||||
|
animationType: "slide-in",
|
||||||
|
});
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}
|
||||||
|
console.log(JSON.stringify(user_info));
|
||||||
} else {
|
} else {
|
||||||
dispatch(unsetOnboarding());
|
toast.show(JSON.stringify(result[1]), {
|
||||||
toast.show("Successfully logged in", {
|
type: "warning",
|
||||||
type: "success",
|
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
|
||||||
}
|
}
|
||||||
console.log(JSON.stringify(user_info));
|
setLoggingIn(false);
|
||||||
} else {
|
});
|
||||||
toast.show(JSON.stringify(result[1]), {
|
}
|
||||||
type: "warning",
|
|
||||||
placement: "top",
|
|
||||||
duration: 2000,
|
|
||||||
animationType: "slide-in",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_small}>Login</Text>
|
<Text style={styles.text_white_small}>Login</Text>
|
||||||
|
|
|
@ -195,7 +195,13 @@ export default function Onboarding() {
|
||||||
...styles.text_white_small_bold,
|
...styles.text_white_small_bold,
|
||||||
...{ textAlign: "center" },
|
...{ textAlign: "center" },
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{ backgroundColor: colors.primary_2 }}
|
modalContentContainerStyle={{
|
||||||
|
backgroundColor: colors.primary_2,
|
||||||
|
borderWidth: 0,
|
||||||
|
zIndex: 1000,
|
||||||
|
}}
|
||||||
|
dropDownDirection="BOTTOM"
|
||||||
|
listMode="MODAL"
|
||||||
/>
|
/>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
zIndex={2000}
|
zIndex={2000}
|
||||||
|
@ -215,7 +221,13 @@ export default function Onboarding() {
|
||||||
...styles.text_white_small_bold,
|
...styles.text_white_small_bold,
|
||||||
...{ textAlign: "center" },
|
...{ textAlign: "center" },
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{ backgroundColor: colors.primary_2 }}
|
modalContentContainerStyle={{
|
||||||
|
backgroundColor: colors.primary_2,
|
||||||
|
borderWidth: 0,
|
||||||
|
zIndex: 1000,
|
||||||
|
}}
|
||||||
|
dropDownDirection="BOTTOM"
|
||||||
|
listMode="MODAL"
|
||||||
/>
|
/>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
zIndex={1000}
|
zIndex={1000}
|
||||||
|
@ -235,7 +247,13 @@ export default function Onboarding() {
|
||||||
...styles.text_white_small_bold,
|
...styles.text_white_small_bold,
|
||||||
...{ textAlign: "center" },
|
...{ textAlign: "center" },
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{ backgroundColor: colors.primary_2 }}
|
modalContentContainerStyle={{
|
||||||
|
backgroundColor: colors.primary_2,
|
||||||
|
borderWidth: 0,
|
||||||
|
zIndex: 1000,
|
||||||
|
}}
|
||||||
|
dropDownDirection="BOTTOM"
|
||||||
|
listMode="MODAL"
|
||||||
/>
|
/>
|
||||||
</MotiView>
|
</MotiView>
|
||||||
<MotiView
|
<MotiView
|
||||||
|
|
|
@ -17,12 +17,14 @@ 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>();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
// const dispatch = useDispatch();
|
// const dispatch = useDispatch();
|
||||||
// const creds = useSelector((state: RootState) => state.auth.creds);
|
// const creds = useSelector((state: RootState) => state.auth.creds);
|
||||||
|
const [registering, setRegistering] = useState(false);
|
||||||
const [user, setUser] = useState({
|
const [user, setUser] = useState({
|
||||||
first_name: "",
|
first_name: "",
|
||||||
last_name: "",
|
last_name: "",
|
||||||
|
@ -30,6 +32,7 @@ export default function Register() {
|
||||||
username: "",
|
username: "",
|
||||||
email: "",
|
email: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
confirm_password: "",
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
|
@ -121,49 +124,77 @@ export default function Register() {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={{ paddingVertical: 4 }} />
|
<View style={{ paddingVertical: 4 }} />
|
||||||
|
<TextInput
|
||||||
|
style={styles.text_input}
|
||||||
|
placeholder="Confirm Password"
|
||||||
|
placeholderTextColor={colors.text_default}
|
||||||
|
secureTextEntry={true}
|
||||||
|
value={user.confirm_password}
|
||||||
|
autoCapitalize={"none"}
|
||||||
|
onChange={(
|
||||||
|
e: NativeSyntheticEvent<TextInputChangeEventData>
|
||||||
|
): void => {
|
||||||
|
setUser({ ...user, confirm_password: e.nativeEvent.text });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<View style={{ paddingVertical: 4 }} />
|
||||||
<Button
|
<Button
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
await UserRegister({
|
if (!registering) {
|
||||||
username: user.username,
|
if (user.password === user.confirm_password) {
|
||||||
email: user.email,
|
setRegistering(true);
|
||||||
password: user.password,
|
await UserRegister({
|
||||||
student_id_number: user.student_id_number,
|
username: user.username,
|
||||||
first_name: user.first_name,
|
email: user.email,
|
||||||
last_name: user.last_name,
|
password: user.password,
|
||||||
}).then((result) => {
|
student_id_number: user.student_id_number,
|
||||||
console.log(result);
|
first_name: user.first_name,
|
||||||
if (result[0]) {
|
last_name: user.last_name,
|
||||||
setUser({
|
}).then((result: any) => {
|
||||||
...user,
|
console.log(result);
|
||||||
first_name: "",
|
if (result[0]) {
|
||||||
last_name: "",
|
setUser({
|
||||||
student_id_number: "",
|
...user,
|
||||||
username: "",
|
first_name: "",
|
||||||
email: "",
|
last_name: "",
|
||||||
password: "",
|
student_id_number: "",
|
||||||
|
username: "",
|
||||||
|
email: "",
|
||||||
|
password: "",
|
||||||
|
});
|
||||||
|
toast.show(
|
||||||
|
"Success! An email has been sent to activate your account",
|
||||||
|
{
|
||||||
|
type: "success",
|
||||||
|
placement: "top",
|
||||||
|
duration: 6000,
|
||||||
|
animationType: "slide-in",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Login");
|
||||||
|
}, 10000);
|
||||||
|
} else {
|
||||||
|
toast.show(JSON.parse(JSON.stringify(result[1])), {
|
||||||
|
type: "warning",
|
||||||
|
placement: "top",
|
||||||
|
duration: 6000,
|
||||||
|
animationType: "slide-in",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
setRegistering(false);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
toast.show(
|
toast.show(
|
||||||
"Success! An email has been sent to activate your account",
|
"Password does not match confirm password. Please try again"
|
||||||
|
),
|
||||||
{
|
{
|
||||||
type: "success",
|
type: "warning",
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 6000,
|
duration: 6000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
}
|
};
|
||||||
);
|
|
||||||
setTimeout(() => {
|
|
||||||
navigation.navigate("Login");
|
|
||||||
}, 10000);
|
|
||||||
} else {
|
|
||||||
toast.show(JSON.stringify(result[1]), {
|
|
||||||
type: "warning",
|
|
||||||
placement: "top",
|
|
||||||
duration: 6000,
|
|
||||||
animationType: "slide-in",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import styles, { Viewport } from "../../styles";
|
import styles, { Viewport } from "../../styles";
|
||||||
import { View, Text, ToastAndroid } from "react-native";
|
import {
|
||||||
|
View,
|
||||||
|
Text,
|
||||||
|
ToastAndroid,
|
||||||
|
Pressable,
|
||||||
|
ActivityIndicator,
|
||||||
|
} from "react-native";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
UserInfoReturnType,
|
UserInfoReturnType,
|
||||||
|
@ -24,6 +30,8 @@ import { urlProvider } from "../../components/Api/Api";
|
||||||
import MapView, { UrlTile, Marker } from "react-native-maps";
|
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 AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
|
|
||||||
export default function StartStudying({ route }: any) {
|
export default function StartStudying({ route }: any) {
|
||||||
const { location } = route.params;
|
const { location } = route.params;
|
||||||
|
@ -72,13 +80,18 @@ export default function StartStudying({ route }: any) {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
queryClient.invalidateQueries({ queryKey: ["user_status"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["user_status_list"] });
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["study_group_list"] });
|
||||||
toast.show("You are now studying \n" + selected_subject, {
|
toast.show("You are now studying \n" + selected_subject, {
|
||||||
type: "success",
|
type: "success",
|
||||||
placement: "top",
|
placement: "top",
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
// Set a delay before going back to homepage to hopefully let the queries refresh in time
|
||||||
|
setTimeout(() => {
|
||||||
|
navigation.navigate("Home");
|
||||||
|
}, 200);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
toast.show(String(error), {
|
toast.show(String(error), {
|
||||||
|
@ -90,57 +103,70 @@ export default function StartStudying({ route }: any) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (StudentInfo.isLoading) {
|
||||||
|
return (
|
||||||
|
<View style={styles.background}>
|
||||||
|
<AnimatedContainer>
|
||||||
|
<View style={{ paddingVertical: 8 }} />
|
||||||
|
<ActivityIndicator size={96} color={colors.secondary_1} />
|
||||||
|
<Text style={styles.text_white_medium}>Loading...</Text>
|
||||||
|
</AnimatedContainer>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (location && location.coords) {
|
if (location && location.coords) {
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainerNoScroll>
|
<AnimatedContainerNoScroll>
|
||||||
<View style={{ zIndex: -1 }}>
|
<View style={{ zIndex: -1 }}>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
<MapView
|
<View style={{ borderRadius: 16, overflow: "hidden" }}>
|
||||||
style={{
|
<MapView
|
||||||
height: Viewport.height * 0.4,
|
style={{
|
||||||
width: Viewport.width * 0.8,
|
height: Viewport.height * 0.4,
|
||||||
alignSelf: "center",
|
width: Viewport.width * 0.8,
|
||||||
}}
|
alignSelf: "center",
|
||||||
customMapStyle={[
|
}}
|
||||||
{
|
customMapStyle={[
|
||||||
featureType: "poi",
|
{
|
||||||
stylers: [
|
featureType: "poi",
|
||||||
{
|
stylers: [
|
||||||
visibility: "off",
|
{
|
||||||
},
|
visibility: "off",
|
||||||
],
|
},
|
||||||
},
|
],
|
||||||
]}
|
},
|
||||||
mapType="none"
|
]}
|
||||||
scrollEnabled={false}
|
mapType="none"
|
||||||
zoomEnabled={false}
|
scrollEnabled={false}
|
||||||
toolbarEnabled={false}
|
zoomEnabled={false}
|
||||||
rotateEnabled={false}
|
toolbarEnabled={false}
|
||||||
minZoomLevel={18}
|
rotateEnabled={false}
|
||||||
initialRegion={{
|
minZoomLevel={18}
|
||||||
latitude: location.coords.latitude,
|
initialRegion={{
|
||||||
longitude: location.coords.longitude,
|
|
||||||
latitudeDelta: 0.0922,
|
|
||||||
longitudeDelta: 0.0421,
|
|
||||||
}}
|
|
||||||
loadingBackgroundColor={colors.secondary_2}
|
|
||||||
>
|
|
||||||
<UrlTile
|
|
||||||
urlTemplate={urlProvider}
|
|
||||||
shouldReplaceMapContent={true}
|
|
||||||
maximumZ={19}
|
|
||||||
flipY={false}
|
|
||||||
zIndex={1}
|
|
||||||
/>
|
|
||||||
<Marker
|
|
||||||
coordinate={{
|
|
||||||
latitude: location.coords.latitude,
|
latitude: location.coords.latitude,
|
||||||
longitude: location.coords.longitude,
|
longitude: location.coords.longitude,
|
||||||
|
latitudeDelta: 0.0922,
|
||||||
|
longitudeDelta: 0.0421,
|
||||||
}}
|
}}
|
||||||
pinColor={colors.primary_1}
|
loadingBackgroundColor={colors.secondary_2}
|
||||||
/>
|
>
|
||||||
</MapView>
|
<UrlTile
|
||||||
|
urlTemplate={urlProvider}
|
||||||
|
shouldReplaceMapContent={true}
|
||||||
|
maximumZ={19}
|
||||||
|
flipY={false}
|
||||||
|
zIndex={1}
|
||||||
|
/>
|
||||||
|
<Marker
|
||||||
|
coordinate={{
|
||||||
|
latitude: location.coords.latitude,
|
||||||
|
longitude: location.coords.longitude,
|
||||||
|
}}
|
||||||
|
pinColor={colors.primary_1}
|
||||||
|
/>
|
||||||
|
</MapView>
|
||||||
|
</View>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
</View>
|
</View>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
|
@ -174,28 +200,32 @@ export default function StartStudying({ route }: any) {
|
||||||
listMode="MODAL"
|
listMode="MODAL"
|
||||||
/>
|
/>
|
||||||
<View style={styles.padding} />
|
<View style={styles.padding} />
|
||||||
<Button
|
<View style={styles.flex_row}>
|
||||||
onPress={() => {
|
<Pressable onPress={() => navigation.navigate("Home")}>
|
||||||
console.log({
|
<CaretLeftIcon size={32} />
|
||||||
subject: selected_subject,
|
</Pressable>
|
||||||
location: {
|
<Button
|
||||||
latitude: location.coords.latitude,
|
onPress={() => {
|
||||||
longitude: location.coords.longitude,
|
console.log({
|
||||||
},
|
subject: selected_subject,
|
||||||
});
|
location: {
|
||||||
mutation.mutate({
|
latitude: location.coords.latitude,
|
||||||
active: true,
|
longitude: location.coords.longitude,
|
||||||
subject: selected_subject,
|
},
|
||||||
location: {
|
});
|
||||||
latitude: location.coords.latitude,
|
mutation.mutate({
|
||||||
longitude: location.coords.longitude,
|
active: true,
|
||||||
},
|
subject: selected_subject,
|
||||||
});
|
location: {
|
||||||
}}
|
latitude: location.coords.latitude,
|
||||||
>
|
longitude: location.coords.longitude,
|
||||||
<Text style={styles.text_white_small}>Start Studying</Text>
|
},
|
||||||
</Button>
|
});
|
||||||
<View style={styles.padding} />
|
}}
|
||||||
|
>
|
||||||
|
<Text style={styles.text_white_small}>Start Studying</Text>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
</AnimatedContainerNoScroll>
|
</AnimatedContainerNoScroll>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import styles from "../../styles";
|
import styles from "../../styles";
|
||||||
import { View, Text } from "react-native";
|
import { View, Text, ActivityIndicator } from "react-native";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
UserInfoReturnType,
|
UserInfoReturnType,
|
||||||
|
@ -26,6 +26,9 @@ import AnimatedContainerNoScroll from "../../components/AnimatedContainer/Animat
|
||||||
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 { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
|
import Loading from "../Loading/Loading";
|
||||||
|
import LoadingFeedback from "../../components/LoadingFeedback/LoadingFeedback";
|
||||||
|
|
||||||
export default function SubjectsPage() {
|
export default function SubjectsPage() {
|
||||||
const logged_in_user = useSelector((state: RootState) => state.user.user);
|
const logged_in_user = useSelector((state: RootState) => state.user.user);
|
||||||
|
@ -183,7 +186,9 @@ export default function SubjectsPage() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (StudentInfo.isLoading || Subjects.isLoading) {
|
||||||
|
return <LoadingFeedback />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainerNoScroll>
|
<AnimatedContainerNoScroll>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
NativeSyntheticEvent,
|
NativeSyntheticEvent,
|
||||||
TextInputChangeEventData,
|
TextInputChangeEventData,
|
||||||
Pressable,
|
Pressable,
|
||||||
|
ActivityIndicator,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
@ -42,6 +43,9 @@ import { setUser as setUserinState } from "../../features/redux/slices/UserSlice
|
||||||
import * as ImagePicker from "expo-image-picker";
|
import * as ImagePicker from "expo-image-picker";
|
||||||
import * as FileSystem from "expo-file-system";
|
import * as FileSystem from "expo-file-system";
|
||||||
import { useToast } from "react-native-toast-notifications";
|
import { useToast } from "react-native-toast-notifications";
|
||||||
|
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
|
||||||
|
import Loading from "../Loading/Loading";
|
||||||
|
import LoadingFeedback from "../../components/LoadingFeedback/LoadingFeedback";
|
||||||
|
|
||||||
export default function UserInfoPage() {
|
export default function UserInfoPage() {
|
||||||
const logged_in_user = useSelector((state: RootState) => state.user.user);
|
const logged_in_user = useSelector((state: RootState) => state.user.user);
|
||||||
|
@ -285,7 +289,14 @@ export default function UserInfoPage() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
StudentInfo.isLoading ||
|
||||||
|
Semesters.isLoading ||
|
||||||
|
yearlevel_query.isLoading ||
|
||||||
|
course_query.isLoading
|
||||||
|
) {
|
||||||
|
return <LoadingFeedback />;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<View style={styles.background}>
|
<View style={styles.background}>
|
||||||
<AnimatedContainerNoScroll>
|
<AnimatedContainerNoScroll>
|
||||||
|
@ -339,7 +350,7 @@ export default function UserInfoPage() {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 3 }}>
|
<View style={{ flex: 3 }}>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
zIndex={4000}
|
zIndex={1000}
|
||||||
open={yearLevelOpen}
|
open={yearLevelOpen}
|
||||||
value={selected_yearlevel}
|
value={selected_yearlevel}
|
||||||
items={year_levels}
|
items={year_levels}
|
||||||
|
@ -361,7 +372,7 @@ export default function UserInfoPage() {
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{
|
dropDownContainerStyle={{
|
||||||
backgroundColor: colors.primary_2,
|
backgroundColor: colors.primary_2,
|
||||||
zIndex: 4000,
|
zIndex: 1000,
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
}}
|
}}
|
||||||
dropDownDirection="TOP"
|
dropDownDirection="TOP"
|
||||||
|
@ -374,7 +385,7 @@ export default function UserInfoPage() {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 3 }}>
|
<View style={{ flex: 3 }}>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
zIndex={3000}
|
zIndex={2000}
|
||||||
open={semesterOpen}
|
open={semesterOpen}
|
||||||
value={selected_semester}
|
value={selected_semester}
|
||||||
items={semesters}
|
items={semesters}
|
||||||
|
@ -396,7 +407,7 @@ export default function UserInfoPage() {
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{
|
dropDownContainerStyle={{
|
||||||
backgroundColor: colors.primary_2,
|
backgroundColor: colors.primary_2,
|
||||||
zIndex: 3000,
|
zIndex: 2000,
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
}}
|
}}
|
||||||
dropDownDirection="TOP"
|
dropDownDirection="TOP"
|
||||||
|
@ -409,7 +420,7 @@ export default function UserInfoPage() {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 3 }}>
|
<View style={{ flex: 3 }}>
|
||||||
<DropDownPicker
|
<DropDownPicker
|
||||||
zIndex={2000}
|
zIndex={3000}
|
||||||
open={courseOpen}
|
open={courseOpen}
|
||||||
value={selected_course}
|
value={selected_course}
|
||||||
items={courses}
|
items={courses}
|
||||||
|
@ -431,7 +442,7 @@ export default function UserInfoPage() {
|
||||||
}}
|
}}
|
||||||
dropDownContainerStyle={{
|
dropDownContainerStyle={{
|
||||||
backgroundColor: colors.primary_2,
|
backgroundColor: colors.primary_2,
|
||||||
zIndex: 2000,
|
zIndex: 3000,
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
}}
|
}}
|
||||||
dropDownDirection="TOP"
|
dropDownDirection="TOP"
|
||||||
|
|
|
@ -44,8 +44,9 @@ const styles = StyleSheet.create({
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
flex: 1,
|
flexGrow: 1,
|
||||||
paddingHorizontal: 4,
|
paddingHorizontal: 4,
|
||||||
|
paddingVertical: 32,
|
||||||
},
|
},
|
||||||
flex_row: {
|
flex_row: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|
Loading…
Add table
Reference in a new issue