import React, {useState} from 'react'; import {StyleSheet, Text, View} from 'react-native'; import {useSelector} from 'react-redux'; import {UniversityIcon} from '.'; import {NO_MOMENTS} from '../../store/initialStates'; import {RootState} from '../../store/rootreducer'; import {ScreenType} from '../../types'; import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; import Avatar from './Avatar'; import FriendsCount from './FriendsCount'; import ProfileMoreInfoDrawer from './ProfileMoreInfoDrawer'; type ProfileHeaderProps = { userXId: string | undefined; screenType: ScreenType; isBlocked: boolean; handleBlockUnblock: () => void; }; const ProfileHeader: React.FC = ({ userXId, screenType, isBlocked, handleBlockUnblock, }) => { const { profile: {name = '', university_class = 2021} = {}, user: {username: userXName = ''}, } = userXId ? useSelector((state: RootState) => state.userX[screenType][userXId]) : useSelector((state: RootState) => state.user); const [drawerVisible, setDrawerVisible] = useState(false); const [firstName, lastName] = [...name.split(' ')]; return ( {name.length <= 16 ? ( {name} ) : ( {firstName} {lastName} )} ); }; const styles = StyleSheet.create({ container: { top: SCREEN_HEIGHT / 2.4, width: '100%', position: 'absolute', }, row: { flexDirection: 'row', }, header: { flexDirection: 'column', justifyContent: 'center', alignItems: 'center', marginTop: SCREEN_WIDTH / 18.2, marginLeft: SCREEN_WIDTH / 8, marginBottom: SCREEN_WIDTH / 50, }, avatar: { bottom: SCREEN_WIDTH / 80, left: '10%', }, name: { marginLeft: SCREEN_WIDTH / 8, fontSize: 17, fontWeight: '500', alignSelf: 'center', }, friends: { alignSelf: 'flex-start', marginRight: SCREEN_WIDTH / 20, }, university: { alignSelf: 'flex-end', bottom: 3, }, friendsAndUniversity: { flexDirection: 'row', flex: 1, marginLeft: SCREEN_WIDTH / 10, marginTop: SCREEN_WIDTH / 40, }, }); export default ProfileHeader;