import { AssetLevelEnum, MintStatus, SellingMethodEnum } from '@bit-ui-libs/common'; import ContentLoader, { Rect } from 'react-content-loader/native'; import { StyleProp, TouchableOpacity, View, ViewStyle } from 'react-native'; import FastImage from 'react-native-fast-image'; import { Swipeable } from 'react-native-gesture-handler'; import { Icon, Text } from '../../../components'; import { tw } from '../../../core/tailwind'; import { useTheme, useThemeMode } from '../../../core/theme'; import { TokenSwipeActionEnum } from '../enums'; import { useGetTokenDetails } from '../hooks'; import { MintedChip } from './MintedChip'; import { TokenCardSwipeActions } from './TokenCardSwipeActions'; import { TokenDateText } from './TokenDateText'; import { TokenLevel } from './TokenLevel'; import { VerifiedChip } from './VerifiedChip'; // type EventOrAssetIdProp = // // If parent component passes EVENT ID, then no need ASSET ID // | { eventId: string; assetId?: never } // // If parent component passes ASSET ID, then no need EVENT ID // | { assetId: string; eventId?: never }; type TokenCardProps = // EventOrAssetIdProp & { eventId: string; // Style-related props flat?: boolean; hideTitle?: boolean; hideDate?: boolean; hideStatus?: boolean; flexRowReverse?: boolean; showAssetLevel?: boolean; swipeActions?: TokenSwipeActionEnum[]; // This is needed to workaround BITDEV-1389 (caused by backend logical bug on steps) isMinted?: boolean; sellingMethod?: SellingMethodEnum; // Event handlers onPress?: () => void; onSwipeAction?: (action: TokenSwipeActionEnum) => void; onGradePress?: (level: AssetLevelEnum, hardwareLevel?: number) => void; }; export function TokenCard(props: TokenCardProps) { const { data, isLoading } = useGetTokenDetails({ eventId: props.eventId, queryKey: ['token-details', props.eventId], separator: ' | ', }); const containerStyle = [ tw.style(`my-2 rounded-lg items-center`, { 'flex-row': !props.flexRowReverse, 'flex-row-reverse': props.flexRowReverse, // The styles below will be hidden if FLAT is passed. // FLAT means this card is intended to be placed flat against a parent container, // instead of using our own custom container. 'bg-[#2A2627] dark:bg-[#808080]': !props.flat, 'p-2': !props.flat, borderWidth: !props.flat ? 1 : undefined, borderColor: !props.flat ? '#565656' : undefined, }), ]; if (isLoading) return ; const component = ( {data?.mainAttachmentUrl ? ( ) : ( )} {/* Token Information */} {data?.name} {data?.categories} {props.showAssetLevel && data?.device ? ( { props.onGradePress?.(data.level, data.device.hardwareLevel); }} /> ) : null} {/* Token Date */} {/* Token Statuses */} ); if (props.swipeActions && props.swipeActions.length > 0) { return ( ( )}> {component} ); } return component; } interface TokenCardContentLoaderProps { style: StyleProp; } function TokenCardContentLoader({ style }: TokenCardContentLoaderProps) { const { background } = useTheme(); const { currentTheme } = useThemeMode(); return ( ); }