You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a part of the Distance Request project. We're adding a feature with which users can request a reimbursement for gas expenses they incur while traveling by car. Please see the following video to check how this beta feature currently look like. This specific task is related getting the user's location in the flow of creating a distance request.
We’ll create a UseCurrentLocationButton which will render a View with styles.flexRow. Inside it will be a pin Expensicon and the text “Use current location”. The UseCurrentLocationButton will be rendered directly below the AddressSearch component.
When the button is pressed we will call getCurrentPosition(success, error, config) which will automatically prompt for the user’s location if needed. In the success callback we will clear any errors, set the text in the WaypointAddress input to “Your location”, access the user’s current location via position.coords.latitude/longitude, save the waypoint in Onyx with address: ‘Your location’, and then navigate back to the “Request money” page.
In the error callback we’ll call an action setLocationError() which will set the errorCode on a location object in Onyx. We’re using the errorCode instead of a message because we want to let the component handle displaying the proper error message. We’ll use a new component called LocationErrorMessage to display the error below the button. It will have a similar appearance to the DotIndicatorMessage but it will show one error at a time.
If the error.code is 1 for PERMISSION_DENIED then we will display the message "It looks like you have denied permission to your location. Please [allow location permission in settings](link to settings) and then try again”. We will render this error message using Text components and translation keys for the message before and after the link piece. The text in brackets will use a TextLink so that Linking.openURL will be able to open the settings on native and desktop. On web we will link to a new help.expensify.com page where there will be instructions for how to access location settings on each browser. Most modern browsers do not allow pages to link to settings for security reasons.
To fetch the link we’ll add to react-native-x-geolocation a function called getPermissionDeniedHelpLink(helpLink, settingsLink = 'app-settings:LOCATION_SETTINGS'). For the platform specific implementations we simply return the correct link. Although the function is a bit trivial it is configurable from the App side and handles the platform specific piece.
If I understand correctly, getPermissionDeniedHelpLink is a very simple function that returns helpLink if the code is running on Web and settingsLink if it's running on iOS or Android
If the error code is 2 for POSITION_UNAVAILABLE or 3 for TIMEOUT then we’ll use DotIndicatorMessage and display an error message like “We were unable to find your location, please try again or enter an address manually”.
This is a part of the Distance Request project. We're adding a feature with which users can request a reimbursement for gas expenses they incur while traveling by car. Please see the following video to check how this beta feature currently look like. This specific task is related getting the user's location in the flow of creating a distance request.
Video
Screen.Recording.2023-08-24.at.7.30.36.AM.mov
We’ll create a UseCurrentLocationButton which will render a View with styles.flexRow. Inside it will be a pin Expensicon and the text “Use current location”. The UseCurrentLocationButton will be rendered directly below the AddressSearch component.
When the button is pressed we will call getCurrentPosition(success, error, config) which will automatically prompt for the user’s location if needed. In the success callback we will clear any errors, set the text in the WaypointAddress input to “Your location”, access the user’s current location via position.coords.latitude/longitude, save the waypoint in Onyx with address: ‘Your location’, and then navigate back to the “Request money” page.
The
getCurrentPositionfunction is from the newreact-native-x-geolocationlibraryIn the error callback we’ll call an action setLocationError() which will set the errorCode on a location object in Onyx. We’re using the errorCode instead of a message because we want to let the component handle displaying the proper error message. We’ll use a new component called LocationErrorMessage to display the error below the button. It will have a similar appearance to the DotIndicatorMessage but it will show one error at a time.
If the error.code is 1 for PERMISSION_DENIED then we will display the message "It looks like you have denied permission to your location. Please [allow location permission in settings](link to settings) and then try again”. We will render this error message using Text components and translation keys for the message before and after the link piece. The text in brackets will use a TextLink so that Linking.openURL will be able to open the settings on native and desktop. On web we will link to a new help.expensify.com page where there will be instructions for how to access location settings on each browser. Most modern browsers do not allow pages to link to settings for security reasons.
To fetch the link we’ll add to react-native-x-geolocation a function called getPermissionDeniedHelpLink(helpLink, settingsLink = 'app-settings:LOCATION_SETTINGS'). For the platform specific implementations we simply return the correct link. Although the function is a bit trivial it is configurable from the App side and handles the platform specific piece.
If I understand correctly,
getPermissionDeniedHelpLinkis a very simple function that returnshelpLinkif the code is running on Web andsettingsLinkif it's running on iOS or AndroidIf the error code is 2 for POSITION_UNAVAILABLE or 3 for TIMEOUT then we’ll use DotIndicatorMessage and display an error message like “We were unable to find your location, please try again or enter an address manually”.
internal link
Upwork Automation - Do Not Edit