aboutsummaryrefslogtreecommitdiff
path: root/src/routes/profile
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/profile')
-rw-r--r--src/routes/profile/Profile.tsx38
-rw-r--r--src/routes/profile/ProfileStack.tsx36
2 files changed, 45 insertions, 29 deletions
diff --git a/src/routes/profile/Profile.tsx b/src/routes/profile/Profile.tsx
index b6672c85..f47d25c4 100644
--- a/src/routes/profile/Profile.tsx
+++ b/src/routes/profile/Profile.tsx
@@ -11,17 +11,17 @@ import {
} from '../../screens';
import {ProfileStack, ProfileStackParams} from './ProfileStack';
import {RouteProp} from '@react-navigation/native';
+import {ScreenType} from '../../types';
/**
- * What will be the First Screen of the stack depends on value of isProfileView (Search if its true else Profile)
* Trying to explain the purpose of each route on the stack (ACTUALLY A STACK)
- * Profile : To display the logged in user's profile when isProfileView is false, else displays profile of any user the logged in user wants to view.
- * When you click on the profile icon after looking at a user's profile, the stack is reset and you come back to the top of the stack (First screen : Profile in this case)
- * Search : To display the search screen. Search for a user on this screen, click on a result tile and navigate to the same (isProfileView = true).
+ * Profile : To display the logged in user's profile when the userXId passed in to it is (undefined | null | empty string) else displays profile of the user being visited.
+ * Search : To display the search screen. Search for a user on this screen, click on a result tile and navigate to the same.
* When you click on the search icon after looking at a user's profile, the stack gets reset and you come back to the top of the stack (First screen : Search in this case)
* SocialMediaTaggs : To display user data for any social media account set up by the user.
* IndividualMoment : To display individual images uploaded by the user (Navigate to comments from this screen, click on a commenter's profile pic / username, look at a user's profile. Click on the profile icon again to come back to your own profile).
* MomentCommentsScreen : Displays comments posted by users on an image uploaded by the user.
+ * EditProfile : To edit logged in user's information.
*/
type ProfileStackRouteProps = RouteProp<ProfileStackParams, 'Profile'>;
@@ -31,7 +31,12 @@ interface ProfileStackProps {
}
const Profile: React.FC<ProfileStackProps> = ({route}) => {
- const {isProfileView} = route.params;
+ const {screenType} = route.params;
+
+ /**
+ * This parameter isProfileStack acts as a switch between Search and Profile Stacks
+ */
+ const isProfileStack = screenType === ScreenType.Profile;
return (
<ProfileStack.Navigator
screenOptions={{
@@ -56,15 +61,21 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
}),
}}
mode="modal"
- initialRouteName={!isProfileView ? 'Profile' : 'Search'}>
+ initialRouteName={isProfileStack ? 'Profile' : 'Search'}>
<ProfileStack.Screen
name="Profile"
component={ProfileScreen}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{
+ screenType,
+ }}
/>
- {isProfileView ? (
- <ProfileStack.Screen name="Search" component={SearchScreen} />
+ {!isProfileStack ? (
+ <ProfileStack.Screen
+ name="Search"
+ component={SearchScreen}
+ initialParams={{screenType}}
+ />
) : (
<React.Fragment />
)}
@@ -77,8 +88,9 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
headerBackTitleVisible: false,
headerTintColor: 'white',
}}
+ initialParams={{screenType}}
/>
- {!isProfileView ? (
+ {isProfileStack ? (
<ProfileStack.Screen name="CaptionScreen" component={CaptionScreen} />
) : (
<React.Fragment />
@@ -87,18 +99,18 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
name="IndividualMoment"
component={IndividualMoment}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="MomentCommentsScreen"
component={MomentCommentsScreen}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="FollowersListScreen"
component={FollowersListScreen}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="EditProfile"
diff --git a/src/routes/profile/ProfileStack.tsx b/src/routes/profile/ProfileStack.tsx
index 5590f78a..e7db9f37 100644
--- a/src/routes/profile/ProfileStack.tsx
+++ b/src/routes/profile/ProfileStack.tsx
@@ -1,41 +1,45 @@
+/**
+ * Note the name userXId here, it refers to the id of the user being visited
+ */
import {createStackNavigator} from '@react-navigation/stack';
-import {MomentType, ProfilePreviewType, SocialAccountType} from '../../types';
+import {MomentType, ScreenType} from '../../types';
export type ProfileStackParams = {
- Search: undefined;
+ Search: {
+ screenType: ScreenType;
+ };
Profile: {
- isProfileView: boolean;
- username: string;
- userId: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
SocialMediaTaggs: {
socialMediaType: string;
- socialMediaHandle: string;
- isProfileView: boolean;
- name: string;
- accountData: SocialAccountType;
- avatar: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
CaptionScreen: {
title: string;
image: object;
+ screenType: ScreenType;
};
IndividualMoment: {
moment: MomentType;
- isProfileView: boolean;
- username: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
MomentCommentsScreen: {
- isProfileView: boolean;
moment_id: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
FollowersListScreen: {
isFollowers: boolean;
- list: ProfilePreviewType[];
+ userXId: string | undefined;
+ screenType: ScreenType;
};
EditProfile: {
- userId: boolean;
- username: ProfilePreviewType[];
+ userId: string;
+ username: string;
};
};