From a48d28547b98e4bf179875ec0c5eb52a8fc5f663 Mon Sep 17 00:00:00 2001 From: mvaivre Date: Mon, 19 Aug 2024 10:54:31 +0200 Subject: [PATCH] Improve NFT grid --- .../mobile-wallet/src/components/NFTsGrid.tsx | 21 +++++++++++++------ .../src/screens/NFTs/NFTSScreen.tsx | 2 -- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/mobile-wallet/src/components/NFTsGrid.tsx b/apps/mobile-wallet/src/components/NFTsGrid.tsx index 9bc044ed2a..a42155f0e9 100644 --- a/apps/mobile-wallet/src/components/NFTsGrid.tsx +++ b/apps/mobile-wallet/src/components/NFTsGrid.tsx @@ -19,7 +19,6 @@ along with the library. If not, see . import { AddressHash, NFT } from '@alephium/shared' import { FlashList } from '@shopify/flash-list' import { useMemo } from 'react' -import { useTranslation } from 'react-i18next' import { ActivityIndicator, Dimensions } from 'react-native' import styled, { useTheme } from 'styled-components/native' @@ -37,27 +36,31 @@ interface NFTsGridProps extends ModalContentProps { nftSize?: number } -const gap = 12 -const screenPadding = DEFAULT_MARGIN +const gap = DEFAULT_MARGIN / 2 +const containerHorizontalPadding = DEFAULT_MARGIN - gap const NFTsGrid = ({ addressHash, nfts: nftsProp, nftSize, nftsPerRow = 3 }: NFTsGridProps) => { const selectAddressesNFTs = useMemo(makeSelectAddressesNFTs, []) const nfts = useAppSelector((s) => selectAddressesNFTs(s, addressHash)) const isLoadingNfts = useAppSelector((s) => s.nfts.loading) const theme = useTheme() - const { t } = useTranslation() const data = nftsProp ?? nfts const columns = nftsPerRow const { width: windowWidth } = Dimensions.get('window') - const totalGapSize = (columns - 1) * gap + screenPadding * 2 + const totalGapSize = columns * gap * 2 + containerHorizontalPadding * 2 const size = nftSize ?? (windowWidth - totalGapSize) / columns return ( item.id} - renderItem={({ item: nft }) => } + renderItem={({ item: nft }) => ( + + + + )} + contentContainerStyle={{ paddingHorizontal: containerHorizontalPadding }} numColumns={columns} estimatedItemSize={64} ListEmptyComponent={ @@ -78,6 +81,12 @@ const NFTsGrid = ({ addressHash, nfts: nftsProp, nftSize, nftsPerRow = 3 }: NFTs export default NFTsGrid +const NFTThumbnailContainer = styled.View` + margin: ${gap}px; + overflow: hidden; + border-radius: 9px; +` + const NoNFTsMessage = styled.View` text-align: center; justify-content: center; diff --git a/apps/mobile-wallet/src/screens/NFTs/NFTSScreen.tsx b/apps/mobile-wallet/src/screens/NFTs/NFTSScreen.tsx index 0de2d3ab91..4e03d611a4 100644 --- a/apps/mobile-wallet/src/screens/NFTs/NFTSScreen.tsx +++ b/apps/mobile-wallet/src/screens/NFTs/NFTSScreen.tsx @@ -24,7 +24,6 @@ import NFTsGrid from '~/components/NFTsGrid' import { InWalletTabsParamList } from '~/navigation/InWalletNavigation' import { ReceiveNavigationParamList } from '~/navigation/ReceiveNavigation' import { SendNavigationParamList } from '~/navigation/SendNavigation' -import { DEFAULT_MARGIN } from '~/style/globalStyle' interface ScreenProps extends StackScreenProps, @@ -39,7 +38,6 @@ const NFTsScreen = ({ navigation, ...props }: ScreenProps) => { verticalGap contrastedBg screenTitleAlwaysVisible - contentContainerStyle={{ padding: DEFAULT_MARGIN }} headerOptions={{ headerTitle: t('NFTs') }}