diff --git a/apps/mobile/src/screens/NftDetailScreen/NftDetailScreenInner.tsx b/apps/mobile/src/screens/NftDetailScreen/NftDetailScreenInner.tsx index 0520a448c6..27dd0a9667 100644 --- a/apps/mobile/src/screens/NftDetailScreen/NftDetailScreenInner.tsx +++ b/apps/mobile/src/screens/NftDetailScreen/NftDetailScreenInner.tsx @@ -1,43 +1,13 @@ -import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; -import { useColorScheme } from 'nativewind'; +import { RouteProp, useRoute } from '@react-navigation/native'; import { useCallback } from 'react'; -import { ScrollView, StyleSheet, View } from 'react-native'; -import FastImage from 'react-native-fast-image'; import { useLazyLoadQuery } from 'react-relay'; import { graphql } from 'relay-runtime'; -import { BackButton } from '~/components/BackButton'; -import { TokenFailureBoundary } from '~/components/Boundaries/TokenFailureBoundary/TokenFailureBoundary'; -import { Button } from '~/components/Button'; -import { GalleryTouchableOpacity } from '~/components/GalleryTouchableOpacity'; -import { Pill } from '~/components/Pill'; -import { ProfilePicture } from '~/components/ProfilePicture/ProfilePicture'; import { NftDetailScreenInnerQuery } from '~/generated/NftDetailScreenInnerQuery.graphql'; -import { PostIcon } from '~/navigation/MainTabNavigator/PostIcon'; -import { MainTabStackNavigatorParamList, MainTabStackNavigatorProp } from '~/navigation/types'; -import { NftDetailAssetCacheSwapper } from '~/screens/NftDetailScreen/NftDetailAsset/NftDetailAssetCacheSwapper'; -import TokenViewEmitter from '~/shared/components/TokenViewEmitter'; -import { useTrack } from '~/shared/contexts/AnalyticsContext'; -import { useLoggedInUserId } from '~/shared/relay/useLoggedInUserId'; -import colors from '~/shared/theme/colors'; +import { MainTabStackNavigatorParamList } from '~/navigation/types'; -import { IconContainer } from '../../components/IconContainer'; -import { InteractiveLink } from '../../components/InteractiveLink'; -import { Markdown } from '../../components/Markdown'; -import { Typography } from '../../components/Typography'; -import { PoapIcon } from '../../icons/PoapIcon'; -import { ShareIcon } from '../../icons/ShareIcon'; import { shareToken } from '../../utils/shareToken'; -import { NftAdditionalDetails } from './NftAdditionalDetails'; -import { NftDetailAsset } from './NftDetailAsset/NftDetailAsset'; - -const markdownStyles = StyleSheet.create({ - body: { - fontSize: 14, - }, -}); - -const ENABLED_CREATOR = false; +import { NftDetailSection } from './NftDetailSection'; export function NftDetailScreenInner() { const route = useRoute>(); @@ -56,36 +26,11 @@ export function NftDetailScreenInner() { tokenById(id: $tokenId) { ... on Token { __typename - dbid - name - chain - tokenId - description - - contract { - name - badgeURL - contractAddress { - address - chain - } - } - ownerIsCreator - owner { - id - username - ...ProfilePictureFragment - } - - ...NftAdditionalDetailsFragment - ...NftDetailAssetFragment + ...shareTokenFragment } - - ...shareTokenFragment - ...TokenFailureBoundaryFragment } - ...useLoggedInUserIdFragment + ...NftDetailSectionQueryFragment } `, { @@ -107,199 +52,15 @@ export function NftDetailScreenInner() { // { tokenId: '2O1TnqK7sbhbdlAeQwLFkxo8T9i' } ); - const { colorScheme } = useColorScheme(); - const token = query.tokenById; - const loggedInUserId = useLoggedInUserId(query); - if (token?.__typename !== 'Token') { throw new Error("We couldn't find that token. Something went wrong and we're looking into it."); } - const isTokenOwner = loggedInUserId === token.owner?.id; - - const track = useTrack(); - - const navigation = useNavigation(); - const handleShare = useCallback(() => { shareToken(token, query.collectionTokenById?.collection ?? null); }, [query.collectionTokenById, token]); - const handleOpenCommunityScreen = useCallback(() => { - const contractAddress = token.contract?.contractAddress; - const { address, chain } = contractAddress ?? {}; - if (!address || !chain) return; - navigation.push('Community', { - contractAddress: address, - chain, - }); - }, [navigation, token.contract?.contractAddress]); - - const handleUsernamePress = useCallback(() => { - if (token.owner?.username) { - track('NFT Detail Collector Name Clicked', { - username: token.owner.username, - contractAddress: token.contract?.contractAddress?.address, - tokenId: token.tokenId, - }); - navigation.push('Profile', { username: token.owner.username }); - } - }, [ - navigation, - track, - token.owner?.username, - token.contract?.contractAddress?.address, - token.tokenId, - ]); - - const handleCreatePost = useCallback(() => { - if (!token.dbid) return; - - navigation.navigate('PostComposer', { - tokenId: token.dbid, - }); - }, [navigation, token.dbid]); - - // const handleCreatorPress = useCallback(() => { - // if (token.creator?.username) { - // track('NFT Detail Creator Name Clicked', { - // username: token.creator.username, - // contractAddress: token.contract?.contractAddress?.address, - // tokenId: token.tokenId, - // }); - // navigation.push('Profile', { username: token.creator.username }); - // } - // }, [navigation, track, token.creator?.username]); - - return ( - - - - - - - } - onPress={handleShare} - /> - - - - - - - - - - - - - - {token.name} - - - {token.contract?.name ? ( - - - {token.chain === 'POAP' && } - {token.contract?.badgeURL && ( - - )} - - - {token.contract.name} - - - - - ) : null} - - - - {token.owner && ( - - - {token.ownerIsCreator ? 'CREATOR' : 'OWNER'} - - - - {token.owner.username && } - - - {token.owner.username} - - - - )} - {ENABLED_CREATOR && ( - - - CREATOR - - - - riley.eth - - - riley.eth - - - )} - - - {token.description && ( - - {token.description} - - )} - - {isTokenOwner && ( -