import React from 'react'; import {LayoutChangeEvent, Linking, StyleSheet, Text, View} from 'react-native'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {launchCamera} from 'react-native-image-picker'; import {useDispatch, useSelector, useStore} from 'react-redux'; import {TAGG_DARK_BLUE, TOGGLE_BUTTON_TYPE} from '../../constants'; import { acceptFriendRequest, declineFriendRequest, updateUserXFriends, updateUserXProfileAllScreens, } from '../../store/actions'; import {NO_PROFILE} from '../../store/initialStates'; import {RootState} from '../../store/rootReducer'; import {ScreenType} from '../../types'; import { getUserAsProfilePreviewType, normalize, SCREEN_HEIGHT, SCREEN_WIDTH, } from '../../utils'; import {canViewProfile} from '../../utils/users'; import {FriendsButton} from '../common'; import {MessageButton} from '../messages'; import ProfileBadges from './ProfileBadges'; import ToggleButton from './ToggleButton'; interface ProfileBodyProps { onLayout: (event: LayoutChangeEvent) => void; isBlocked: boolean; handleBlockUnblock: () => void; userXId: string | undefined; screenType: ScreenType; } const ProfileBody: React.FC = ({ onLayout, isBlocked, handleBlockUnblock, userXId, screenType, }) => { const dispatch = useDispatch(); const {profile = NO_PROFILE, user} = useSelector((state: RootState) => userXId ? state.userX[screenType][userXId] : state.user, ); const {biography, website, friendship_status, friendship_requester_id} = profile; const {id, username, first_name, last_name} = getUserAsProfilePreviewType( user, profile, ); const state: RootState = useStore().getState(); const handleAcceptRequest = async () => { await dispatch(acceptFriendRequest({id, username, first_name, last_name})); await dispatch(updateUserXFriends(id, state)); dispatch(updateUserXProfileAllScreens(id, state)); }; const handleDeclineFriendRequest = async () => { await dispatch(declineFriendRequest(id)); dispatch(updateUserXProfileAllScreens(id, state)); }; return ( {`@${username}`} {biography.length > 0 && ( {`${biography}`} )} {website.length > 0 && ( { Linking.openURL( website.startsWith('http') ? website : 'http://' + website, ); }}>{`${website}`} )} { launchCamera( { mediaType: 'video', durationLimit: 60, videoQuality: 'medium', }, (response) => { console.log(response); const file = response.assets[0].uri; console.log(file); }, ); }}> foooo {userXId && isBlocked && ( )} {userXId && !isBlocked && ( {canViewProfile(state, userXId, screenType) && ( )} )} ); }; const styles = StyleSheet.create({ toggleButtonContainer: { flexDirection: 'row', flex: 1, paddingTop: '3.5%', paddingBottom: '2%', }, simpleRowContainer: {flexDirection: 'row'}, buttonsContainer: { flex: 1, paddingTop: '3.5%', paddingBottom: '2%', width: '50%', height: SCREEN_HEIGHT * 0.1, flexDirection: 'row', justifyContent: 'space-between', }, container: { paddingHorizontal: 18, backgroundColor: 'white', }, username: { fontWeight: '600', fontSize: normalize(13.5), marginBottom: '1%', }, biography: { fontSize: normalize(13.5), marginBottom: '1.5%', }, website: { fontSize: normalize(13.5), color: TAGG_DARK_BLUE, marginBottom: '1%', }, }); export default ProfileBody;