11import React , { useEffect } from 'react' ;
22import type { ReactNode } from 'react' ;
33import type { OnyxEntry } from 'react-native-onyx' ;
4- import { useMemoizedLazyExpensifyIcons } from '@hooks/useLazyAsset' ;
4+ import useMapMarkers from '@hooks/useMapMarkers' ;
5+ import type { MapMarkerType } from '@hooks/useMapMarkers/types' ;
56import useNetwork from '@hooks/useNetwork' ;
67import useOnyx from '@hooks/useOnyx' ;
78import useStyleUtils from '@hooks/useStyleUtils' ;
8- import useTheme from '@hooks/useTheme' ;
99import useThemeStyles from '@hooks/useThemeStyles' ;
1010import getArrayDepth from '@libs/getArrayDepth' ;
1111import { getWaypointIndex } from '@libs/TransactionUtils' ;
1212import { init as initMapboxToken , stop as stopMapboxToken } from '@userActions/MapboxToken' ;
1313import CONST from '@src/CONST' ;
1414import ONYXKEYS from '@src/ONYXKEYS' ;
1515import type { Transaction } from '@src/types/onyx' ;
16- import type IconAsset from '@src/types/utils/IconAsset' ;
1716import DistanceMapView from './DistanceMapView' ;
18- import ImageSVG from './ImageSVG' ;
1917import type { WayPoint } from './MapView/MapViewTypes' ;
2018import PendingMapView from './MapView/PendingMapView' ;
2119
@@ -42,10 +40,9 @@ function ConfirmedRoute({transaction, isSmallerIcon, shouldHaveBorderRadius = tr
4240 const { route0 : route } = transaction ?. routes ?? { } ;
4341 const waypoints = transaction ?. comment ?. waypoints ?? { } ;
4442 const coordinates = route ?. geometry ?. coordinates ?? [ ] ;
45- const theme = useTheme ( ) ;
4643 const styles = useThemeStyles ( ) ;
4744 const StyleUtils = useStyleUtils ( ) ;
48- const expensifyIcons = useMemoizedLazyExpensifyIcons ( [ 'DotIndicator' , 'DotIndicatorUnfilled' , 'Location' ] ) ;
45+ const getMapMarkerIconComponent = useMapMarkers ( ) ;
4946
5047 const [ mapboxAccessToken ] = useOnyx ( ONYXKEYS . MAPBOX_ACCESS_TOKEN ) ;
5148
@@ -54,15 +51,6 @@ function ConfirmedRoute({transaction, isSmallerIcon, shouldHaveBorderRadius = tr
5451 return stopMapboxToken ;
5552 } , [ ] ) ;
5653
57- const getMarkerComponent = ( icon : IconAsset ) : ReactNode => (
58- < ImageSVG
59- src = { icon }
60- width = { CONST . MAP_MARKER_SIZE }
61- height = { CONST . MAP_MARKER_SIZE }
62- fill = { theme . icon }
63- />
64- ) ;
65-
6654 const lastWaypointIndex = Object . keys ( waypoints ) . length - 1 ;
6755 const waypointMarkers : WayPoint [ ] = [ ] ;
6856 for ( const [ key , waypoint ] of Object . entries ( waypoints ) ) {
@@ -71,19 +59,17 @@ function ConfirmedRoute({transaction, isSmallerIcon, shouldHaveBorderRadius = tr
7159 }
7260
7361 const index = getWaypointIndex ( key ) ;
74- let MarkerComponent : IconAsset ;
62+ let markerType : MapMarkerType = 'WAYPOINT' ;
7563 if ( index === 0 ) {
76- MarkerComponent = expensifyIcons . DotIndicatorUnfilled ;
64+ markerType = 'START_WAYPOINT' ;
7765 } else if ( index === lastWaypointIndex ) {
78- MarkerComponent = expensifyIcons . Location ;
79- } else {
80- MarkerComponent = expensifyIcons . DotIndicator ;
66+ markerType = 'STOP_WAYPOINT' ;
8167 }
8268
8369 waypointMarkers . push ( {
8470 id : `${ waypoint . lng } ,${ waypoint . lat } ,${ index } ` ,
8571 coordinate : [ waypoint . lng , waypoint . lat ] as const ,
86- markerComponent : ( ) : ReactNode => getMarkerComponent ( MarkerComponent ) ,
72+ markerComponent : ( ) : ReactNode => getMapMarkerIconComponent ( markerType ) ,
8773 } ) ;
8874 }
8975
@@ -105,6 +91,7 @@ function ConfirmedRoute({transaction, isSmallerIcon, shouldHaveBorderRadius = tr
10591 waypoints = { waypointMarkers }
10692 styleURL = { CONST . MAPBOX . STYLE_URL }
10793 requireRouteToDisplayMap = { requireRouteToDisplayMap }
94+ shouldDisplayCurrentLocation = { false }
10895 />
10996 ) : (
11097 < PendingMapView
0 commit comments