aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-04-09 13:27:45 -0400
committerIvan Chen <ivan@tagg.id>2021-04-09 13:27:45 -0400
commitc54a25dc05eeb70780bc3a3ec05cb8cbed3f334b (patch)
tree9c5eba5cbdf0d8989022e723613795560374256b /src
parent0ebd64161da70d5d417886d7026ec8e0f4691db3 (diff)
code cleanup
Diffstat (limited to 'src')
-rw-r--r--src/routes/main/MainStackScreen.tsx24
-rw-r--r--src/screens/chat/ChatResultsCell.tsx9
-rw-r--r--src/screens/chat/ChatResultsList.tsx19
-rw-r--r--src/screens/chat/ChatSearchBar.tsx9
-rw-r--r--src/screens/chat/NewChatModal.tsx3
5 files changed, 22 insertions, 42 deletions
diff --git a/src/routes/main/MainStackScreen.tsx b/src/routes/main/MainStackScreen.tsx
index 1d222040..37867151 100644
--- a/src/routes/main/MainStackScreen.tsx
+++ b/src/routes/main/MainStackScreen.tsx
@@ -1,11 +1,6 @@
import AsyncStorage from '@react-native-community/async-storage';
import {RouteProp} from '@react-navigation/native';
-import {
- StackNavigationOptions,
- createStackNavigator,
- TransitionSpecs,
-} from '@react-navigation/stack';
-import {NavigationContainer} from '@react-navigation/native';
+import {StackNavigationOptions} from '@react-navigation/stack';
import React, {useEffect, useState} from 'react';
import {StyleSheet, Text} from 'react-native';
import {normalize} from 'react-native-elements';
@@ -16,6 +11,8 @@ import {
BadgeSelection,
CaptionScreen,
CategorySelection,
+ ChatListScreen,
+ ChatScreen,
CreateCustomCategory,
DiscoverUsers,
EditProfile,
@@ -24,19 +21,17 @@ import {
InviteFriendsScreen,
MomentCommentsScreen,
MomentUploadPromptScreen,
+ NewChatModal,
NotificationsScreen,
- ProfileScreen,
PrivacyScreen,
+ ProfileScreen,
RequestContactsAccess,
SearchScreen,
+ SettingsScreen,
SocialMediaTaggs,
SuggestedPeopleScreen,
SuggestedPeopleUploadPictureScreen,
SuggestedPeopleWelcomeScreen,
- SettingsScreen,
- ChatListScreen,
- ChatScreen,
- NewChatModal,
} from '../../screens';
import MutualBadgeHolders from '../../screens/suggestedPeople/MutualBadgeHolders';
import {ScreenType} from '../../types';
@@ -58,8 +53,6 @@ type MainStackRouteProps = RouteProp<MainStackParams, 'Profile'>;
interface MainStackProps {
route: MainStackRouteProps;
}
-const RootStack = createStackNavigator();
-const tempStack = createStackNavigator();
const MainStackScreen: React.FC<MainStackProps> = ({route}) => {
const {screenType} = route.params;
@@ -322,7 +315,10 @@ const MainStackScreen: React.FC<MainStackProps> = ({route}) => {
<MainStack.Screen
name="Chat"
component={ChatScreen}
- options={{headerShown: true}}
+ options={{
+ ...headerBarOptions('black', ''),
+ headerStyle: {height: ChatHeaderHeight},
+ }}
/>
<MainStack.Screen
name="NewChatModal"
diff --git a/src/screens/chat/ChatResultsCell.tsx b/src/screens/chat/ChatResultsCell.tsx
index 00f7130d..3678a2d7 100644
--- a/src/screens/chat/ChatResultsCell.tsx
+++ b/src/screens/chat/ChatResultsCell.tsx
@@ -2,14 +2,12 @@ import {useNavigation} from '@react-navigation/native';
import React, {useContext, useEffect, useState} from 'react';
import {Alert, Image, StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
-import {useDispatch, useSelector, useStore} from 'react-redux';
+import {ChatContext} from '../../App';
+import {ERROR_FAILED_TO_CREATE_CHANNEL} from '../../constants/strings';
import {loadImageFromURL} from '../../services';
-import {RootState} from '../../store/rootReducer';
import {ProfilePreviewType, UserType} from '../../types';
import {createChannel, normalize, SCREEN_WIDTH} from '../../utils';
import {defaultUserProfile} from '../../utils/users';
-import {ChatContext} from '../../App';
-import {ERROR_FAILED_TO_CREATE_CHANNEL} from '../../constants/strings';
interface ChatResults {
profileData: ProfilePreviewType;
@@ -24,7 +22,6 @@ const ChatResultsCell: React.FC<ChatResults> = ({
}) => {
const [avatar, setAvatar] = useState<string | undefined>(undefined);
const {chatClient, setChannel} = useContext(ChatContext);
- const {university} = useSelector((state: RootState) => state.user.profile);
useEffect(() => {
(async () => {
@@ -42,8 +39,6 @@ const ChatResultsCell: React.FC<ChatResults> = ({
})();
}, [thumbnail_url]);
- const dispatch = useDispatch();
- const state: RootState = useStore().getState();
const navigation = useNavigation();
const createChannelIfNotPresentAndNavigate = async () => {
try {
diff --git a/src/screens/chat/ChatResultsList.tsx b/src/screens/chat/ChatResultsList.tsx
index 17a16572..0c6d58e4 100644
--- a/src/screens/chat/ChatResultsList.tsx
+++ b/src/screens/chat/ChatResultsList.tsx
@@ -23,16 +23,13 @@ interface ChatResultsProps {
setChatModalVisible: Function;
}
-const sectionHeader: React.FC<Boolean> = () => {
- return null;
-};
-
const ChatResultsList: React.FC<ChatResultsProps> = ({
results,
setChatModalVisible,
}) => {
const [showEmptyView, setshowEmptyView] = useState<boolean>(false);
const {user: loggedInUser} = useSelector((state: RootState) => state.user);
+ const tabbarHeight = useBottomTabBarHeight();
useEffect(() => {
if (results && results.length > 0) {
@@ -54,7 +51,7 @@ const ChatResultsList: React.FC<ChatResultsProps> = ({
) : (
<SectionList
onScrollBeginDrag={Keyboard.dismiss}
- contentContainerStyle={[{paddingBottom: useBottomTabBarHeight()}]}
+ contentContainerStyle={[{paddingBottom: tabbarHeight}]}
sections={results}
keyExtractor={(item, index) => item.id + index}
renderItem={({item}) => {
@@ -68,12 +65,7 @@ const ChatResultsList: React.FC<ChatResultsProps> = ({
}}
stickySectionHeadersEnabled={false}
ListEmptyComponent={() => (
- <View
- style={{
- marginTop: 20,
- justifyContent: 'center',
- alignItems: 'center',
- }}>
+ <View style={styles.empty}>
<Text>Start a new chat by searching for someone</Text>
</View>
)}
@@ -102,6 +94,11 @@ const styles = StyleSheet.create({
fontWeight: '500',
fontSize: normalize(14),
},
+ empty: {
+ marginTop: 20,
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
});
export default ChatResultsList;
diff --git a/src/screens/chat/ChatSearchBar.tsx b/src/screens/chat/ChatSearchBar.tsx
index 294efa57..4916ec45 100644
--- a/src/screens/chat/ChatSearchBar.tsx
+++ b/src/screens/chat/ChatSearchBar.tsx
@@ -1,4 +1,4 @@
-import React, {useEffect, useState} from 'react';
+import React from 'react';
import {
Keyboard,
NativeSyntheticEvent,
@@ -10,16 +10,9 @@ import {
TouchableOpacity,
View,
ViewStyle,
- LayoutChangeEvent,
} from 'react-native';
import {normalize} from 'react-native-elements';
import Animated, {useAnimatedStyle} from 'react-native-reanimated';
-import Icon from 'react-native-vector-icons/Feather';
-import {useSelector} from 'react-redux';
-import {RootState} from '../../store/rootReducer';
-import {getSearchSuggestions} from '../../utils';
-
-const AnimatedIcon = Animated.createAnimatedComponent(Icon);
interface SearchBarProps extends TextInputProps {
onCancel: () => void;
diff --git a/src/screens/chat/NewChatModal.tsx b/src/screens/chat/NewChatModal.tsx
index 32a9b667..a7754d3a 100644
--- a/src/screens/chat/NewChatModal.tsx
+++ b/src/screens/chat/NewChatModal.tsx
@@ -1,5 +1,4 @@
-import {useNavigation} from '@react-navigation/core';
-import React, {useEffect, useRef, useState} from 'react';
+import React, {useEffect, useState} from 'react';
import {
Keyboard,
SectionListData,