Code cleanup for multiple pages and components

This commit is contained in:
Keannu Christian Bernasol 2023-09-20 21:16:54 +08:00
parent 14e14b8bb6
commit 68778cea7a
5 changed files with 22 additions and 13 deletions

View file

@ -1,26 +1,26 @@
import { Callout } from "react-native-maps";
import { RawLocationType } from "../../interfaces/Interfaces";
import { LocationType, RawLocationType } from "../../interfaces/Interfaces";
import styles from "../../styles";
import { Text } from "react-native";
// Map popup for user's location
type props = {
location: RawLocationType;
location: LocationType;
studying: boolean;
subject?: string;
};
export default function CustomMapCallout(props: props) {
let { location, studying, subject } = props;
if (location && location.coords) {
if (location && location.latitude && location.longitude) {
if (studying) {
return (
<Callout>
<Text style={styles.text_black_tiny}>
You are here {"\n"}
X: {Math.round(location.coords.longitude) + "\n"}
Z: {Math.round(location.coords.latitude) + "\n"}
X: {Math.round(location.longitude) + "\n"}
Z: {Math.round(location.latitude) + "\n"}
Studying: {subject}
</Text>
</Callout>
@ -30,8 +30,8 @@ export default function CustomMapCallout(props: props) {
<Callout>
<Text style={styles.text_black_tiny}>
You are here {"\n"}
X: {Math.round(location.coords.longitude) + "\n"}
Z: {Math.round(location.coords.latitude)}
X: {Math.round(location.longitude) + "\n"}
Z: {Math.round(location.latitude)}
</Text>
</Callout>
);