From 88fb33d1fe1cd0785e4a92cb3c20d0fafb2da54d Mon Sep 17 00:00:00 2001 From: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> Date: Mon, 19 Oct 2020 17:14:37 -0700 Subject: Merged changes to make sure moments view and search work (#62) --- src/routes/profile/MomentStack.tsx | 11 ------- src/routes/profile/MomentStackScreen.tsx | 46 ------------------------------ src/routes/profile/Profile.tsx | 45 +++++++++++++++++++++++------ src/routes/profile/ProfileStack.tsx | 5 ++++ src/routes/profile/index.ts | 4 +-- src/routes/tabs/NavigationBar.tsx | 13 +++++---- src/routes/viewProfile/ProfileProvider.tsx | 10 ++++++- 7 files changed, 60 insertions(+), 74 deletions(-) delete mode 100644 src/routes/profile/MomentStack.tsx delete mode 100644 src/routes/profile/MomentStackScreen.tsx (limited to 'src/routes') diff --git a/src/routes/profile/MomentStack.tsx b/src/routes/profile/MomentStack.tsx deleted file mode 100644 index 83853c99..00000000 --- a/src/routes/profile/MomentStack.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import {createStackNavigator} from '@react-navigation/stack'; -import {MomentType} from '../../types'; - -export type MomentStackParams = { - Profile: undefined; - IndividualMoment: { - moment: MomentType; - }; -}; - -export const MomentStack = createStackNavigator(); diff --git a/src/routes/profile/MomentStackScreen.tsx b/src/routes/profile/MomentStackScreen.tsx deleted file mode 100644 index 8768199a..00000000 --- a/src/routes/profile/MomentStackScreen.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import {IndividualMoment} from '../../screens'; -import {MomentStack} from './MomentStack'; -import Profile from './Profile'; - -const MomentStackScreen: React.FC = () => { - return ( - ({ - cardStyle: { - opacity: progress.interpolate({ - inputRange: [0, 0.5, 0.9, 1], - outputRange: [0, 0.25, 0.7, 1], - }), - }, - overlayStyle: { - backgroundColor: '#808080', - opacity: progress.interpolate({ - inputRange: [0, 1], - outputRange: [0, 0.9], - extrapolate: 'clamp', - }), - }, - }), - }} - initialRouteName="Profile" - mode="modal"> - - - - ); -}; - -export default MomentStackScreen; diff --git a/src/routes/profile/Profile.tsx b/src/routes/profile/Profile.tsx index b39b726e..363e9e21 100644 --- a/src/routes/profile/Profile.tsx +++ b/src/routes/profile/Profile.tsx @@ -1,29 +1,52 @@ import React from 'react'; import { - ProfileScreen, + IndividualMoment, CaptionScreen, SocialMediaTaggs, SearchScreen, + ProfileScreen, } from '../../screens'; -import {RouteProp} from '@react-navigation/native'; import {ProfileStack, ProfileStackParams} from './ProfileStack'; +import {RouteProp} from '@react-navigation/native'; import {AvatarTitle} from '../../components'; -type ProfileScreenRouteProps = RouteProp; +type ProfileStackRouteProps = RouteProp; -interface ProfileScreenProps { - route: ProfileScreenRouteProps; +interface ProfileStackProps { + route: ProfileStackRouteProps; } -const Profile: React.FC = ({route}) => { +const Profile: React.FC = ({route}) => { const {isProfileView} = route.params; return ( + screenOptions={{ + headerShown: false, + cardStyle: {backgroundColor: 'transparent'}, + cardOverlayEnabled: true, + cardStyleInterpolator: ({current: {progress}}) => ({ + cardStyle: { + opacity: progress.interpolate({ + inputRange: [0, 0.5, 0.9, 1], + outputRange: [0, 0.25, 0.7, 1], + }), + }, + overlayStyle: { + backgroundColor: '#808080', + opacity: progress.interpolate({ + inputRange: [0, 1], + outputRange: [0, 0.9], + extrapolate: 'clamp', + }), + }, + }), + }} + mode="modal" + initialRouteName={!isProfileView ? `Profile` : `Search`}> {isProfileView ? ( @@ -47,6 +70,12 @@ const Profile: React.FC = ({route}) => { ) : ( )} + ); }; diff --git a/src/routes/profile/ProfileStack.tsx b/src/routes/profile/ProfileStack.tsx index df4d234f..1d7b907e 100644 --- a/src/routes/profile/ProfileStack.tsx +++ b/src/routes/profile/ProfileStack.tsx @@ -1,4 +1,5 @@ import {createStackNavigator} from '@react-navigation/stack'; +import {MomentType} from '../../types'; export type ProfileStackParams = { Search: undefined; @@ -14,6 +15,10 @@ export type ProfileStackParams = { title: string; image: object; }; + IndividualMoment: { + moment: MomentType; + isProfileView: boolean; + }; }; export const ProfileStack = createStackNavigator(); diff --git a/src/routes/profile/index.ts b/src/routes/profile/index.ts index 1ab9cb7e..eed5c6b4 100644 --- a/src/routes/profile/index.ts +++ b/src/routes/profile/index.ts @@ -1,4 +1,2 @@ export * from './ProfileStack'; -export * from './MomentStack'; -export * from './MomentStackScreen'; -export {default} from './Profile'; +export * from './Profile'; diff --git a/src/routes/tabs/NavigationBar.tsx b/src/routes/tabs/NavigationBar.tsx index f05a512b..9cfbe4bf 100644 --- a/src/routes/tabs/NavigationBar.tsx +++ b/src/routes/tabs/NavigationBar.tsx @@ -2,8 +2,7 @@ import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; import React from 'react'; import {NavigationIcon} from '../../components'; import {Home, Notifications, Upload} from '../../screens'; -import Profile from '../profile'; -import MomentStackScreen from '../profile/MomentStackScreen'; +import Profile from '../profile/Profile'; const Tabs = createBottomTabNavigator(); @@ -36,7 +35,7 @@ const NavigationBar: React.FC = () => { ) : ( ); - } else if (route.name === 'MomentStackScreen') { + } else if (route.name === 'Profile') { return focused ? ( ) : ( @@ -45,7 +44,7 @@ const NavigationBar: React.FC = () => { } }, })} - initialRouteName="MomentStackScreen" + initialRouteName="Profile" tabBarOptions={{ showLabel: false, style: { @@ -65,7 +64,11 @@ const NavigationBar: React.FC = () => { /> - + ); }; diff --git a/src/routes/viewProfile/ProfileProvider.tsx b/src/routes/viewProfile/ProfileProvider.tsx index 1af7917d..8fb9a011 100644 --- a/src/routes/viewProfile/ProfileProvider.tsx +++ b/src/routes/viewProfile/ProfileProvider.tsx @@ -8,7 +8,6 @@ import { loadAvatar, loadCover, loadInstaPosts, - loadRecentlySearchedUsers, } from '../../services'; interface ProfileContextProps { @@ -18,6 +17,8 @@ interface ProfileContextProps { avatar: string | null; cover: string | null; instaPosts: Array; + newMomentsAvailable: boolean; + updateMoments: (value: boolean) => void; } const NO_USER: UserType = { userId: '', @@ -35,6 +36,8 @@ export const ProfileContext = createContext({ avatar: null, cover: null, instaPosts: [], + newMomentsAvailable: true, + updateMoments: () => {}, }); /** @@ -46,6 +49,7 @@ const ProfileProvider: React.FC = ({children}) => { const [avatar, setAvatar] = useState(null); const [cover, setCover] = useState(null); const [instaPosts, setInstaPosts] = useState>([]); + const [newMomentsAvailable, setNewMomentsAvailable] = useState(true); const {userId} = user; useEffect(() => { @@ -79,9 +83,13 @@ const ProfileProvider: React.FC = ({children}) => { avatar, cover, instaPosts, + newMomentsAvailable, loadProfile: (id, username) => { setUser({...user, userId: id, username}); }, + updateMoments: (value) => { + setNewMomentsAvailable(value); + }, }}> {children} -- cgit v1.2.3-70-g09d2