NTP-65681 | Map view crash fix (#1178)
This commit is contained in:
@@ -112,11 +112,11 @@ const MapViewWrapper = forwardRef<MapViewWrapperRef, MapViewWrapperProps>((props
|
|||||||
{...mapProps}
|
{...mapProps}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
{deviceGeolocationCoordinate && (
|
{deviceGeolocationCoordinate?.latitude && deviceGeolocationCoordinate?.longitude && (
|
||||||
<Marker
|
<Marker
|
||||||
coordinate={{
|
coordinate={{
|
||||||
latitude: deviceGeolocationCoordinate.latitude,
|
latitude: Number(deviceGeolocationCoordinate.latitude),
|
||||||
longitude: deviceGeolocationCoordinate.longitude,
|
longitude: Number(deviceGeolocationCoordinate.longitude),
|
||||||
}}
|
}}
|
||||||
onPress={() => currentLocationMarkerRef?.current?.showCallout()}
|
onPress={() => currentLocationMarkerRef?.current?.showCallout()}
|
||||||
tracksViewChanges={false}
|
tracksViewChanges={false}
|
||||||
@@ -138,8 +138,8 @@ const MapViewWrapper = forwardRef<MapViewWrapperRef, MapViewWrapperProps>((props
|
|||||||
{agentBaseLocation?.latitude && agentBaseLocation?.longitude && (
|
{agentBaseLocation?.latitude && agentBaseLocation?.longitude && (
|
||||||
<Marker
|
<Marker
|
||||||
coordinate={{
|
coordinate={{
|
||||||
latitude: agentBaseLocation.latitude,
|
latitude: Number(agentBaseLocation.latitude),
|
||||||
longitude: agentBaseLocation.longitude,
|
longitude: Number(agentBaseLocation.longitude),
|
||||||
}}
|
}}
|
||||||
onPress={() => baseLocationMarkerRef?.current?.showCallout()}
|
onPress={() => baseLocationMarkerRef?.current?.showCallout()}
|
||||||
tracksViewChanges={false}
|
tracksViewChanges={false}
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ const CustomMarker = (props: CustomMarkerProps) => {
|
|||||||
key={caseReferenceId}
|
key={caseReferenceId}
|
||||||
identifier={caseReferenceId}
|
identifier={caseReferenceId}
|
||||||
coordinate={{
|
coordinate={{
|
||||||
latitude: caseDetails[caseReferenceId]?.addressLocation?.latitude,
|
latitude: Number(caseDetails[caseReferenceId]?.addressLocation?.latitude),
|
||||||
longitude: caseDetails[caseReferenceId]?.addressLocation?.longitude,
|
longitude: Number(caseDetails[caseReferenceId]?.addressLocation?.longitude),
|
||||||
}}
|
}}
|
||||||
tracksViewChanges={false}
|
tracksViewChanges={false}
|
||||||
onPress={() => handleMarkerPress(caseReferenceId)}
|
onPress={() => handleMarkerPress(caseReferenceId)}
|
||||||
|
|||||||
@@ -14,12 +14,19 @@ import { CLICKSTREAM_EVENT_NAMES } from '@common/Constants';
|
|||||||
interface MapButtonsProps {
|
interface MapButtonsProps {
|
||||||
buttonPosition: SharedValue<number>;
|
buttonPosition: SharedValue<number>;
|
||||||
mapRef: React.RefObject<MapViewWrapperRef>;
|
mapRef: React.RefObject<MapViewWrapperRef>;
|
||||||
|
visibleCard: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MapButtons = ({ buttonPosition, mapRef }: MapButtonsProps) => {
|
const MapButtons = ({ buttonPosition, mapRef, visibleCard }: MapButtonsProps) => {
|
||||||
const buttonAnimatedStyle = useAnimatedStyle(() => {
|
const buttonAnimatedStyle = useAnimatedStyle(() => {
|
||||||
|
let positionValue;
|
||||||
|
if (Number.isNaN(buttonPosition.value)) {
|
||||||
|
positionValue = visibleCard ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
positionValue = buttonPosition.value;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
bottom: buttonPosition.value * 208, // 208 is the height of the card
|
bottom: positionValue * 208, // 208 is the height of the card
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ const MapWithCasesPins = React.memo(({ filteredCasesList }: IMapWithCasesPins) =
|
|||||||
>
|
>
|
||||||
{markers}
|
{markers}
|
||||||
</MapViewWrapper>
|
</MapViewWrapper>
|
||||||
<MapButtons buttonPosition={buttonPosition} mapRef={mapRef} />
|
<MapButtons buttonPosition={buttonPosition} mapRef={mapRef} visibleCard={!!visibleCard} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ const UserCard: React.FC<UserCardProps> = ({ selectedCase, cardPosition }) => {
|
|||||||
const caseDetail = useAppSelector((state) => state.allCases?.caseDetails?.[selectedCase]) || {};
|
const caseDetail = useAppSelector((state) => state.allCases?.caseDetails?.[selectedCase]) || {};
|
||||||
|
|
||||||
const cardAnimatedStyle = useAnimatedStyle(() => {
|
const cardAnimatedStyle = useAnimatedStyle(() => {
|
||||||
|
const positionValue = Number.isNaN(cardPosition.value) ? 1 : cardPosition.value;
|
||||||
return {
|
return {
|
||||||
transform: [
|
transform: [
|
||||||
{
|
{
|
||||||
translateY: (1 - cardPosition.value) * 220, // 220 is the height of the card here as the profile picture takes the extra space
|
translateY: (1 - positionValue) * 220, // 220 is the height of the card here as the profile picture takes the extra space
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,7 +85,10 @@ const MapWithAddresses = ({ caseId }: IMapWithAddressesProps) => {
|
|||||||
? address?.rank
|
? address?.rank
|
||||||
: TOP_ADDRESS_PIN_SELECTED_Z_INDEX
|
: TOP_ADDRESS_PIN_SELECTED_Z_INDEX
|
||||||
}
|
}
|
||||||
coordinate={{ latitude: address.latitude, longitude: address.longitude }}
|
coordinate={{
|
||||||
|
latitude: Number(address.latitude),
|
||||||
|
longitude: Number(address.longitude),
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Pin address={address} />
|
<Pin address={address} />
|
||||||
</Marker>
|
</Marker>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
StyleSheet,
|
StyleSheet,
|
||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useCallback, useEffect, useRef } from 'react';
|
||||||
import { GenericStyles } from '@rn-ui-lib/styles';
|
import { GenericStyles } from '@rn-ui-lib/styles';
|
||||||
import { COLORS } from '@rn-ui-lib/colors';
|
import { COLORS } from '@rn-ui-lib/colors';
|
||||||
import Text from '@rn-ui-lib/components/Text';
|
import Text from '@rn-ui-lib/components/Text';
|
||||||
@@ -33,8 +33,19 @@ const TopAddressesList = ({ caseId, scrollToIndex }: ITopAddressesList) => {
|
|||||||
dispatch(getTopAddresses(caseId, PAGE_START));
|
dispatch(getTopAddresses(caseId, PAGE_START));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleScrollToIndexFailed = useCallback((info: { index: number }) => {
|
||||||
|
const wait = new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
wait.then(() => {
|
||||||
|
flatListRef.current?.scrollToIndex({
|
||||||
|
index: info.index,
|
||||||
|
animated: true,
|
||||||
|
viewPosition: 16,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (scrollToIndex != null && !isTopAddressesLoading) {
|
if (scrollToIndex != null && !isTopAddressesLoading && addresses?.length) {
|
||||||
InteractionManager.runAfterInteractions(() => {
|
InteractionManager.runAfterInteractions(() => {
|
||||||
flatListRef.current?.scrollToIndex({
|
flatListRef.current?.scrollToIndex({
|
||||||
index: scrollToIndex - 1,
|
index: scrollToIndex - 1,
|
||||||
@@ -62,6 +73,7 @@ const TopAddressesList = ({ caseId, scrollToIndex }: ITopAddressesList) => {
|
|||||||
refreshControl={<RefreshControl refreshing={false} onRefresh={onRefresh} />}
|
refreshControl={<RefreshControl refreshing={false} onRefresh={onRefresh} />}
|
||||||
contentContainerStyle={[GenericStyles.p16, GenericStyles.mb24]}
|
contentContainerStyle={[GenericStyles.p16, GenericStyles.mb24]}
|
||||||
renderItem={({ item }) => <OtherAddressItem locationDetails={item} caseId={caseId} />}
|
renderItem={({ item }) => <OtherAddressItem locationDetails={item} caseId={caseId} />}
|
||||||
|
onScrollToIndexFailed={handleScrollToIndexFailed}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<View style={[GenericStyles.justifyContentCenter, GenericStyles.alignCenter, styles.h100]}>
|
<View style={[GenericStyles.justifyContentCenter, GenericStyles.alignCenter, styles.h100]}>
|
||||||
|
|||||||
Reference in New Issue
Block a user