Moved callouts to a separate component

This commit is contained in:
Keannu Christian Bernasol 2023-08-15 14:53:58 +08:00
parent 146d80cc98
commit 040ffb622c
2 changed files with 47 additions and 29 deletions

View file

@ -0,0 +1,41 @@
import { Callout } from "react-native-maps";
import { LocationType } from "../../interfaces/Interfaces";
import styles from "../../styles";
import { Text } from "react-native";
// Map popup for user's location
type props = {
location: LocationType;
studying: boolean;
subject?: string;
};
export default function CustomMapCallout(props: props) {
let { location, studying, subject } = props;
if (location && location.coords) {
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"}
Studying: {subject}
</Text>
</Callout>
);
} else {
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)}
</Text>
</Callout>
);
}
}
return <></>;
}