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 // Switch this on if you wanna run production URLs while in development
let use_production = true; let use_production = false;
if (__DEV__ && use_production) { if (__DEV__ && use_production) {
backendURL = "https://stude.keannu1.duckdns.org"; backendURL = "https://stude.keannu1.duckdns.org";
backendURLWebsocket = "ws://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}> <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={{

View file

@ -85,8 +85,8 @@ export default function Home() {
if (locationPermitted) { if (locationPermitted) {
let newLocation = await Location.getCurrentPositionAsync(); let newLocation = await Location.getCurrentPositionAsync();
if (newLocation) { if (newLocation) {
setLocation(newLocation); setLocation(newLocation);
await DistanceHandler(newLocation); await DistanceHandler(newLocation);
} }
} }
} }
@ -146,27 +146,28 @@ export default function Home() {
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 // 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( const dist = GetDistance(
student_status.location.latitude, student_status.location.latitude,
student_status.location.longitude, student_status.location.longitude,
location.coords.latitude, location.coords.latitude,
location.coords.longitude location.coords.longitude
); );
console.log('Distance:',dist) console.log("Distance:", dist);
console.log(student_status.location.latitude, console.log(
student_status.location.latitude,
student_status.location.longitude, student_status.location.longitude,
location.coords.latitude, location.coords.latitude,
location.coords.longitude) location.coords.longitude
);
if (dist > 0.02 && studying && !stopping_toofar) { 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({ stop_studying.mutate({
active: false, active: false,
}); });
setStopping(true); setStopping(true);
} }
} }
}, },
onError: (error: Error) => { onError: (error: Error) => {
toast.show(String(error), { toast.show(String(error), {
@ -212,7 +213,7 @@ export default function Home() {
}, 500); }, 500);
setStudyGroups([]); setStudyGroups([]);
setStudying(false); setStudying(false);
setStopping(false); setStopping(false);
}, },
onError: (error: Error) => { onError: (error: Error) => {
toast.show(String(error), { toast.show(String(error), {
@ -591,6 +592,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>
@ -698,6 +706,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>
@ -906,7 +921,7 @@ export default function Home() {
duration: 2000, duration: 2000,
animationType: "slide-in", animationType: "slide-in",
}); });
requestLocation() requestLocation();
}} }}
> >
<RefreshIcon size={32} /> <RefreshIcon size={32} />
@ -982,14 +997,13 @@ export default function Home() {
<DropdownIcon size={32} /> <DropdownIcon size={32} />
</Pressable> </Pressable>
<View style={styles.flex_column}> <View style={styles.flex_column}>
<Text style={styles.text_white_medium}>List View</Text> <Text style={styles.text_white_medium}>List View</Text>
<Switch <Switch
value={modalByGroup} value={modalByGroup}
onChange={() => { onChange={() => {
setModalByGroup(!modalByGroup); setModalByGroup(!modalByGroup);
}} }}
style={{alignSelf:'center'}} style={{ alignSelf: "center" }}
/> />
</View> </View>
@ -1048,6 +1062,13 @@ export default function Home() {
<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>
@ -1130,14 +1151,13 @@ export default function Home() {
<DropdownIcon size={32} /> <DropdownIcon size={32} />
</Pressable> </Pressable>
<View style={styles.flex_column}> <View style={styles.flex_column}>
<Text style={styles.text_white_medium}>List View</Text> <Text style={styles.text_white_medium}>List View</Text>
<Switch <Switch
value={modalByGroup} value={modalByGroup}
onChange={() => { onChange={() => {
setModalByGroup(!modalByGroup); setModalByGroup(!modalByGroup);
}} }}
style={{alignSelf:'center'}} style={{ alignSelf: "center" }}
/> />
</View> </View>
@ -1174,34 +1194,43 @@ export default function Home() {
<></> <></>
)} )}
{modalByGroup ? ( {modalByGroup ? (
study_groups_global.map((studygroup: StudyGroupType, index: number) => { study_groups_global.map(
return ( (studygroup: StudyGroupType, index: number) => {
<View return (
key={index} <View
style={{ key={index}
alignContent: "center", style={{
alignSelf: "center", alignContent: "center",
justifyContent: "center", alignSelf: "center",
backgroundColor: colors.secondary_3, justifyContent: "center",
borderColor: colors.primary_2, backgroundColor: colors.secondary_3,
borderWidth: 1, borderColor: colors.primary_2,
borderRadius: 16, borderWidth: 1,
width: 256, borderRadius: 16,
marginVertical: 4, width: 256,
}} marginVertical: 4,
> }}
<Text style={styles.text_white_tiny_bold}> >
Group Name: {studygroup.name} <Text style={styles.text_white_tiny_bold}>
</Text> Group Name: {studygroup.name}
<Text style={styles.text_white_tiny_bold}> </Text>
{`Studying ${studygroup.subject}`} {studygroup.landmark ? (
</Text> <Text style={styles.text_white_tiny_bold}>
<Text style={styles.text_white_tiny_bold}> {studygroup.landmark}
Students Studying: {studygroup.students.length} </Text>
</Text> ) : (
</View> <></>
); )}
}) <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>
);
}
)
) : ( ) : (
<></> <></>
)} )}