-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 - wrong location briefly shows before San Francisco upon first open of the Distance request page #27395
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
07abca9
implement DistanceMapView with blocking view for Android native
akinwale 022e00a
make the onMapReady prop optional
akinwale d9acbdc
Merge remote-tracking branch 'upstream/main' into task-27087
akinwale de783fd
fix themeColors -> theme
akinwale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/components/DistanceMapView/distanceMapViewPropTypes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
// Public access token to be used to fetch map data from Mapbox. | ||
accessToken: PropTypes.string.isRequired, | ||
|
||
// Style applied to MapView component. Note some of the View Style props are not available on ViewMap | ||
style: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), | ||
|
||
// Link to the style JSON document. | ||
styleURL: PropTypes.string, | ||
|
||
// Whether map can tilt in the vertical direction. | ||
pitchEnabled: PropTypes.bool, | ||
|
||
// Padding to apply when the map is adjusted to fit waypoints and directions | ||
mapPadding: PropTypes.number, | ||
|
||
// Initial coordinate and zoom level | ||
initialState: PropTypes.shape({ | ||
location: PropTypes.arrayOf(PropTypes.number).isRequired, | ||
zoom: PropTypes.number.isRequired, | ||
}), | ||
|
||
// Locations on which to put markers | ||
waypoints: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
id: PropTypes.string, | ||
coordinate: PropTypes.arrayOf(PropTypes.number), | ||
markerComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func]), | ||
}), | ||
), | ||
|
||
// List of coordinates which together forms a direction. | ||
directionCoordinates: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)), | ||
|
||
// Callback to call when the map is idle / ready | ||
onMapReady: PropTypes.func, | ||
|
||
// Optional additional styles to be applied to the overlay | ||
overlayStyle: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), | ||
}; | ||
|
||
const defaultProps = { | ||
styleURL: undefined, | ||
pitchEnabled: false, | ||
mapPadding: 0, | ||
initialState: undefined, | ||
waypoints: undefined, | ||
directionCoordinates: undefined, | ||
onMapReady: () => {}, | ||
overlayStyle: undefined, | ||
}; | ||
|
||
export {propTypes, defaultProps}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, {useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import BlockingView from '../BlockingViews/BlockingView'; | ||
import MapView from '../MapView'; | ||
import styles from '../../styles/styles'; | ||
import useNetwork from '../../hooks/useNetwork'; | ||
import useLocalize from '../../hooks/useLocalize'; | ||
import * as Expensicons from '../Icon/Expensicons'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import * as distanceMapViewPropTypes from './distanceMapViewPropTypes'; | ||
|
||
function DistanceMapView(props) { | ||
const [isMapReady, setIsMapReady] = useState(false); | ||
const {isOffline} = useNetwork(); | ||
const {translate} = useLocalize(); | ||
|
||
return ( | ||
<> | ||
<MapView | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{..._.omit(props, 'overlayStyle')} | ||
onMapReady={() => { | ||
if (isMapReady) { | ||
return; | ||
} | ||
setIsMapReady(true); | ||
}} | ||
/> | ||
{!isMapReady && ( | ||
<View style={StyleUtils.combineStyles(styles.mapViewOverlay, props.overlayStyle)}> | ||
<BlockingView | ||
icon={Expensicons.EmptyStateRoutePending} | ||
title={translate('distance.mapPending.title')} | ||
subtitle={isOffline ? translate('distance.mapPending.subtitle') : translate('distance.mapPending.onlineSubtitle')} | ||
shouldShowLink={false} | ||
/> | ||
</View> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
DistanceMapView.propTypes = distanceMapViewPropTypes.propTypes; | ||
DistanceMapView.defaultProps = distanceMapViewPropTypes.defaultProps; | ||
DistanceMapView.displayName = 'DistanceMapView'; | ||
|
||
export default DistanceMapView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import _ from 'underscore'; | ||
import MapView from '../MapView'; | ||
import * as distanceMapViewPropTypes from './distanceMapViewPropTypes'; | ||
|
||
function DistanceMapView(props) { | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <MapView {..._.omit(props, 'overlayStyle')} />; | ||
} | ||
|
||
DistanceMapView.propTypes = distanceMapViewPropTypes.propTypes; | ||
DistanceMapView.defaultProps = distanceMapViewPropTypes.defaultProps; | ||
DistanceMapView.displayName = 'DistanceMapView'; | ||
|
||
export default DistanceMapView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code block introduced the following issue:
Which was fixed by showing
BlockingView
only when!requireRouteToDisplayMap
, otherwise showPendingMapView
.