Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map can be moved in money request preview #40852

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading