From ab7fa09af967e0a8cf2ca53dfb24f8bc8a6886f7 Mon Sep 17 00:00:00 2001 From: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> Date: Sun, 18 Oct 2020 16:37:32 -0700 Subject: [TMA 279] Ability to search and view someone's profile (#58) * Batch one : major changes * WIP checkpoint * The one before the final touch * Probable final touch * ran yarn lint D: * linter broke something * fixed a small bug * Addressed a small nitpick * Well abstracted now Co-authored-by: Ivan Chen --- src/screens/profile/CaptionScreen.tsx | 10 +++++----- src/screens/profile/ProfileScreen.tsx | 20 ++++++++++++++------ src/screens/profile/SocialMediaTaggs.tsx | 12 ++++++++---- 3 files changed, 27 insertions(+), 15 deletions(-) (limited to 'src/screens/profile') diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index e3040509..53c47a6d 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -42,14 +42,14 @@ const CaptionScreen: React.FC = ({route, navigation}) => { setCaption(caption); }; - const checkImageUploadStatus = (statusMap : object) => { - for(let [key, value] of Object.entries(statusMap)){ - if (value != "Success"){ + const checkImageUploadStatus = (statusMap: object) => { + for (let [key, value] of Object.entries(statusMap)) { + if (value != 'Success') { return false; } } return true; - } + }; const handleShare = async () => { try { @@ -68,7 +68,7 @@ const CaptionScreen: React.FC = ({route, navigation}) => { }); request.append('moment', title); request.append('user_id', userId); - request.append('captions', JSON.stringify({'image':caption})); + request.append('captions', JSON.stringify({image: caption})); let response = await fetch(MOMENTS_UPLOAD_ENDPOINT, { method: 'POST', headers: { diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx index cc388ffd..7d11fa2a 100644 --- a/src/screens/profile/ProfileScreen.tsx +++ b/src/screens/profile/ProfileScreen.tsx @@ -2,20 +2,28 @@ import React from 'react'; import {StatusBar} from 'react-native'; import Animated from 'react-native-reanimated'; import {Content, Cover, TabsGradient} from '../../components'; -import {AuthContext} from '../../routes/authentication'; +import {RouteProp} from '@react-navigation/native'; +import {ProfileStackParams} from '../../routes/profile'; /** - * Profile Screen for a user's logged in profile + * Profile Screen for a user's profile * including posts, messaging, and settings */ -const ProfileScreen: React.FC = () => { - const {user} = React.useContext(AuthContext); + +type ProfileScreenRouteProps = RouteProp; + +interface ProfileOnboardingProps { + route: ProfileScreenRouteProps; +} + +const ProfileScreen: React.FC = ({route}) => { + const {isProfileView} = route.params; const y = Animated.useValue(0); return ( <> - - + + ); diff --git a/src/screens/profile/SocialMediaTaggs.tsx b/src/screens/profile/SocialMediaTaggs.tsx index 9e4f2aea..ddbebcea 100644 --- a/src/screens/profile/SocialMediaTaggs.tsx +++ b/src/screens/profile/SocialMediaTaggs.tsx @@ -4,7 +4,7 @@ import {ScrollView, StatusBar, StyleSheet, View} from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import {AVATAR_GRADIENT} from '../../constants'; import {SocialMediaInfo, TabsGradient, TaggsFeed} from '../../components'; -import {AuthContext, ProfileStackParams} from '../../routes'; +import {AuthContext, ProfileStackParams, ProfileContext} from '../../routes'; import {headerBarHeightWithImage, SCREEN_HEIGHT} from '../../utils'; type SocialMediaTaggsRouteProp = RouteProp< @@ -27,17 +27,21 @@ interface SocialMediaTaggsProps { * + date posted * + dark background */ -const SocialMediaTaggs: React.FC = () => { +const SocialMediaTaggs: React.FC = ({route}) => { + const {isProfileView} = route.params; + const context = isProfileView + ? React.useContext(ProfileContext) + : React.useContext(AuthContext); const { user, profile: {name}, - } = React.useContext(AuthContext); + } = context; // TODO: We should use the passed-in socialmedia type/handle instead. // Currently don't have an intuitive way of doing so, for now, // just grabbing from user's AuthContext. // const {socialMediaType, socialMediaHandle} = route.params; - const {instaPosts} = React.useContext(AuthContext); + const {instaPosts} = context; const socialMediaType = 'Instagram'; const socialMediaHandle = instaPosts[0].username; -- cgit v1.2.3-70-g09d2