Show landmarks if it exists in homepage and in conversation page

This commit is contained in:
Keannu Bernasol 2023-11-24 00:22:14 +08:00
parent c0a8a8efc8
commit 51b7b24430
3 changed files with 81 additions and 44 deletions

View file

@ -22,7 +22,7 @@ if (__DEV__) {
}
// Switch this on if you wanna run production URLs while in development
let use_production = true;
let use_production = false;
if (__DEV__ && use_production) {
backendURL = "https://stude.keannu1.duckdns.org";
backendURLWebsocket = "ws://stude.keannu1.duckdns.org";

View file

@ -200,9 +200,17 @@ export default function ConversationPage() {
>
<View style={styles.flex_row}>
<Text style={{ ...styles.text_white_medium }}>
{`Group: ${studygroup?.name ? studygroup.name : ""}`}
{`Group: ${studygroup?.name ? studygroup.name : "Loading..."}`}
</Text>
</View>
{studygroup.landmark ? (
<Text style={{...styles.text_white_tiny_bold,...{textAlign:'left'}}}>
{studygroup.landmark}
</Text>
) : (
<></>
)}
<View style={{ ...styles.flex_row }}>
<Text
style={{

View file

@ -85,8 +85,8 @@ export default function Home() {
if (locationPermitted) {
let newLocation = await Location.getCurrentPositionAsync();
if (newLocation) {
setLocation(newLocation);
await DistanceHandler(newLocation);
setLocation(newLocation);
await DistanceHandler(newLocation);
}
}
}
@ -146,27 +146,28 @@ export default function Home() {
setStudying(data[1].active);
setStudentStatus(data[1]);
// Deactivate student status if too far away from current location you are studying in
if(student_status && location){
if (student_status && location) {
const dist = GetDistance(
student_status.location.latitude,
student_status.location.longitude,
location.coords.latitude,
location.coords.longitude
);
console.log('Distance:',dist)
console.log(student_status.location.latitude,
console.log("Distance:", dist);
console.log(
student_status.location.latitude,
student_status.location.longitude,
location.coords.latitude,
location.coords.longitude)
location.coords.longitude
);
if (dist > 0.02 && studying && !stopping_toofar) {
console.log('Too far from current studying location')
console.log("Too far from current studying location");
stop_studying.mutate({
active: false,
});
setStopping(true);
}
}
},
onError: (error: Error) => {
toast.show(String(error), {
@ -212,7 +213,7 @@ export default function Home() {
}, 500);
setStudyGroups([]);
setStudying(false);
setStopping(false);
setStopping(false);
},
onError: (error: Error) => {
toast.show(String(error), {
@ -591,6 +592,13 @@ export default function Home() {
<Text style={styles.text_white_tiny_bold}>
Study Group: {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>
@ -698,6 +706,13 @@ export default function Home() {
<Text style={styles.text_white_tiny_bold}>
Study Group: {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>
@ -906,7 +921,7 @@ export default function Home() {
duration: 2000,
animationType: "slide-in",
});
requestLocation()
requestLocation();
}}
>
<RefreshIcon size={32} />
@ -982,14 +997,13 @@ export default function Home() {
<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'}}
style={{ alignSelf: "center" }}
/>
</View>
@ -1048,6 +1062,13 @@ export default function Home() {
<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>
@ -1130,14 +1151,13 @@ export default function Home() {
<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'}}
style={{ alignSelf: "center" }}
/>
</View>
@ -1174,34 +1194,43 @@ export default function Home() {
<></>
)}
{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>
<Text style={styles.text_white_tiny_bold}>
{`Studying ${studygroup.subject}`}
</Text>
<Text style={styles.text_white_tiny_bold}>
Students Studying: {studygroup.students.length}
</Text>
</View>
);
})
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>
</View>
);
}
)
) : (
<></>
)}