Skip to content

Commit 3405ace

Browse files
committed
Fix last user location updates, showing user location dot above the route on the map, rounded route line
1 parent 27cbef0 commit 3405ace

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/CONST/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9492,6 +9492,13 @@ const CONST = {
94929492
},
94939493

94949494
MODAL_MAX_HEIGHT_TO_WINDOW_HEIGHT_RATIO_LANDSCAPE_MODE: 0.75,
9495+
9496+
MAP_VIEW_LAYERS: {
9497+
USER_LOCATION_SOURCE: 'user-location-source',
9498+
USER_LOCATION: 'user-location',
9499+
ROUTE_SOURCE: 'route-source',
9500+
ROUTE_FILL: 'route-fill',
9501+
},
94959502
} as const;
94969503

94979504
const CONTINUATION_DETECTION_SEARCH_FILTER_KEYS = [

src/components/MapView/Direction.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Mapbox from '@rnmapbox/maps';
22
import useThemeStyles from '@hooks/useThemeStyles';
3+
import CONST from '@src/CONST';
34
import type {DirectionProps} from './MapViewTypes';
45

56
function Direction({coordinates}: DirectionProps) {
@@ -10,7 +11,7 @@ function Direction({coordinates}: DirectionProps) {
1011

1112
return (
1213
<Mapbox.ShapeSource
13-
id="routeSource"
14+
id={CONST.MAP_VIEW_LAYERS.ROUTE_SOURCE}
1415
shape={{
1516
type: 'Feature',
1617
properties: {},
@@ -21,7 +22,8 @@ function Direction({coordinates}: DirectionProps) {
2122
}}
2223
>
2324
<Mapbox.LineLayer
24-
id="routeFill"
25+
belowLayerID={CONST.MAP_VIEW_LAYERS.USER_LOCATION}
26+
id={CONST.MAP_VIEW_LAYERS.ROUTE_FILL}
2527
style={styles.mapDirection}
2628
/>
2729
</Mapbox.ShapeSource>

src/components/MapView/Direction.website.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React from 'react';
66
import {Layer, Source} from 'react-map-gl';
77
import {View} from 'react-native';
88
import useThemeStyles from '@hooks/useThemeStyles';
9+
import CONST from '@src/CONST';
910
import type {DirectionProps} from './MapViewTypes';
1011

1112
function Direction({coordinates}: DirectionProps) {
@@ -20,7 +21,7 @@ function Direction({coordinates}: DirectionProps) {
2021
<View>
2122
{!!coordinates && (
2223
<Source
23-
id="route"
24+
id={CONST.MAP_VIEW_LAYERS.ROUTE_SOURCE}
2425
type="geojson"
2526
data={{
2627
type: 'Feature',
@@ -32,9 +33,9 @@ function Direction({coordinates}: DirectionProps) {
3233
}}
3334
>
3435
<Layer
35-
id="route"
36+
id={CONST.MAP_VIEW_LAYERS.ROUTE_FILL}
3637
type="line"
37-
source="route"
38+
source={CONST.MAP_VIEW_LAYERS.ROUTE_SOURCE}
3839
paint={layerPointStyle}
3940
layout={layerLayoutStyle}
4041
/>

src/components/MapView/MapView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ function MapView({
278278
/>
279279
{interactive && (
280280
<Mapbox.ShapeSource
281-
id="user-location"
281+
id={CONST.MAP_VIEW_LAYERS.USER_LOCATION_SOURCE}
282282
shape={{
283283
type: 'FeatureCollection',
284284
features: [
@@ -294,8 +294,8 @@ function MapView({
294294
}}
295295
>
296296
<Mapbox.CircleLayer
297-
id="user-location-layer"
298-
sourceID="user-location"
297+
id={CONST.MAP_VIEW_LAYERS.USER_LOCATION}
298+
sourceID={CONST.MAP_VIEW_LAYERS.USER_LOCATION_SOURCE}
299299
style={{
300300
circleColor: colors.blue400,
301301
circleRadius: 8,

src/libs/actions/GPSDraftDetails.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
66
import type {GpsDraftDetails} from '@src/types/onyx';
77
import type {Unit} from '@src/types/onyx/Policy';
88
import geodesicDistance from '@src/utils/geodesicDistance';
9+
import {setUserLocation} from './UserLocation';
910

1011
function resetGPSDraftDetails() {
1112
Onyx.merge(ONYXKEYS.GPS_DRAFT_DETAILS, null);
@@ -72,6 +73,12 @@ function addGpsPoints(gpsDraftDetails: OnyxEntry<GpsDraftDetails>, newGpsPoints:
7273

7374
const updatedGpsPoints = [...capturedPoints, ...gpsPointsToAdd];
7475

76+
const latestPoint = updatedGpsPoints.at(-1);
77+
78+
if (latestPoint) {
79+
setUserLocation({longitude: latestPoint.long, latitude: latestPoint.lat});
80+
}
81+
7582
if (updatedDistance > 0) {
7683
updateGpsTripNotificationDistance(updatedDistance);
7784
}

src/styles/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ type WorkspaceUpgradeIntroBoxParams = {isExtraSmallScreenWidth: boolean};
9191

9292
type OfflineFeedbackStyle = Record<'deleted' | 'pending' | 'default' | 'error' | 'container' | 'textContainer' | 'text' | 'errorDot', ViewStyle | TextStyle>;
9393

94-
type MapDirectionStyle = Pick<LineLayerStyleProps, 'lineColor' | 'lineWidth'>;
94+
type MapDirectionStyle = Pick<LineLayerStyleProps, 'lineColor' | 'lineWidth' | 'lineCap'>;
9595

9696
type MapDirectionLayerStyle = Pick<LineLayer, 'layout' | 'paint'>;
9797

@@ -6465,6 +6465,7 @@ const plainStyles = (theme: ThemeColors) =>
64656465
mapDirection: {
64666466
lineColor: theme.success,
64676467
lineWidth: 7,
6468+
lineCap: 'round',
64686469
},
64696470

64706471
mapDirectionLayer: {

0 commit comments

Comments
 (0)