Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

[LIVE-1035] - Feature: Add NFT counter value #2385

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a1b1c6a
Update NFT send flow for new NFT model
lambertkevin Mar 25, 2022
af1a180
Update operations for new NFT model
lambertkevin Mar 25, 2022
7a76556
Update NFT collections and gallery for new NFT model
lambertkevin Mar 25, 2022
de914dd
Update NFT in Account for new NFT model
lambertkevin Mar 25, 2022
bf72d15
Update NFT card and viewer for new NFT model
lambertkevin Mar 25, 2022
22bd593
Add missing error translation for NFT send quantity
lambertkevin Mar 25, 2022
b971d9d
New Crowdin updates (#2320)
gre Mar 29, 2022
8cf0e08
Update OperationRowNftName for V3
lambertkevin Mar 30, 2022
1f3bf5c
Update Skeleton for V3
lambertkevin Mar 30, 2022
4c263ff
Update NftCard for V3
lambertkevin Mar 30, 2022
997524a
Update NftCollectionRow for V3
lambertkevin Mar 30, 2022
e7f6a01
Update NftImage for V3 + add onError handler
lambertkevin Mar 30, 2022
1845aaf
Update NftLinksPanel for V3
lambertkevin Mar 30, 2022
a66f865
Update NftLinksPanel for V3
lambertkevin Mar 30, 2022
7b83a60
Update NftNavigator for V3
lambertkevin Mar 30, 2022
0b38fdb
Update NftCollectionsList for V3
lambertkevin Mar 30, 2022
6e824c6
Update NftCollection for V3
lambertkevin Mar 30, 2022
6cc8c78
Update NftCollectionHeaderTitle for V3
lambertkevin Mar 30, 2022
5b3ef76
Update NftCollectionWithName for V3
lambertkevin Mar 30, 2022
b49c40b
Update NftGalleryHeaderTitle for V3
lambertkevin Mar 30, 2022
1a377bf
Update NFT Send flow for V3
lambertkevin Mar 30, 2022
5deff8a
Update NFT Gallery for V3
lambertkevin Mar 30, 2022
a0ab7d2
Fix Operation details currencyId for NFT metadata
lambertkevin Mar 30, 2022
bf32e2f
Add LLC dependency
lambertkevin Mar 25, 2022
8f08d10
Update NFT Image Viewer for V3
lambertkevin Mar 31, 2022
391d7e2
Change status type in NftCard
lambertkevin Mar 31, 2022
74656a5
Fix all linting issues
lambertkevin Mar 31, 2022
13ccd20
Fix NftNavigator header
lambertkevin Mar 31, 2022
3db1366
Add counter value to NFT drawer
lambertkevin Apr 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@ledgerhq/errors": "6.10.0",
"@ledgerhq/hw-transport": "6.24.1",
"@ledgerhq/hw-transport-http": "6.27.0",
"@ledgerhq/live-common": "21.36.0",
"@ledgerhq/live-common": "https://github.com/LedgerHQ/ledger-live-common.git#1effe19c902a37475d858ef5bb82ff9724ccf7f6",
"@ledgerhq/logs": "6.10.0",
"@ledgerhq/native-ui": "^0.7.9",
"@ledgerhq/react-native-hid": "6.24.1",
Expand Down
1 change: 1 addition & 0 deletions src/components/BottomModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const BottomModal = ({
</View>
</View>
</ReactNativeModal>
</ButtonUseTouchable.Provider>
);
};

Expand Down
44 changes: 21 additions & 23 deletions src/components/Nft/NftCard.js → src/components/Nft/NftCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ import { RectButton } from "react-native-gesture-handler";
import { View, StyleSheet, Platform } from "react-native";
import { useNftMetadata } from "@ledgerhq/live-common/lib/nft";
import { useTheme, useNavigation } from "@react-navigation/native";
import type { CollectionWithNFT, NFT } from "@ledgerhq/live-common/lib/nft";
import { ScreenName } from "../../const";
import { ProtoNFT } from "@ledgerhq/live-common/lib/types";
import { NFTResource } from "@ledgerhq/live-common/lib/nft/NftMetadataProvider/types";
import { NavigatorName, ScreenName } from "../../const";
import Skeleton from "../Skeleton";
import NftImage from "./NftImage";
import LText from "../LText";

type Props = {
nft: NFT | $Diff<NFT, { collection: * }>,
collection: CollectionWithNFT,
style?: Object,
nft: ProtoNFT;
style?: Object;
};

const NftCardView = ({
nft,
collection,
style,
status,
metadata,
}: {
nft: NFT | $Diff<NFT, { collection: * }>,
collection: CollectionWithNFT,
style?: Object,
status: "queued" | "loading" | "loaded" | "error" | "nodata",
metadata?: Object,
nft: ProtoNFT;
style?: Object;
status: NFTResource["status"];
metadata?: Object;
}) => {
const amount = nft.amount.toFixed();
const { colors } = useTheme();
Expand All @@ -45,9 +43,11 @@ const NftCardView = ({
},
]}
onPress={() => {
navigation.navigate(ScreenName.NftViewer, {
nft,
collection,
navigation.navigate(NavigatorName.NftNavigator, {
screen: ScreenName.NftViewer,
params: {
nft,
},
});
}}
>
Expand Down Expand Up @@ -92,17 +92,15 @@ const NftCardView = ({
const NftCardMemo = memo(NftCardView);
// this technique of splitting the usage of context and memoing the presentational component is used to prevent
// the rerender of all NftCards whenever the NFT cache changes (whenever a new NFT is loaded)
const NftCard = ({ nft, collection, style }: Props) => {
const { status, metadata } = useNftMetadata(collection.contract, nft.tokenId);
const NftCard = ({ nft, style }: Props) => {
const { status, metadata } = useNftMetadata(
nft.contract,
nft.tokenId,
nft.currencyId,
);

return (
<NftCardMemo
nft={nft}
collection={collection}
style={style}
status={status}
metadata={metadata}
/>
<NftCardMemo nft={nft} style={style} status={status} metadata={metadata} />
);
};

Expand Down
87 changes: 0 additions & 87 deletions src/components/Nft/NftCollectionRow.js

This file was deleted.

23 changes: 12 additions & 11 deletions src/components/Nft/NftCollectionRow.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import React from "react";
import React, { memo } from "react";
import { StyleSheet } from "react-native";
import { RectButton } from "react-native-gesture-handler";
import {
useNftMetadata,
CollectionWithNFT,
} from "@ledgerhq/live-common/lib/nft";
import { useNftMetadata, ProtoNFT } from "@ledgerhq/live-common/lib/nft";
import { Flex, Text } from "@ledgerhq/native-ui";
import { useTheme } from "styled-components/native";
import Skeleton from "../Skeleton";
import NftImage from "./NftImage";

type Props = {
collection: CollectionWithNFT;
collection: ProtoNFT[];
onCollectionPress: () => void;
};

function NftCollectionRow({ collection, onCollectionPress }: Props) {
const { colors } = useTheme();
const { contract, nfts } = collection;
const { status, metadata } = useNftMetadata(contract, nfts[0].tokenId);
const nft = collection[0];
const { status, metadata } = useNftMetadata(
nft?.contract,
nft?.tokenId,
nft?.currencyId,
);
const loading = status === "loading";

return (
Expand All @@ -41,7 +42,7 @@ function NftCollectionRow({ collection, onCollectionPress }: Props) {
ellipsizeMode="tail"
numberOfLines={2}
>
{metadata?.tokenName || collection.contract}
{metadata?.tokenName || nft.contract}
</Text>
</Skeleton>
</Flex>
Expand All @@ -51,14 +52,14 @@ function NftCollectionRow({ collection, onCollectionPress }: Props) {
color={"neutral.c70"}
ml={5}
>
{collection.nfts.length}
{collection.length}
</Text>
</Flex>
</RectButton>
);
}

export default NftCollectionRow;
export default memo(NftCollectionRow);

const styles = StyleSheet.create({
container: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
// @flow

import React, { useState } from "react";

import FastImage from "react-native-fast-image";
import { Image, View, StyleSheet, Animated } from "react-native";
import FastImage, {
OnLoadEvent,
FastImageProps,
} from "react-native-fast-image";
import { View, StyleSheet, Animated } from "react-native";
import ImageNotFoundIcon from "../../icons/ImageNotFound";
import { withTheme } from "../../colors";
import Skeleton from "../Skeleton";

const ImageComponent = ({
style,
source,
resizeMode,
onLoadEnd,
onLoad,
...props
}: {
style: Object,
source: { [string]: string },
resizeMode: string,
onLoadEnd: () => *,
onLoad: () => *,
}) => (
<FastImage
style={style}
resizeMode={FastImage.resizeMode[resizeMode]}
source={source}
onLoad={onLoad}
onLoadEnd={onLoadEnd}
/>
);
style: Object;
} & FastImageProps) =>
typeof props?.source === "object" && props?.source?.uri ? (
<FastImage {...props} />
) : (
<></>
);

const NotFound = ({
colors,
onLayout,
}: {
colors: Object,
onLayout: () => *,
colors: Object;
onLayout: () => void;
}) => {
const [iconWidth, setIconWidth] = useState(40);

Expand All @@ -58,20 +47,22 @@ const NotFound = ({
};

type Props = {
style?: Object,
status: string,
src: string,
resizeMode?: string,
colors: any,
style?: Object;
status: string;
src: string;
resizeMode?: string;
colors: any;
};

type State = {
loadError: boolean,
loadError: boolean;
};

class NftImage extends React.PureComponent<Props, State> {
state = {
beforeLoadDone: false,
loadError: false,
contentType: null,
};

opacityAnim = new Animated.Value(0);
Expand All @@ -84,10 +75,24 @@ class NftImage extends React.PureComponent<Props, State> {
}).start();
};

onLoad = ({ nativeEvent }: OnLoadEvent) => {
if (!nativeEvent) {
this.setState({ loadError: true });
}
};

onError = () => {
this.setState({ loadError: true });
};

render() {
const { style, status, src, colors, resizeMode = "cover" } = this.props;
const { loadError } = this.state;

const noData = status === "nodata";
const metadataError = status === "error";
const noSource = status === "loaded" && !src;

return (
<View style={[style, styles.root]}>
<Skeleton style={styles.skeleton} loading={true} />
Expand All @@ -99,10 +104,7 @@ class NftImage extends React.PureComponent<Props, State> {
},
]}
>
{status === "nodata" ||
status === "error" ||
(status === "loaded" && !src) ||
loadError ? (
{noData || metadataError || noSource || loadError ? (
<NotFound colors={colors} onLayout={this.startAnimation} />
) : (
<ImageComponent
Expand All @@ -116,13 +118,9 @@ class NftImage extends React.PureComponent<Props, State> {
source={{
uri: src,
}}
onLoad={({ nativeEvent }: Image.ImageLoadEvent) => {
if (!nativeEvent) {
this.setState({ loadError: true });
}
}}
onLoad={this.onLoad}
onLoadEnd={this.startAnimation}
onError={() => this.setState({ loadError: true })}
onError={this.onError}
/>
)}
</Animated.View>
Expand Down
Loading