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

Create currency modal with react-native-permissions and geolocation #2194

Merged
merged 64 commits into from
May 20, 2021

Conversation

rameshhpathak
Copy link
Contributor

@rameshhpathak rameshhpathak commented Apr 1, 2021

<If necessary, assign reviewers that know the area or changes well. Feel free to tag any additional reviewers you see fit.>

Details

I used react-native-geolocation-service because the original library itself suggests to use it based on it's use of Google Services in Android.

From the library itself:

Currently, on Android, this uses the android.location API. This API is not recommended by Google because it is less accurate and slower than the recommended Google Location Services API. This is something that we want to change in the near future https://github.com/react-native-community/react-native-geolocation/issues/6.

Fixed Issues

Fixes #1970

Tests

1. Go to /iou/split on web. Verify that the currency is based on your location.
2. Click on the currency, a list with all currencies should show.
3. Search for a currency, or scroll down to your desired currency
4. Click on the currency to select and click on the Confirm button the confirm selection
5. Verify that the selected currency shows now in the amount page
6. Refresh the page, and verify that the same currency shows in the amount page

QA Steps

Same as tests

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Screenshot 2021-04-12 at 12 49 55

Screenshot 2021-04-12 at 12 50 24

@rameshhpathak rameshhpathak marked this pull request as ready for review April 1, 2021 06:55
@rameshhpathak rameshhpathak requested a review from a team as a code owner April 1, 2021 06:55
@MelvinBot MelvinBot requested review from jasperhuangg and removed request for a team April 1, 2021 06:55
@rameshhpathak rameshhpathak changed the title Install react-native-permissions and Geolocation Create currency modal with react-native-permissions and geolocation Apr 1, 2021
@Julesssss
Copy link
Contributor

Hi @rameshhpathak, thanks for raising the PR. I'm afraid I didn't get around to testing this today. Will do a full review after the easter bank holiday weekend (Tuesday)

ios/File.swift Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file required it seems blank?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the resolution here? I see these files were removed but there's still a BridgingFile.swift committed. Is that file necessary?

src/components/CreateMenu.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jasperhuangg jasperhuangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, also looks like there are a few merge conflicts that need to be resolved. Thanks!

src/ONYXKEYS.js Outdated Show resolved Hide resolved
src/libs/OptionsListUtils.js Outdated Show resolved Hide resolved
src/pages/iou/steps/IOUAmountPage.js Outdated Show resolved Hide resolved
src/pages/iou/steps/IOUCurrencySelection.js Outdated Show resolved Hide resolved
@rameshhpathak
Copy link
Contributor Author

Hey @jasperhuangg @AndrewGable thank you for your reviews, I will resolve the issues in line with the comments you have sent

@AndrewGable
Copy link
Contributor

@rameshhpathak - Can you fix the failing test? Thanks!

@shawnborton
Copy link
Contributor

I would also love to see some updated screenshots. From what I can tell, some of the spacing looks off. You should be able to use the "New Group" flow in Expensify.cash to see exactly what the spacing should look like in terms of an existing piece of UI where we have a text input, then rows of information, with a floating button at the bottom.

@@ -432,11 +432,37 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
return '';
}

/**
* Returns the personal details for an array of logins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't correct

isSearchStringMatch(searchValue, currencyOption.searchText)));

return {
// currency options holds a section for those currencies which are not selected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this comment means, could you please clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Julesssss I think this was missed while I was staging changes. I will change it.

*
* @param {Object} details
*/
function setCurrencyPreferences() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be called fetchCurrencyPreferences to match the other functions called on app start.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Comment on lines 57 to 58
const {currencyOptions} = getCurrencyListForSections(this.props.currencyList,
'');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the newline?

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a few things in my first review:

  • The Currency Modal is supposed to be separate from the IOUModal, rather than a step within the flow. It should open on top of the current modal and then close to reveal the IOU Modal again.
  • At the main page after logging in on web I was asked for location permission, we want to avoid this and only ask if the user changes their currency. We don't want to ask this on every refresh. Only if previously enabled should we make the check on app start.
  • I'm unable to build to iOS or Android, can you confirm you haven't faced the same problem?

@rameshhpathak
Copy link
Contributor Author

Noticed a few things in my first review:

* The Currency Modal is supposed to be separate from the IOUModal, rather than a step within the flow. It should open on top of the current modal and then close to reveal the IOU Modal again.

* At the main page after logging in on web I was asked for location permission, we want to avoid this and only ask if the user changes their currency. We don't want to ask this on every refresh. Only if previously enabled should we make the check on app start.

