|
@@ -1,8 +1,12 @@
|
|
|
-import { View, Image, Text } from 'react-native';
|
|
|
-import { Marker, Callout, CalloutSubview } from 'react-native-maps';
|
|
|
+import { useEffect, useRef } from 'react';
|
|
|
+import { View, Image, Text, TouchableOpacity, Platform } from 'react-native';
|
|
|
+import { Marker, Callout, CalloutSubview, MapMarker } from 'react-native-maps';
|
|
|
+import CustomCallout from '../CustomCallout';
|
|
|
+
|
|
|
import { styles } from './styles';
|
|
|
import { ItemSeries } from '../../../../types/map';
|
|
|
import { Colors } from 'src/theme';
|
|
|
+
|
|
|
import CheckSvg from 'assets/icons/mark.svg';
|
|
|
|
|
|
const MarkerItem = ({
|
|
@@ -18,48 +22,68 @@ const MarkerItem = ({
|
|
|
seriesName: string;
|
|
|
toggleSeries: (item: any) => void;
|
|
|
}) => {
|
|
|
- return (
|
|
|
- <Marker coordinate={coordinate} tracksViewChanges={false}>
|
|
|
- <View
|
|
|
- style={[styles.markerContainer, marker.visited === 1 && { backgroundColor: Colors.ORANGE }]}
|
|
|
- >
|
|
|
- <Image source={{ uri: iconUrl }} style={styles.icon} resizeMode="contain" />
|
|
|
- </View>
|
|
|
+ let markerRef = useRef<MapMarker>(null);
|
|
|
+ useEffect(() => {
|
|
|
+ if (markerRef.current && Platform.OS !== 'ios') {
|
|
|
+ markerRef.current?.showCallout();
|
|
|
+ }
|
|
|
+ }, [marker.visited]);
|
|
|
|
|
|
- <Callout tooltip style={styles.customView}>
|
|
|
- <View style={styles.calloutContainer}>
|
|
|
- <View style={styles.calloutImageContainer}>
|
|
|
- <Image source={{ uri: iconUrl }} style={styles.calloutImage} resizeMode="contain" />
|
|
|
- </View>
|
|
|
- <View style={styles.calloutTextContainer}>
|
|
|
- <Text style={styles.seriesName}>{seriesName}</Text>
|
|
|
- <Text style={styles.markerName}>{marker.name}</Text>
|
|
|
- </View>
|
|
|
- <CalloutSubview
|
|
|
- style={[
|
|
|
- styles.calloutButton,
|
|
|
- marker.visited === 1 && {
|
|
|
- backgroundColor: Colors.WHITE,
|
|
|
- borderWidth: 1,
|
|
|
- borderColor: Colors.BORDER_LIGHT
|
|
|
- }
|
|
|
- ]}
|
|
|
- onPress={() => toggleSeries(marker)}
|
|
|
- >
|
|
|
- {marker?.visited === 1 ? (
|
|
|
- <View style={styles.completedContainer}>
|
|
|
- <CheckSvg width={14} height={14} fill={Colors.DARK_BLUE} />
|
|
|
- <Text style={[styles.calloutButtonText, { color: Colors.DARK_BLUE }]}>
|
|
|
- Completed
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
- ) : (
|
|
|
- <Text style={styles.calloutButtonText}>Mark Completed</Text>
|
|
|
- )}
|
|
|
- </CalloutSubview>
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <Marker coordinate={coordinate} tracksViewChanges={false} ref={markerRef}>
|
|
|
+ <View
|
|
|
+ style={[
|
|
|
+ styles.markerContainer,
|
|
|
+ marker.visited === 1 && { backgroundColor: Colors.ORANGE }
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <Image source={{ uri: iconUrl }} style={styles.icon} resizeMode="contain" />
|
|
|
</View>
|
|
|
- </Callout>
|
|
|
- </Marker>
|
|
|
+ {Platform.OS === 'ios' ? (
|
|
|
+ <Callout tooltip style={styles.customView}>
|
|
|
+ <View style={styles.calloutContainer}>
|
|
|
+ <View style={styles.calloutImageContainer}>
|
|
|
+ <Image source={{ uri: iconUrl }} style={styles.calloutImage} resizeMode="contain" />
|
|
|
+ </View>
|
|
|
+ <View style={styles.calloutTextContainer}>
|
|
|
+ <Text style={styles.seriesName}>{seriesName}</Text>
|
|
|
+ <Text style={styles.markerName}>{marker.name}</Text>
|
|
|
+ </View>
|
|
|
+ <CalloutSubview
|
|
|
+ style={[
|
|
|
+ styles.calloutButton,
|
|
|
+ marker.visited === 1 && {
|
|
|
+ backgroundColor: Colors.WHITE,
|
|
|
+ borderWidth: 1,
|
|
|
+ borderColor: Colors.BORDER_LIGHT
|
|
|
+ }
|
|
|
+ ]}
|
|
|
+ onPress={() => toggleSeries(marker)}
|
|
|
+ >
|
|
|
+ {marker?.visited === 1 ? (
|
|
|
+ <View style={styles.completedContainer}>
|
|
|
+ <CheckSvg width={14} height={14} fill={Colors.DARK_BLUE} />
|
|
|
+ <Text style={[styles.calloutButtonText, { color: Colors.DARK_BLUE }]}>
|
|
|
+ Completed
|
|
|
+ </Text>
|
|
|
+ </View>
|
|
|
+ ) : (
|
|
|
+ <Text style={styles.calloutButtonText}>Mark Completed</Text>
|
|
|
+ )}
|
|
|
+ </CalloutSubview>
|
|
|
+ </View>
|
|
|
+ </Callout>
|
|
|
+ ) : (
|
|
|
+ <CustomCallout
|
|
|
+ marker={marker}
|
|
|
+ toggleSeries={toggleSeries}
|
|
|
+ iconUrl={iconUrl}
|
|
|
+ seriesName={seriesName}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </Marker>
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|