Skip to content

Commit

Permalink
disable map interaction in money request preview
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Apr 24, 2024
1 parent fd8ef99 commit 0d45c55
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/components/ConfirmedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ type ConfirmedRoutePropsOnyxProps = {
type ConfirmedRouteProps = ConfirmedRoutePropsOnyxProps & {
/** Transaction that stores the distance expense data */
transaction: OnyxEntry<Transaction>;

/** Whether the map is interactable or not */
interactive?: boolean;
};

function ConfirmedRoute({mapboxAccessToken, transaction}: ConfirmedRouteProps) {
function ConfirmedRoute({mapboxAccessToken, transaction, interactive}: ConfirmedRouteProps) {
const {isOffline} = useNetwork();
const {route0: route} = transaction?.routes ?? {};
const waypoints = transaction?.comment?.waypoints ?? {};
Expand Down Expand Up @@ -89,6 +92,7 @@ function ConfirmedRoute({mapboxAccessToken, transaction}: ConfirmedRouteProps) {

return !isOffline && Boolean(mapboxAccessToken?.token) ? (
<DistanceMapView
interactive={interactive}
accessToken={mapboxAccessToken?.token ?? ''}
mapPadding={CONST.MAP_PADDING}
pitchEnabled={false}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MapView/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {ComponentProps, MapViewOnyxProps} from './types';
import utils from './utils';

const MapView = forwardRef<MapViewHandle, ComponentProps>(
({accessToken, style, mapPadding, userLocation: cachedUserLocation, styleURL, pitchEnabled, initialState, waypoints, directionCoordinates, onMapReady}, ref) => {
({accessToken, style, mapPadding, userLocation: cachedUserLocation, styleURL, pitchEnabled, initialState, waypoints, directionCoordinates, onMapReady, interactive = true}, ref) => {
const navigation = useNavigation();
const {isOffline} = useNetwork();
const {translate} = useLocalize();
Expand Down Expand Up @@ -145,7 +145,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
};

return !isOffline && Boolean(accessToken) && Boolean(currentPosition) ? (
<View style={style}>
<View style={[style, !interactive ? styles.pointerEventsNone : {}]}>
<Mapbox.MapView
style={{flex: 1}}
styleURL={styleURL}
Expand Down
2 changes: 2 additions & 0 deletions src/components/MapView/MapView.website.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
userLocation: cachedUserLocation,
directionCoordinates,
initialState = {location: CONST.MAPBOX.DEFAULT_COORDINATE, zoom: CONST.MAPBOX.DEFAULT_ZOOM},
interactive = true,
},
ref,
) => {
Expand Down Expand Up @@ -195,6 +196,7 @@ const MapView = forwardRef<MapViewHandle, ComponentProps>(
}}
style={StyleUtils.getTextColorStyle(theme.mapAttributionText)}
mapStyle={styleURL}
interactive={interactive}
>
{waypoints?.map(({coordinate, markerComponent, id}) => {
const MarkerComponent = markerComponent;
Expand Down
2 changes: 2 additions & 0 deletions src/components/MapView/MapViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type MapViewProps = {
directionCoordinates?: Array<[number, number]>;
// Callback to call when the map is idle / ready.
onMapReady?: () => void;
// Whether the map is interactable or not
interactive?: boolean;
};

type DirectionProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ function MoneyRequestPreviewContent({
>
{showMapAsImage && (
<View style={styles.reportActionItemImages}>
<ConfirmedRoute transaction={transaction} />
<ConfirmedRoute
transaction={transaction}
interactive={false}
/>
</View>
)}
{!showMapAsImage && hasReceipt && (
Expand Down
5 changes: 4 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ function MoneyRequestView({
>
<View style={styles.moneyRequestViewImage}>
{showMapAsImage ? (
<ConfirmedRoute transaction={transaction} />
<ConfirmedRoute
transaction={transaction}
interactive={false}
/>
) : (
<ReportActionItemImage
thumbnail={receiptURIs?.thumbnail}
Expand Down

0 comments on commit 0d45c55

Please sign in to comment.