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: add nfts to new assets redesign #4267

Merged
merged 47 commits into from
Oct 10, 2023
Merged

feat: add nfts to new assets redesign #4267

merged 47 commits into from
Oct 10, 2023

Conversation

MuckT
Copy link
Collaborator

@MuckT MuckT commented Oct 5, 2023

Description

Adds Nft Collections to the new assets page. Nft items are displayed as groups in a section list instead of a flat list as was previously done in #3912. Now accepts an arbitrary number for NUM_OF_NFTS_PER_ROW constant.

2 Nfts Per Row 3 Nfts Per Row Error No Nfts

Test plan

  • Tested locally on iOS and Android
  • Unit tests updated

Related issues

Backwards compatibility

Yes

@MuckT MuckT changed the title Tomm/act 918 feat: add nfts to new assets redesign Oct 5, 2023
@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

Merging #4267 (f9c1296) into main (fe6215f) will increase coverage by 0.00%.
The diff coverage is 91.37%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4267   +/-   ##
=======================================
  Coverage   83.99%   84.00%           
=======================================
  Files         711      711           
  Lines       26131    26178   +47     
  Branches     3385     3401   +16     
=======================================
+ Hits        21950    21992   +42     
- Misses       4117     4120    +3     
- Partials       64       66    +2     
Files Coverage Δ
src/nfts/types.ts 100.00% <100.00%> (ø)
src/tokens/Assets.tsx 88.00% <91.22%> (+0.33%) ⬆️

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 fe6215f...f9c1296. Read the comment docs.

@MuckT
Copy link
Collaborator Author

MuckT commented Oct 5, 2023

I am seeing this warning in development mode: flexWrap: 'wrap' is not supported with the 'VirtualizedList' components. Consider using 'numColumns' with 'FlatList' instead. which seems concerning. There is some discussion about it in facebook/react-native#18079. Alternatively to ignoring this warning I could render one item which would be a FlatList containing all of the Nfts, but that also seems rather hacky.

@MuckT MuckT marked this pull request as ready for review October 6, 2023 00:48
@satish-ravi
Copy link
Contributor

I am seeing this warning in development mode: flexWrap: 'wrap' is not supported with the 'VirtualizedList' components. Consider using 'numColumns' with 'FlatList' instead. which seems concerning. There is some discussion about it in facebook/react-native#18079. Alternatively to ignoring this warning I could render one item which would be a FlatList containing all of the Nfts, but that also seems rather hacky.

This does seem concerning, given that the implication is not completely understood. One another way to implement this would be to make a section be 2 items and the render item function could render a single row with 2 items, which also seems a bit hacky, but maybe will make some of the styling cleaner.

@@ -172,6 +184,45 @@ describe('AssetsScreen', () => {
// TODO(ACT-918): assert nfts are displayed here
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be removed now. Also would be good good to assert that NftItem is not found before switching tabs in this test and other tests testing tab click (similar to how TokenBalanceItem and PositionItem is asserted)

Comment on lines 305 to 310
// For even indexes, add right margin; for odd indexes, add left margin.
// If the index is even and it's the last image, add a right margin to left-align the image in the last row.
index % 2 === 0
? { marginRight: Spacing.Regular16 } &&
index === nfts.length - 1 &&
styles.nftsLastImage
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand this. Is the right margin added for even indices if its not the last item? It seems like index === nfts.length - 1 would be false and this would ultimately result in a false. The right margin seems to be applied only for the last item (from styles.nftsLastImage) which also seems like it shouldn't make any difference since the last row will have only one item in this case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the last image is an even index we only need to apply the right margin. If the last image is an odd index we need to apply special style to align it left, otherwise we get cases where the last image is in the center of the two columns.

Comment on lines 268 to 269
: nfts.length
? [{ data: nfts }]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might be worth just doing an if else or switch and avoid the nested ternary.

Copy link
Contributor

@satish-ravi satish-ravi left a comment

Choose a reason for hiding this comment

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

Approved once horizontal padding / margin is fixed to match designs

src/tokens/Assets.tsx Outdated Show resolved Hide resolved
src/tokens/Assets.tsx Outdated Show resolved Hide resolved
@MuckT MuckT enabled auto-merge (squash) October 10, 2023 16:17
@MuckT MuckT merged commit 335c100 into main Oct 10, 2023
16 checks passed
@MuckT MuckT deleted the tomm/act-918 branch October 10, 2023 16: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.

2 participants