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: Issues raised on iOS QA #325

Merged
merged 13 commits into from
Sep 19, 2023
Merged

Fix: Issues raised on iOS QA #325

merged 13 commits into from
Sep 19, 2023

Conversation

tuliomir
Copy link
Contributor

@tuliomir tuliomir commented Sep 11, 2023

Solves items from #318

Acceptance Criteria

  • Navigating to the "Receive" screen no longer marks an address as used
  • "Receive Amount" screen automatically focuses on the Keyboard
  • Clicking the "X" on the "Create Token" flow goes back to the dashboard screen
  • Clicking "Back" on the "Receive Transaction Details" after receiving a tx, goes back to the dashboard screen
  • Correct positioning of the "Receive Transaction Details" confirmation modal
  • Correct "Safe Area" insets for modals
  • Correct "Safe Area" insets for when the keyboard is being displayed
  • Dismisses keyboard whenever the "Pin Screen" is displayed

Tested on simulators for devices:

  • iPhone 13 mini
  • iPhone 13
  • iPhone SE (3rd gen)
  • iPhone 14 Pro

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@tuliomir tuliomir added the bug Something isn't working label Sep 11, 2023
@tuliomir tuliomir self-assigned this Sep 11, 2023
@@ -361,7 +361,6 @@ const AppStack = () => {
>
<Stack.Navigator
screenOptions={{
presentation: 'modal',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the iOS modals exhibition have changed, this property is no longer desired.

@tuliomir tuliomir requested review from andreabadesso and removed request for alexruzenhack September 11, 2023 15:49
@@ -114,7 +114,7 @@ class CreateTokenAmount extends React.Component {
<HathorHeader
title={t`CREATE TOKEN`}
onBackPress={() => this.props.navigation.goBack()}
onCancel={() => this.props.navigation.pop()}
onCancel={() => this.props.navigation.getParent()?.goBack()}
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if there is no parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ? operator was put there mostly as a coding best practice, but the idea is that there will always be a parent navigator there.

Not having a parent is a signal that there was a major refactor and our current hierarchy of navigators is different from expected. In that case, maybe throwing an exception would be a better way of informing the developer of the need to change this code as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the optional chaining operator on a38a087 .

await this.props.wallet.getNextAddress();
// When we create a new payment request, we don't update the address for a new one
// This will only happen when it receives a transaction and becomes a used address
await this.props.wallet.getCurrentAddress();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what's going on here, did we change the logic for getCurrentAddress and getNextAddress? When?

Copy link
Contributor Author

@tuliomir tuliomir Sep 15, 2023

Choose a reason for hiding this comment

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

This was requested on item n⁰ 9 on issue 318.

getNextAddress() not only fetches the next available address, but also marks the current one as used:

  async getNextAddress() {
    // First we mark the current address as used, then return the next
    await this.getCurrentAddress({ markAsUsed: true });

By changing the call to getCurrentAddress() we don't do this marking, and leave it to the wallet's new transaction websocket handler to do so.

If there is no property, it's better
to throw an error than to silence it.
@@ -17,7 +17,13 @@ class AmountTextInput extends React.Component {
}

focus = () => {
this.inputRef.current.focus();
/* After the focus method is called, the screen is still re-rendered at least once more.
Copy link
Member

Choose a reason for hiding this comment

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

Why is it happening just now? It was working before, wasn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was working before.
I couldn't find a decisive answer for why this stopped working, but it probably has something to do with the general changes to the focus related functions from React Navigation 4 to 5.

Copy link
Contributor Author

@tuliomir tuliomir Sep 18, 2023

Choose a reason for hiding this comment

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

A few considerations about this:

  • This focus command works perfectly when the screen is mounted at the same time it is rendered. So it works on the CreateTokenAmount and SendAmountInput just as it used to work before.
  • The problem happens on the NewPaymentRequest screen, that is built inside a tab bar. The AmountTextInput that needs to be focused here is mounted when the My Address tab is focused, and because of that is not available to be rendered/focused at mount time.
  • The tab management component currently used does not use the React Navigation material-top-tab-navigator wrapper, but instead uses directly its underlying react-native-tab-view lib.

That way, the focus event does not work as expected within the screen after the migration from Navigator 4 to 5 and 6. It only receives the focus event when changing from the Send stack to the Receive stack, for example.

I would suggest opening another PR to use the material-top-tab-navigator on this Receive stack instead of the tab view, so that we could have the focus events available on the screens again through React hooks and remove the edge case that brings the need for this setTimeout.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Create another issue to handle this and add it to the upgrade dependencies project, we can do it later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -75,7 +76,7 @@ const HathorHeader = (props) => {

const styles = StyleSheet.create({
wrapper: {
height: 56,
height: HEADER_HEIGHT,
Copy link
Member

Choose a reason for hiding this comment

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

The other PR you stop using this constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right: while this PR was already under review I came up with a better organization for this on 326.
This variable will be short lived on the constants file.

* Default Hathor Header height, used for recalculating layout offsets.
* @type {number}
*/
export const HEADER_HEIGHT = 56;
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed in the iOS color PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The utils.js still uses it on the 326 color PR. It will be completely removed soon on the colors refactor:

src/components/ReceiveMyAddress.js Outdated Show resolved Hide resolved
src/utils.js Show resolved Hide resolved
src/components/ModalConfirmation.js Outdated Show resolved Hide resolved
src/screens/PaymentRequestDetail.js Outdated Show resolved Hide resolved
@tuliomir tuliomir merged commit df914d5 into dev Sep 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants