mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-05-17 03:48:06 +08:00
Moved callouts to a separate component
This commit is contained in:
parent
146d80cc98
commit
040ffb622c
2 changed files with 47 additions and 29 deletions
41
src/components/CustomMapCallout/CustomMapCallout.tsx
Normal file
41
src/components/CustomMapCallout/CustomMapCallout.tsx
Normal 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 <></>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue