import analytics from '@components/analytics' import Button from '@components/Button' import haptics from '@components/haptics' import AttachmentAudio from '@components/Timeline/Shared/Attachment/Audio' import AttachmentImage from '@components/Timeline/Shared/Attachment/Image' import AttachmentUnsupported from '@components/Timeline/Shared/Attachment/Unsupported' import AttachmentVideo from '@components/Timeline/Shared/Attachment/Video' import { useNavigation } from '@react-navigation/native' import { StyleConstants } from '@utils/styles/constants' import layoutAnimation from '@utils/styles/layoutAnimation' import React, { useCallback, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { Pressable, StyleSheet, View } from 'react-native' export interface Props { status: Pick } const TimelineAttachment = React.memo( ({ status }: Props) => { const { t } = useTranslation('componentTimeline') const [sensitiveShown, setSensitiveShown] = useState(status.sensitive) const onPressBlurView = useCallback(() => { analytics('timeline_shared_attachment_blurview_press_show') layoutAnimation() setSensitiveShown(false) haptics('Light') }, []) const onPressShow = useCallback(() => { analytics('timeline_shared_attachment_blurview_press_hide') setSensitiveShown(true) haptics('Light') }, []) let imageUrls: Nav.RootStackParamList['Screen-ImagesViewer']['imageUrls'] = [] const navigation = useNavigation() const navigateToImagesViewer = (id: string) => navigation.navigate('Screen-ImagesViewer', { imageUrls, id }) const attachments = useMemo( () => status.media_attachments.map((attachment, index) => { switch (attachment.type) { case 'image': imageUrls.push({ id: attachment.id, url: attachment.url, remote_url: attachment.remote_url, width: attachment.meta?.original?.width, height: attachment.meta?.original?.height }) return ( ) case 'video': return ( ) case 'gifv': return ( ) case 'audio': return ( ) default: return ( ) } }), [sensitiveShown] ) return ( {status.sensitive && (sensitiveShown ? (