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

feat(swap): Initial Swap screen redesign #5409

Merged
merged 15 commits into from
May 21, 2024
Merged

feat(swap): Initial Swap screen redesign #5409

merged 15 commits into from
May 21, 2024

Conversation

jophish
Copy link
Contributor

@jophish jophish commented May 13, 2024

Description

First part of RET-1065. Updates the design of swap screen to match the designs in Figma. The rest of the behavior outlined in the ticket will come in followup PRs.

Test plan

Unit and manual tested. See video below:

swap-redesign-2024-05-13_17.03.19.mp4

Related issues

Backwards compatibility

Yes.

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 89.47368% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 86.31%. Comparing base (5946f19) to head (6851300).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5409   +/-   ##
=======================================
  Coverage   86.31%   86.31%           
=======================================
  Files         756      756           
  Lines       31185    31205   +20     
  Branches     5347     5353    +6     
=======================================
+ Hits        26916    26935   +19     
- Misses       4036     4037    +1     
  Partials      233      233           
Files Coverage Δ
src/analytics/Events.tsx 100.00% <100.00%> (ø)
src/analytics/Properties.tsx 100.00% <ø> (ø)
src/components/Touchable.tsx 100.00% <100.00%> (ø)
src/icons/DownIndicator.tsx 100.00% <100.00%> (ø)
src/swap/SwapScreen.tsx 93.78% <100.00%> (+0.09%) ⬆️
src/swap/SwapAmountInput.tsx 91.66% <83.78%> (+0.62%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5946f19...6851300. Read the comment docs.

Copy link
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

Great!

Things/questions I noted from the video:

  • Does the token selection also work when tapping the container of the down arrow?
  • The right padding/margin in the skeleton loader seems different from the left one. It should be the same.
  • The ripple effect on the switch token button is being clipped by containers above and below it. It should be above them.
  • I'm slightly concerned by the fact that the "MAX" button can change position based on the length of the $ value. Maybe something we can improve with Kayla?

locales/base/translation.json Outdated Show resolved Hide resolved
src/swap/SwapScreen.tsx Outdated Show resolved Hide resolved
@bakoushin
Copy link
Contributor

Looking great!

Noticed a few rendering issues:

  1. The switch token button is rendered behind the "to" field on the iOS emulator (see screenshot):
  1. If we put a really long number, everything breaks (see video). This could possibly be a real-life issue for fiats having really large denominations.
    Perhaps we could stop the fiat value from growing in width past 40% of the parent width?
Simulator.Screen.Recording.-.iPhone.15.-.2024-05-14.at.11.30.35.mp4
  1. +1 to Jean:
  • I would expect the whole top part of the swap amount box to be pressable. Not only the arrow button.
  • I wonder if instead of ripple across the switch token button, we can add a rotation animation instead? Like, the arrow after a tap rotates 360 degrees (don't know though if it is possible to turn off the ripple effect).

@jophish
Copy link
Contributor Author

jophish commented May 14, 2024

Responding to some comments:

@jeanregisser

Does the token selection also work when tapping the container of the down arrow?

It did not, but now it does - this required a bit of rejiggering to how Touchables work, since the border radius is uneven depending on the state of the screen.

The right padding/margin in the skeleton loader seems different from the left one. It should be the same.

Thanks! This has been fixed.

The ripple effect on the switch token button is being clipped by containers above and below it. It should be above them.

This was a tricky one. I'm somewhat sure that we were running up against this bug, since I did not encounter the adverse overlapping behavior when using PlatformTouchable.SelectableBackground() as the background. Fortunately, I was able to work around this using the foreground option instead of background as described here.

I'm slightly concerned by the fact that the "MAX" button can change position based on the length of the $ value. Maybe something we can improve with Kayla?

The designs have been updated to move the "MAX" button to the right of the fiat estimation.

@bakoushin

The switch token button is rendered behind the "to" field on the iOS emulator (see screenshot):

Would you mind testing on iOS again? This is working on Android, but made a few small changes.

If we put a really long number, everything breaks (see video). This could possibly be a real-life issue for fiats having really large denominations.

I've raised this with Kayla, waiting to hear back about design ideas.

I would expect the whole top part of the swap amount box to be pressable. Not only the arrow button.

Addressed above!

I wonder if instead of ripple across the switch token button, we can add a rotation animation instead?

I suppose we could do this, though if the ripple is working correctly (which it should be, now) we could also stick with that.

See new video here:

swap-redesign-2-2024-05-14_16.08.42.mp4

Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

looking great!

locales/base/translation.json Outdated Show resolved Hide resolved
locales/base/translation.json Outdated Show resolved Hide resolved
src/analytics/docs.ts Outdated Show resolved Hide resolved
src/swap/SwapScreen.tsx Outdated Show resolved Hide resolved
<PlatformTouchable
{...passThroughProps}
background={useForeground ? undefined : background}
foreground={useForeground ? background : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

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

i got really hung up on this even though it's not important because it's not easy to understand what useForeground means. (also reading if useForeground, use background is weird). it seems like this prop should be used if the Touchable has any images as children and you want the ripple to be rendered above the image - so perhaps a more intuitive prop for this component could be shouldRenderRippleAbove or rippleAboveImages or hasImageChildren?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, agreed that it's weird as-is... I like shouldRenderRippleAbove, since it does have utility outside of using images within the Touchable.

src/components/Touchable.tsx Outdated Show resolved Hide resolved
src/swap/SwapAmountInput.tsx Outdated Show resolved Hide resolved
...fontStyles.xsmall,
fontWeight: 'bold',
tokenInfo: {
flexDirection: 'row',
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think you need an alignItems center here so that the icon is vertically centered. if you increase your device font size, the icon is no longer centered currently

Copy link
Collaborator

Choose a reason for hiding this comment

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

bump on this! :)

src/swap/SwapScreen.tsx Outdated Show resolved Hide resolved
},
fiatValue: {
...typeScale.bodyXSmall,
paddingLeft: Spacing.Smallest8,
maxWidth: '40%',
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we're adding a max width, we should also add a numberOfLines={1} so that the text is ellipsised when the limit is hit rather than spreading to new lines (e.g. if you type a long number like 123455678923624856 in the token amount - unlikely to happen but if the device font size is large then this number can become smaller to reach the limit)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, good catch.. I had tried to do this but was setting numberOfLines={1} at the wrong layer and it wasn't working as intended. Setting it on the SwapAmountInput/FiatValue component works well!

Copy link
Collaborator

@kathaypacific kathaypacific left a comment

Choose a reason for hiding this comment

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

looks great!! 💅🏼

expect(within(swapFromContainer).getByText('CELO')).toBeTruthy()

expect(within(swapToContainer).getByTestId('SwapAmountInput/Input')).toBeTruthy()
expect(within(swapToContainer).getByText('cUSD')).toBeTruthy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: selectSwapTokens already includes these assertions so you don't need to do it again here :)

...fontStyles.xsmall,
fontWeight: 'bold',
tokenInfo: {
flexDirection: 'row',
Copy link
Collaborator

Choose a reason for hiding this comment

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

bump on this! :)

@jophish jophish added this pull request to the merge queue May 21, 2024
Merged via the queue into main with commit ea65cbc May 21, 2024
16 checks passed
@jophish jophish deleted the jophish/ret-1065 branch May 21, 2024 17:44
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.

None yet

4 participants