import {useIsFocused, useNavigation} from '@react-navigation/native'; import React, {useContext, useEffect, useMemo, useRef, useState} from 'react'; import { Image, Keyboard, KeyboardAvoidingView, Platform, StatusBar, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View, } from 'react-native'; // @ts-ignore import Pinchable from 'react-native-pinchable'; import Animated, { Easing, EasingNode, useSharedValue, withTiming, } from 'react-native-reanimated'; import {SafeAreaView} from 'react-native-safe-area-context'; import Video from 'react-native-video'; import {useDispatch, useSelector, useStore} from 'react-redux'; import {TaggedUsersDrawer} from '.'; import PauseIcon from '../../assets/icons/pause-icon.svg'; import {headerBarOptions, multilineHeaderTitle} from '../../routes'; import {MomentContext} from '../../screens/profile/IndividualMoment'; import {deleteMomentTag, loadMomentTags} from '../../services'; import {loadUserMoments} from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {MomentPostType, MomentTagType, ScreenType, UserType} from '../../types'; import { getTimePosted, navigateToProfile, normalize, SCREEN_HEIGHT, SCREEN_WIDTH, } from '../../utils'; import {mentionPartTypes, renderTextWithMentions} from '../../utils/comments'; import CommentsCount from '../comments/CommentsCount'; import {GradientProgressBar, MomentTags} from '../common'; import {MomentMoreInfoDrawer, TaggAvatar} from '../profile'; interface MomentPostProps { moment: MomentPostType; userXId: string | undefined; screenType: ScreenType; updateMomentViewCount: () => void; } const MomentPost: React.FC = ({ moment, userXId, screenType, updateMomentViewCount, }) => { const navigation = useNavigation(); const dispatch = useDispatch(); const {userId: loggedInUserId, username: loggedInUsername} = useSelector( (state: RootState) => state.user.user, ); const {user} = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, ); const state: RootState = useStore().getState(); const isOwnProfile = user.username === loggedInUsername; const [tags, setTags] = useState([]); const [tagsVisible, setTagsVisible] = useState(false); const [drawerVisible, setDrawerVisible] = useState(false); const [taggedUsersVisible, setTaggedUsersVisible] = useState(false); const [hideText, setHideText] = useState(false); const [fadeValue, setFadeValue] = useState>( new Animated.Value(0), ); const [aspectRatio, setAspectRatio] = useState(1); const [momentTagId, setMomentTagId] = useState(''); const imageRef = useRef(null); const videoRef = useRef