diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-09 17:15:29 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-09 17:15:29 -0400 |
commit | 347e9e450268e4897b8dd241721b84945d9e2ec9 (patch) | |
tree | 58334be3724398c886365e99901e4442f5657172 /src/routes/main/MainStackScreen.tsx | |
parent | 097b515066f1a0c38cb7fb69cf78b16b945594e5 (diff) | |
parent | 3ec56863bfdd47b2ee8d0f0fe5a45be779508660 (diff) |
Merge branch 'master' into tma756-bugfix-onpress-tagg-on-sp
# Conflicts:
# src/components/taggs/TaggsBar.tsx
Diffstat (limited to 'src/routes/main/MainStackScreen.tsx')
-rw-r--r-- | src/routes/main/MainStackScreen.tsx | 410 |
1 files changed, 222 insertions, 188 deletions
diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx index d855f0df..37867151 100644 --- a/src/routes/main/MainStackScreen.tsx +++ b/src/routes/main/MainStackScreen.tsx @@ -1,7 +1,7 @@ import AsyncStorage from '@react-native-community/async-storage'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationOptions} from '@react-navigation/stack'; -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {StyleSheet, Text} from 'react-native'; import {normalize} from 'react-native-elements'; import BackIcon from '../../assets/icons/back-arrow.svg'; @@ -11,6 +11,8 @@ import { BadgeSelection, CaptionScreen, CategorySelection, + ChatListScreen, + ChatScreen, CreateCustomCategory, DiscoverUsers, EditProfile, @@ -19,20 +21,21 @@ import { InviteFriendsScreen, MomentCommentsScreen, MomentUploadPromptScreen, + NewChatModal, NotificationsScreen, - ProfileScreen, PrivacyScreen, + ProfileScreen, RequestContactsAccess, SearchScreen, + SettingsScreen, SocialMediaTaggs, SuggestedPeopleScreen, SuggestedPeopleUploadPictureScreen, SuggestedPeopleWelcomeScreen, - SettingsScreen, } from '../../screens'; import MutualBadgeHolders from '../../screens/suggestedPeople/MutualBadgeHolders'; import {ScreenType} from '../../types'; -import {AvatarHeaderHeight, SCREEN_WIDTH} from '../../utils'; +import {AvatarHeaderHeight, ChatHeaderHeight, SCREEN_WIDTH} from '../../utils'; import {MainStack, MainStackParams} from './MainStackNavigator'; /** @@ -50,7 +53,6 @@ type MainStackRouteProps = RouteProp<MainStackParams, 'Profile'>; interface MainStackProps { route: MainStackRouteProps; } - const MainStackScreen: React.FC<MainStackProps> = ({route}) => { const {screenType} = route.params; @@ -62,6 +64,10 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { 'true', ); + useEffect(() => { + loadResponseToAccessContacts(); + }, []); + const loadResponseToAccessContacts = () => { AsyncStorage.getItem('respondedToAccessContacts') .then((value) => { @@ -73,8 +79,6 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { }); }; - loadResponseToAccessContacts(); - const initialRouteName = (() => { switch (screenType) { case ScreenType.Profile: @@ -85,6 +89,8 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { return 'Notifications'; case ScreenType.SuggestedPeople: return 'SuggestedPeople'; + case ScreenType.Chat: + return 'ChatList'; } })(); @@ -102,200 +108,228 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => { }), }; - return ( - <MainStack.Navigator - screenOptions={{ - headerShown: false, - gestureResponseDistance: {horizontal: SCREEN_WIDTH * 0.6}, - }} - mode="card" - initialRouteName={initialRouteName}> - <MainStack.Screen - name="Profile" - component={ProfileScreen} - initialParams={{screenType}} - options={{ - ...headerBarOptions('white', ''), + const newChatModalStyle: StackNavigationOptions = { + cardStyle: {backgroundColor: 'rgba(0, 0, 0, 0.5)'}, + cardOverlayEnabled: true, + animationEnabled: false, + }; + + const mainStackScreen = () => { + return ( + <MainStack.Navigator + screenOptions={{ + headerShown: false, + gestureResponseDistance: {horizontal: SCREEN_WIDTH * 0.6}, }} - /> - {isSuggestedPeopleTab && - (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( + mode="card" + initialRouteName={initialRouteName}> + <MainStack.Screen + name="Profile" + component={ProfileScreen} + initialParams={{screenType}} + options={{ + ...headerBarOptions('white', ''), + }} + /> + {isSuggestedPeopleTab && + (respondedToAccessContacts && respondedToAccessContacts === 'true' ? ( + <MainStack.Screen + name="SuggestedPeople" + component={SuggestedPeopleScreen} + initialParams={{screenType}} + /> + ) : ( + <MainStack.Screen + name="SuggestedPeople" + component={RequestContactsAccess} + initialParams={{screenType}} + /> + ))} + {isNotificationsTab && ( <MainStack.Screen - name="SuggestedPeople" - component={SuggestedPeopleScreen} + name="Notifications" + component={NotificationsScreen} initialParams={{screenType}} /> - ) : ( + )} + {isSearchTab && ( <MainStack.Screen - name="SuggestedPeople" - component={RequestContactsAccess} + name="Search" + component={SearchScreen} initialParams={{screenType}} /> - ))} - {isNotificationsTab && ( + )} + <MainStack.Screen + name="DiscoverUsers" + component={DiscoverUsers} + options={{ + ...headerBarOptions('white', 'Discover Users'), + }} + /> + <MainStack.Screen + name="SettingsScreen" + component={SettingsScreen} + options={{ + ...headerBarOptions('white', 'Settings and Privacy'), + }} + /> + <MainStack.Screen + name="PrivacyScreen" + component={PrivacyScreen} + options={{ + ...headerBarOptions('white', 'Privacy'), + }} + /> + <MainStack.Screen + name="AccountTypeScreen" + component={AccountType} + options={{ + ...headerBarOptions('white', 'Account Type'), + }} + /> <MainStack.Screen - name="Notifications" - component={NotificationsScreen} + name="AnimatedTutorial" + component={AnimatedTutorial} + options={{ + ...tutorialModalStyle, + }} initialParams={{screenType}} /> - )} - {isSearchTab && ( <MainStack.Screen - name="Search" - component={SearchScreen} + name="CaptionScreen" + component={CaptionScreen} + options={{ + ...modalStyle, + gestureEnabled: false, + }} + /> + <MainStack.Screen + name="SocialMediaTaggs" + component={SocialMediaTaggs} initialParams={{screenType}} + options={{ + ...headerBarOptions('white', ''), + headerStyle: {height: AvatarHeaderHeight}, + }} /> - )} - <MainStack.Screen - name="DiscoverUsers" - component={DiscoverUsers} - options={{ - ...headerBarOptions('white', 'Discover Users'), - }} - /> - <MainStack.Screen - name="SettingsScreen" - component={SettingsScreen} - options={{ - ...headerBarOptions('white', 'Settings and Privacy'), - }} - /> - <MainStack.Screen - name="PrivacyScreen" - component={PrivacyScreen} - options={{ - ...headerBarOptions('white', 'Privacy'), - }} - /> - <MainStack.Screen - name="AccountTypeScreen" - component={AccountType} - options={{ - ...headerBarOptions('white', 'Account Type'), - }} - /> - <MainStack.Screen - name="AnimatedTutorial" - component={AnimatedTutorial} - options={{ - ...tutorialModalStyle, - }} - initialParams={{screenType}} - /> - <MainStack.Screen - name="CaptionScreen" - component={CaptionScreen} - options={{ - ...modalStyle, - gestureEnabled: false, - }} - /> - <MainStack.Screen - name="SocialMediaTaggs" - component={SocialMediaTaggs} - initialParams={{screenType}} - options={{ - ...headerBarOptions('white', ''), - headerStyle: {height: AvatarHeaderHeight}, - }} - /> - <MainStack.Screen - name="CategorySelection" - component={CategorySelection} - options={{ - ...headerBarOptions('white', ''), - }} - /> - <MainStack.Screen - name="CreateCustomCategory" - component={CreateCustomCategory} - options={{ - ...headerBarOptions('white', ''), - }} - /> - <MainStack.Screen - name="IndividualMoment" - component={IndividualMoment} - initialParams={{screenType}} - options={{ - ...modalStyle, - gestureEnabled: false, - }} - /> - <MainStack.Screen - name="MomentCommentsScreen" - component={MomentCommentsScreen} - initialParams={{screenType}} - options={{ - ...headerBarOptions('black', 'Comments'), - }} - /> - <MainStack.Screen - name="MomentUploadPrompt" - component={MomentUploadPromptScreen} - initialParams={{screenType}} - options={{ - ...modalStyle, - }} - /> - <MainStack.Screen - name="FriendsListScreen" - component={FriendsListScreen} - initialParams={{screenType}} - options={{ - ...headerBarOptions('black', 'Friends'), - }} - /> - <MainStack.Screen - name="InviteFriendsScreen" - component={InviteFriendsScreen} - initialParams={{screenType}} - options={{ - ...headerBarOptions('black', 'Invites'), - }} - /> - <MainStack.Screen - name="RequestContactsAccess" - component={RequestContactsAccess} - initialParams={{screenType}} - /> - <MainStack.Screen - name="EditProfile" - component={EditProfile} - options={{ - ...headerBarOptions('white', 'Edit Profile'), - }} - /> - <MainStack.Screen - name="UpdateSPPicture" - component={SuggestedPeopleUploadPictureScreen} - initialParams={{editing: true}} - options={{ - ...headerBarOptions('white', ''), - }} - /> - <MainStack.Screen - name="BadgeSelection" - component={BadgeSelection} - initialParams={{editing: true}} - options={{ - ...headerBarOptions('white', ''), - }} - /> - <MainStack.Screen - name="MutualBadgeHolders" - component={MutualBadgeHolders} - options={{...modalStyle}} - /> - <MainStack.Screen - name="SPWelcomeScreen" - component={SuggestedPeopleWelcomeScreen} - options={{ - ...headerBarOptions('white', ''), - }} - /> - </MainStack.Navigator> - ); + <MainStack.Screen + name="CategorySelection" + component={CategorySelection} + options={{ + ...headerBarOptions('white', ''), + }} + /> + <MainStack.Screen + name="CreateCustomCategory" + component={CreateCustomCategory} + options={{ + ...headerBarOptions('white', ''), + }} + /> + <MainStack.Screen + name="IndividualMoment" + component={IndividualMoment} + initialParams={{screenType}} + options={{ + ...modalStyle, + gestureEnabled: false, + }} + /> + <MainStack.Screen + name="MomentCommentsScreen" + component={MomentCommentsScreen} + initialParams={{screenType}} + options={{ + ...headerBarOptions('black', 'Comments'), + }} + /> + <MainStack.Screen + name="MomentUploadPrompt" + component={MomentUploadPromptScreen} + initialParams={{screenType}} + options={{ + ...modalStyle, + }} + /> + <MainStack.Screen + name="FriendsListScreen" + component={FriendsListScreen} + initialParams={{screenType}} + options={{ + ...headerBarOptions('black', 'Friends'), + }} + /> + <MainStack.Screen + name="InviteFriendsScreen" + component={InviteFriendsScreen} + initialParams={{screenType}} + options={{ + ...headerBarOptions('black', 'Invites'), + }} + /> + <MainStack.Screen + name="RequestContactsAccess" + component={RequestContactsAccess} + initialParams={{screenType}} + /> + <MainStack.Screen + name="EditProfile" + component={EditProfile} + options={{ + ...headerBarOptions('white', 'Edit Profile'), + }} + /> + <MainStack.Screen + name="UpdateSPPicture" + component={SuggestedPeopleUploadPictureScreen} + initialParams={{editing: true}} + options={{ + ...headerBarOptions('white', ''), + }} + /> + <MainStack.Screen + name="BadgeSelection" + component={BadgeSelection} + initialParams={{editing: true}} + options={{ + ...headerBarOptions('white', ''), + }} + /> + <MainStack.Screen + name="MutualBadgeHolders" + component={MutualBadgeHolders} + options={{...modalStyle}} + /> + <MainStack.Screen + name="SPWelcomeScreen" + component={SuggestedPeopleWelcomeScreen} + options={{ + ...headerBarOptions('white', ''), + }} + /> + <MainStack.Screen + name="ChatList" + component={ChatListScreen} + options={{headerTitle: 'Chats'}} + /> + <MainStack.Screen + name="Chat" + component={ChatScreen} + options={{ + ...headerBarOptions('black', ''), + headerStyle: {height: ChatHeaderHeight}, + }} + /> + <MainStack.Screen + name="NewChatModal" + component={NewChatModal} + options={{headerShown: false, ...newChatModalStyle}} + /> + </MainStack.Navigator> + ); + }; + + return mainStackScreen(); }; export const headerBarOptions: ( |