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

Display single waypoint #25161

Merged
merged 19 commits into from
Aug 22, 2023
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
35 changes: 7 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"react-native-web-linear-gradient": "^1.1.2",
"react-native-web-lottie": "^1.4.4",
"react-native-webview": "^11.17.2",
"react-native-x-maps": "1.0.6",
"react-native-x-maps": "^1.0.9",
"react-pdf": "^6.2.2",
"react-plaid-link": "3.3.2",
"react-web-config": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,7 @@ const CONST = {
},
STATUS_TEXT_MAX_LENGTH: 100,
SF_COORDINATES: [-122.4194, 37.7749],
MAPBOX_STYLE_URL: 'mapbox://styles/expensify/cllcoiqds00cs01r80kp34tmq',
NAVIGATION: {
TYPE: {
FORCED_UP: 'FORCED_UP',
Expand Down
33 changes: 33 additions & 0 deletions src/components/DistanceRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ function DistanceRequest({transactionID, transaction, mapboxAccessToken}) {
const numberOfWaypoints = _.size(waypoints);
const lastWaypointIndex = numberOfWaypoints - 1;

const waypointMarkers = _.filter(
_.map(waypoints, (waypoint, key) => {
if (!waypoint || waypoint.lng === undefined || waypoint.lat === undefined) {
return;
}

const index = Number(key.replace('waypoint', ''));
let MarkerComponent;
if (index === 0) {
MarkerComponent = Expensicons.DotIndicatorUnfilled;
} else if (index === lastWaypointIndex) {
MarkerComponent = Expensicons.Location;
} else {
MarkerComponent = Expensicons.DotIndicator;
}

return {
coordinate: [waypoint.lng, waypoint.lat],
markerComponent: () => (
<MarkerComponent
width={20}
height={20}
fill={theme.icon}
/>
),
};
}),
(waypoint) => waypoint,
);

// Show up to the max number of waypoints plus 1/2 of one to hint at scrolling
const halfMenuItemHeight = Math.floor(variables.baseMenuItemHeight / 2);
const scrollContainerMaxHeight = variables.baseMenuItemHeight * MAX_WAYPOINTS_TO_DISPLAY + halfMenuItemHeight;
Expand Down Expand Up @@ -175,13 +205,16 @@ function DistanceRequest({transactionID, transaction, mapboxAccessToken}) {
zoom: DEFAULT_ZOOM_LEVEL,
}}
style={styles.mapView}
waypoints={waypointMarkers}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding waypoints, we should have changed the default location from SF to the first value in waypoints to keep animations consist (coming from #29471)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that's a good point. Thank for letting us know!

styleURL={CONST.MAPBOX_STYLE_URL}
/>
) : (
<View style={[styles.mapPendingView]}>
<BlockingView
icon={Expensicons.EmptyStateRoutePending}
title={translate('distance.mapPending.title')}
subtitle={isOffline ? translate('distance.mapPending.subtitle') : translate('distance.mapPending.onlineSubtitle')}
shouldShowLink={false}
/>
</View>
)}
Expand Down
Loading