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: Android - Map pending text shown in preview instead of icon #44187

Merged
merged 7 commits into from
Jun 23, 2024
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
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;
Loading