Skip to content

Commit

Permalink
Merge pull request #44187 from Krishna2323/krishna2323/issue/43420
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Jun 23, 2024
2 parents 17e9d09 + ae45b46 commit 4dc1710
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/components/ConfirmedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function ConfirmedRoute({mapboxAccessToken, transaction, isSmallerIcon, shouldHa
style={[styles.mapView, shouldHaveBorderRadius && styles.br4]}
waypoints={waypointMarkers}
styleURL={CONST.MAPBOX.STYLE_URL}
requireRouteToDisplayMap={requireRouteToDisplayMap}
/>
) : (
<PendingMapView
Expand Down
29 changes: 20 additions & 9 deletions src/components/DistanceMapView/index.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ import {View} from 'react-native';
import BlockingView from '@components/BlockingViews/BlockingView';
import * as Expensicons from '@components/Icon/Expensicons';
import MapView from '@components/MapView';
import PendingMapView from '@components/MapView/PendingMapView';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import type DistanceMapViewProps from './types';

function DistanceMapView({overlayStyle, ...rest}: DistanceMapViewProps) {
function DistanceMapView({overlayStyle, requireRouteToDisplayMap, ...rest}: DistanceMapViewProps) {
const styles = useThemeStyles();
const [isMapReady, setIsMapReady] = useState(false);
const {isOffline} = useNetwork();
const {translate} = useLocalize();
const theme = useTheme();
const StyleUtils = useStyleUtils();

return (
<>
Expand All @@ -29,14 +32,22 @@ function DistanceMapView({overlayStyle, ...rest}: DistanceMapViewProps) {
}}
/>
{!isMapReady && (
<View style={[styles.mapViewOverlay, overlayStyle]}>
<BlockingView
icon={Expensicons.EmptyStateRoutePending}
title={translate('distance.mapPending.title')}
subtitle={isOffline ? translate('distance.mapPending.subtitle') : translate('distance.mapPending.onlineSubtitle')}
shouldShowLink={false}
iconColor={theme.border}
/>
<View style={[styles.mapViewOverlay, overlayStyle, requireRouteToDisplayMap && StyleUtils.getBorderRadiusStyle(0)]}>
{/* The "map pending" text should only be shown in the IOU create flow. In the created IOU preview, only the icon should be shown. */}
{!requireRouteToDisplayMap ? (
<BlockingView
icon={Expensicons.EmptyStateRoutePending}
title={translate('distance.mapPending.title')}
subtitle={isOffline ? translate('distance.mapPending.subtitle') : translate('distance.mapPending.onlineSubtitle')}
shouldShowLink={false}
iconColor={theme.border}
/>
) : (
<PendingMapView
isSmallerIcon
style={StyleUtils.getBorderRadiusStyle(0)}
/>
)}
</View>
)}
</>
Expand Down
4 changes: 4 additions & 0 deletions src/components/DistanceMapView/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import type {MapViewProps} from '@components/MapView/MapViewTypes';

type DistanceMapViewProps = MapViewProps & {
overlayStyle?: StyleProp<ViewStyle>;

/** Whether it should display the Mapbox map only when the route/coordinates exist otherwise
* it will display pending map icon */
requireRouteToDisplayMap?: boolean;
};

export default DistanceMapViewProps;

0 comments on commit 4dc1710

Please sign in to comment.