import React from 'react';
import { View, Text, Pressable } from 'react-native';
import { Image } from 'expo-image';
import Svg, { Path } from 'react-native-svg';
import type { NFTListing as NFTListingType, ComponentSize } from '../types/algorand';
import { formatCurrency, formatRelativeTime } from '../utils/format';
import { SizeContainer } from '../ui/SizeContainer';
import { StatusBadge } from '../ui/StatusBadge';
function ShieldIcon({ size = 12, color = '#93c5fd' }: { size?: number; color?: string }) {
return (
);
}
function LockIcon({ size = 12, color = '#fdba74' }: { size?: number; color?: string }) {
return (
);
}
function ShoppingCartIcon({ size = 16, color = '#fff' }: { size?: number; color?: string }) {
return (
);
}
function CalendarIcon({ size = 12, color = '#71717a' }: { size?: number; color?: string }) {
return (
);
}
interface NFTListingProps {
data: NFTListingType;
showPurchaseButton?: boolean;
size?: ComponentSize;
className?: string;
imageUrl?: string;
onPurchase?: (listing: NFTListingType) => void;
onFavorite?: (listing: NFTListingType) => void;
}
export function NFTListingComponent({
data: listing,
showPurchaseButton = true,
size = 'full',
className,
imageUrl,
onPurchase,
onFavorite,
}: NFTListingProps) {
const isReserved = !!listing.reservedFor;
const hasGating = listing.gating !== undefined;
const isExpired = listing.expiresAt ? new Date() > listing.expiresAt : false;
const isFullscreen = size === 'fullscreen';
return (
{/* NFT Image */}
{imageUrl && (
{/* Badges overlay */}
{listing.authenticityBadge && (
} />
)}
{isReserved && (
} />
)}
{hasGating && }
{isExpired && }
)}
{/* NFT Info */}
{listing.nft.name}
#{listing.nft.id}
{listing.collection && (
{listing.collection}
)}
{/* Price & Stats */}
{formatCurrency(listing.price, listing.currency)}
Price
{listing.views.toLocaleString()}
Views
{listing.favorites.toLocaleString()}
Favorites
{/* Gating Info */}
{hasGating && listing.gating && (
Gated Access
{listing.gating.type === 'token' &&
`Requires ${listing.gating.requirement} ${listing.gating.asset} tokens`}
{listing.gating.type === 'nft' &&
`Requires NFT from ${listing.gating.collection}`}
)}
{/* Purchase Button */}
{showPurchaseButton && !isExpired && (
!isReserved && onPurchase?.(listing)}
disabled={isReserved}
className={`flex-row items-center justify-center gap-2 py-3 px-4 rounded-xl ${
isReserved
? 'bg-zinc-800/50'
: 'bg-purple-600'
}`}
>
{isReserved ? (
<>
Reserved
>
) : (
<>
Purchase NFT
>
)}
)}
{/* Listed Date */}
Listed {formatRelativeTime(listing.listedAt)}
);
}