From a13dcb5110245bb554d79e779c4942e6f5aaf18a Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 27 Apr 2021 10:46:17 -0400 Subject: refactored avatar --- src/components/profile/Avatar.tsx | 36 ------------------------------- src/components/profile/ProfileHeader.tsx | 4 ++-- src/components/profile/ProfilePreview.tsx | 12 +++-------- src/components/profile/TaggAvatar.tsx | 35 ++++++++++++++++++++++++++++++ src/components/profile/index.ts | 1 + 5 files changed, 41 insertions(+), 47 deletions(-) delete mode 100644 src/components/profile/Avatar.tsx create mode 100644 src/components/profile/TaggAvatar.tsx (limited to 'src/components/profile') diff --git a/src/components/profile/Avatar.tsx b/src/components/profile/Avatar.tsx deleted file mode 100644 index e57a56a3..00000000 --- a/src/components/profile/Avatar.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react'; -import {Image, StyleSheet} from 'react-native'; -import {useSelector} from 'react-redux'; -import {RootState} from '../../store/rootreducer'; -import {ScreenType} from '../../types'; - -const PROFILE_DIM = 100; - -interface AvatarProps { - style?: object; - userXId: string | undefined; - screenType: ScreenType; -} -const Avatar: React.FC = ({style, screenType, userXId}) => { - const {avatar} = useSelector((state: RootState) => - userXId ? state.userX[screenType][userXId] : state.user, - ); - - return ( - - ); -}; - -const styles = StyleSheet.create({ - image: { - height: PROFILE_DIM, - width: PROFILE_DIM, - borderRadius: PROFILE_DIM / 2, - }, -}); - -export default Avatar; diff --git a/src/components/profile/ProfileHeader.tsx b/src/components/profile/ProfileHeader.tsx index 35ec0ea9..db56b216 100644 --- a/src/components/profile/ProfileHeader.tsx +++ b/src/components/profile/ProfileHeader.tsx @@ -8,7 +8,7 @@ import {RootState} from '../../store/rootreducer'; import {ScreenType} from '../../types'; import {hasSeenBadgeTutorial, normalize} from '../../utils'; import BadgeDetailView from '../common/BadgeDetailView'; -import Avatar from './Avatar'; +import TaggAvatar from './TaggAvatar'; import BadgeTutorial from './BadgeTutorial'; import FriendsCount from './FriendsCount'; import ProfileMoreInfoDrawer from './ProfileMoreInfoDrawer'; @@ -107,7 +107,7 @@ const ProfileHeader: React.FC = ({ /> )} - = ({ }) => { const navigation = useNavigation(); const {user: loggedInUser} = useSelector((state: RootState) => state.user); - const [avatar, setAvatar] = useState(null); + const [avatar, setAvatar] = useState(); const dispatch = useDispatch(); useEffect(() => { @@ -187,14 +188,7 @@ const ProfilePreview: React.FC = ({ - + {(previewType === 'Search' || previewType === 'Recent') && ( <> diff --git a/src/components/profile/TaggAvatar.tsx b/src/components/profile/TaggAvatar.tsx new file mode 100644 index 00000000..ea0bdb65 --- /dev/null +++ b/src/components/profile/TaggAvatar.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import {StyleSheet} from 'react-native'; +import {useSelector} from 'react-redux'; +import {RootState} from '../../store/rootreducer'; +import {ScreenType} from '../../types'; +import {Avatar} from '../common'; + +const PROFILE_DIM = 100; + +interface TaggAvatarProps { + style?: object; + userXId: string | undefined; + screenType: ScreenType; +} +const TaggAvatar: React.FC = ({ + style, + screenType, + userXId, +}) => { + const {avatar} = useSelector((state: RootState) => + userXId ? state.userX[screenType][userXId] : state.user, + ); + + return ; +}; + +const styles = StyleSheet.create({ + image: { + height: PROFILE_DIM, + width: PROFILE_DIM, + borderRadius: PROFILE_DIM / 2, + }, +}); + +export default TaggAvatar; diff --git a/src/components/profile/index.ts b/src/components/profile/index.ts index 260f4217..c544c3f2 100644 --- a/src/components/profile/index.ts +++ b/src/components/profile/index.ts @@ -8,3 +8,4 @@ export {default as Friends} from './Friends'; export {default as ProfileMoreInfoDrawer} from './ProfileMoreInfoDrawer'; export {default as MomentMoreInfoDrawer} from './MomentMoreInfoDrawer'; export {default as UniversityIcon} from './UniversityIcon'; +export {default as TaggAvatar} from './TaggAvatar'; -- cgit v1.2.3-70-g09d2 From 64dedc2bc0c65fae604ba771ae4c17d1927ff1c2 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 27 Apr 2021 11:06:41 -0400 Subject: linted --- src/components/profile/ProfilePreview.tsx | 1 - src/components/search/ExploreSectionUser.tsx | 4 ++-- src/components/taggs/TwitterTaggPost.tsx | 5 ++++- src/screens/onboarding/OnboardingStepThree.tsx | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/components/profile') diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx index 242a17e3..66d68d8f 100644 --- a/src/components/profile/ProfilePreview.tsx +++ b/src/components/profile/ProfilePreview.tsx @@ -2,7 +2,6 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; import { Alert, - Image, StyleSheet, Text, TouchableOpacity, diff --git a/src/components/search/ExploreSectionUser.tsx b/src/components/search/ExploreSectionUser.tsx index c1355e17..c949acd4 100644 --- a/src/components/search/ExploreSectionUser.tsx +++ b/src/components/search/ExploreSectionUser.tsx @@ -1,13 +1,13 @@ import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useState} from 'react'; -import {TextStyle, ViewStyle} from 'react-native'; import { - Image, StyleProp, StyleSheet, Text, + TextStyle, TouchableOpacity, ViewProps, + ViewStyle, } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import {useDispatch, useSelector, useStore} from 'react-redux'; diff --git a/src/components/taggs/TwitterTaggPost.tsx b/src/components/taggs/TwitterTaggPost.tsx index a64fea20..db07ba66 100644 --- a/src/components/taggs/TwitterTaggPost.tsx +++ b/src/components/taggs/TwitterTaggPost.tsx @@ -77,7 +77,10 @@ const TwitterTaggPost: React.FC = ({ {post.in_reply_to.text !== 'This tweet is unavailable' && ( <> - + diff --git a/src/screens/onboarding/OnboardingStepThree.tsx b/src/screens/onboarding/OnboardingStepThree.tsx index 3f88e77d..34173b39 100644 --- a/src/screens/onboarding/OnboardingStepThree.tsx +++ b/src/screens/onboarding/OnboardingStepThree.tsx @@ -27,7 +27,6 @@ import { ERROR_SELECT_CLASS_YEAR, ERROR_SELECT_GENDER, ERROR_SELECT_UNIVERSITY, - ERROR_UPLOAD_SMALL_PROFILE_PIC, } from '../../constants/strings'; import {OnboardingStackParams} from '../../routes/onboarding'; import {patchEditProfile} from '../../services'; -- cgit v1.2.3-70-g09d2