* I'm unable to build to iOS or Android, can you confirm you haven't faced the same problem?
  1. Oh okay. I will make the necessary changes.
  2. So we only make this request inside the setCurrencyLocation (renamed: fetchCurrencyLocation) function? Alright.

I will make the necessary changes and solve the build problems in my next commit. I have added comments to your review as well. Thanks!

@Julesssss Julesssss dismissed their stale review May 20, 2021 13:02

Out of date

@rameshhpathak
Copy link
Contributor Author

@Julesssss Sorry, I just switched it back, so we ask it every time user tries to change the currency through the modal.

@Julesssss
Copy link
Contributor

Sorry @rameshhpathak that's not quite right. Can you revert the last commit and we'll worry about this permission prompt later? Thanks 👍

@Julesssss
Copy link
Contributor

There are two very last issues to do with prop type validation, after that I think we're good to merge:

Opening the CurrencyModal A

Warning: Failed prop type: The prop `optionIsFocused` is marked as required in `OptionRow`, but its value is `undefined`.
    in OptionRow (created by ItemWithSeparator)
    in ItemWithSeparator (created by CellRenderer)
    in div (created by View)
    in View (created by CellRenderer)
    in CellRenderer (created by VirtualizedList)
    in div (created by View)
    in View (created by ScrollView)
    in div (created by View)
    in View (created by ForwardRef)
    in ForwardRef (created by ScrollView)
    in ScrollView (created by VirtualizedList)
    in VirtualizedList (created by VirtualizedSectionList)

Opening the CurrencyModal B

Failed prop type: The prop `option.alternateText` is marked as required in `OptionRow`, but its value is `undefined`.
    in OptionRow (created by ItemWithSeparator)
    in ItemWithSeparator (created by CellRenderer)
    in div (created by View)
    in View (created by CellRenderer)
    in CellRenderer (created by VirtualizedList)
    in div (created by View)
    in View (created by ScrollView)
    in div (created by View)
    in View (created by ForwardRef)

@rameshhpathak
Copy link
Contributor Author

Hi @Julesssss Done :)

Julesssss
Julesssss previously approved these changes May 20, 2021
Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for the changes! Looking good.

To unblock other IOU issues we'll create a separate issue to A) Modify the prompt logic to occur after a new currency is selected, and B) use the location permission prompt for mobile.

@Julesssss
Copy link
Contributor

Julesssss commented May 20, 2021

@rameshhpathak -- could you just run pod install from the ios folder, then commit and push the 'Podfile.lock' changes? The iOS app won't build locally without this change. Thanks!

@Julesssss
Copy link
Contributor

Hey @rameshhpathak, just bumping again in the hope you see this today. We'll likely have more conflicts to solve again tomorrow else 🙁

@rameshhpathak
Copy link
Contributor Author

Hi @Julesssss sorry for late reply. I did push it, please take a look

@rameshhpathak
Copy link
Contributor Author

@Julesssss

@Julesssss
Copy link
Contributor

Fantastic, thanks again @rameshhpathak. I think we'll have some much smaller follow-up issues here if that's something you're interested in.

@Julesssss Julesssss merged commit ceb36f2 into Expensify:main May 20, 2021
@rameshhpathak
Copy link
Contributor Author

@Julesssss Of course! I will be in the look out for it! Thank you for your help!

@isagoico
Copy link

isagoico commented May 20, 2021

Not sure if this PR covers the following issue so please let me know if I should open it separately

Currency in LHN does not match the requested currency

Expected Result

Contact will have a badge indicating there is money requested with the correct currency.

Actual Result

Badge is there, but currency does not match. It always displays $

Action Performed

  1. Open staging.expensify.cash and login
  2. Request money to a contact you have messages with
  3. Choose local currency / other than USD

Platform

Issue is reproduced in?

Web ✔️

Notes/Images/Video

image

@iwiznia
Copy link
Contributor

iwiznia commented May 20, 2021

That's known and is going to be fixed here

@isagoico
Copy link

Great! Will check the PR off then, Thanks 🙇

@Julesssss
Copy link
Contributor

Thanks @marcaaron, good points. @rameshhpathak would you mind following up with these changes?

@rameshhpathak
Copy link
Contributor Author

Hi @Julesssss, sure! Will send a PR later tonight.

@Julesssss
Copy link
Contributor

Hi @rameshhpathak, have you been able to take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Pay on Thursday 27th May] [IOU] Create Currency Modal, with geolocation and Location permissions
10 participants