diff --git a/src/components/CustomMapCallout/CustomMapCallout.tsx b/src/components/CustomMapCallout/CustomMapCallout.tsx new file mode 100644 index 0000000..26cea15 --- /dev/null +++ b/src/components/CustomMapCallout/CustomMapCallout.tsx @@ -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 ( + + + You are here {"\n"} + X: {Math.round(location.coords.longitude) + "\n"} + Z: {Math.round(location.coords.latitude) + "\n"} + Studying: {subject} + + + ); + } else { + return ( + + + You are here {"\n"} + X: {Math.round(location.coords.longitude) + "\n"} + Z: {Math.round(location.coords.latitude)} + + + ); + } + } + return <>; +} diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 8328f3a..2b910e2 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -22,6 +22,7 @@ import { } from "../../components/Api/Api"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useToast } from "react-native-toast-notifications"; +import CustomMapCallout from "../../components/CustomMapCallout/CustomMapCallout"; export default function Home() { // Switch this condition to see the main map when debugging @@ -188,34 +189,6 @@ export default function Home() { }, }); - // Map popup for user's location - function CustomCallout() { - if (location && location.coords) { - if (studying) { - return ( - - - You are here {"\n"} - X: {Math.round(location.coords.longitude) + "\n"} - Z: {Math.round(location.coords.latitude) + "\n"} - Studying: {subject} - - - ); - } else { - return ( - - - You are here {"\n"} - X: {Math.round(location.coords.longitude) + "\n"} - Z: {Math.round(location.coords.latitude)} - - - ); - } - } - return <>; - } function CustomMap() { if (dist && location) { if (dist <= 2 || map_debug) { @@ -289,7 +262,11 @@ export default function Home() { }} pinColor={colors.primary_1} > - +