From e5e6328a1189ebb3f78e6eee4213e0b0519f716a Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 14 May 2021 16:42:56 -0700 Subject: moved user from contacts code to legacy --- src/screens/main/NotificationsScreen.tsx | 4 +- src/screens/profile/InviteFriendsScreen.tsx | 90 +------------------ src/screens/profile/legacy/UsersFromContacts.tsx | 106 +++++++++++++++++++++++ 3 files changed, 110 insertions(+), 90 deletions(-) create mode 100644 src/screens/profile/legacy/UsersFromContacts.tsx (limited to 'src') diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index 7e2f082c..bce48ef2 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -259,9 +259,7 @@ const NotificationsScreen: React.FC = () => { onPress={async () => { const permission = await checkPermission(); if (permission === 'authorized') { - navigation.navigate('InviteFriendsScreen', { - screenType: ScreenType.Profile, - }); + navigation.navigate('InviteFriendsScreen'); } else { Alert.alert( '"Tagg" Would Like to Access Your Contacts', diff --git a/src/screens/profile/InviteFriendsScreen.tsx b/src/screens/profile/InviteFriendsScreen.tsx index 87b00aaf..b3653d39 100644 --- a/src/screens/profile/InviteFriendsScreen.tsx +++ b/src/screens/profile/InviteFriendsScreen.tsx @@ -10,23 +10,19 @@ import { StyleSheet, Text, TextInput, - TouchableOpacity, TouchableWithoutFeedback, View, } from 'react-native'; import {checkPermission} from 'react-native-contacts'; import Animated from 'react-native-reanimated'; import Icon from 'react-native-vector-icons/Feather'; -import {useDispatch, useStore} from 'react-redux'; -import {ProfilePreview, TabsGradient} from '../../components'; +import {TabsGradient} from '../../components'; import {InviteFriendTile} from '../../components/friends'; -import {TAGG_LIGHT_BLUE} from '../../constants'; import {MainStackParams} from '../../routes'; import {usersFromContactsService} from '../../services/UserFriendsService'; import {ProfilePreviewType} from '../../types'; import { extractContacts, - handleAddFriend, HeaderHeight, isIPhoneX, normalize, @@ -57,15 +53,12 @@ interface InviteFriendsScreenProps { route: InviteFriendsScreenRouteProp; } -const InviteFriendsScreen: React.FC = ({route}) => { - const {screenType} = route.params; - const dispatch = useDispatch(); - const state = useStore().getState(); +const InviteFriendsScreen: React.FC = ({}) => { const [usersFromContacts, setUsersFromContacts] = useState< ProfilePreviewType[] >([]); const [nonUsersFromContacts, setNonUsersFromContacts] = useState<[]>([]); - const [pendingUsers, setPendingUsers] = useState<[]>([]); + const [pendingUsers] = useState<[]>([]); const [results, setResults] = useState({ usersFromContacts: usersFromContacts, nonUsersFromContacts: nonUsersFromContacts, @@ -131,48 +124,6 @@ const InviteFriendsScreen: React.FC = ({route}) => { search(); }, [query]); - const UsersFromContacts = () => ( - <> - item.username} - renderItem={({item}) => ( - - - - - { - handleAddFriend(screenType, item, dispatch, state).then( - (success) => { - if (success) { - let users = usersFromContacts; - const filteredUsers = users.filter( - (user) => user.username !== item.username, - ); - setResults({ - ...results, - usersFromContacts: filteredUsers, - }); - } - }, - ); - }}> - Add Friend - - - )} - /> - - ); - const PendingList = useMemo( () => ( = ({ + screenType, + results, + setResults, +}) => { + const dispatch = useDispatch(); + const state: RootState = useStore().getState(); + return ( + <> + item.username} + renderItem={({item}) => ( + + + + + { + handleAddFriend(screenType, item, dispatch, state).then( + (success) => { + if (success) { + let users = results.usersFromContacts; + const filteredUsers = users.filter( + (user) => user.username !== item.username, + ); + setResults({ + ...results, + usersFromContacts: filteredUsers, + }); + } + }, + ); + }}> + Add Friend + + + )} + /> + + ); +}; + +export default UsersFromContacts; + +const styles = StyleSheet.create({ + ppContainer: { + alignSelf: 'center', + flexDirection: 'row', + justifyContent: 'space-between', + width: '100%', + height: normalize(42), + alignItems: 'center', + marginBottom: '5%', + marginHorizontal: 10, + }, + friend: { + alignSelf: 'center', + height: '100%', + }, + addFriendButton: { + alignSelf: 'center', + justifyContent: 'center', + alignItems: 'center', + width: 82, + height: 25, + borderColor: TAGG_LIGHT_BLUE, + borderWidth: 2, + borderRadius: 2, + padding: 0, + backgroundColor: TAGG_LIGHT_BLUE, + }, + addFriendButtonTitle: { + color: 'white', + padding: 0, + fontSize: normalize(11), + fontWeight: '700', + lineHeight: normalize(13.13), + letterSpacing: normalize(0.6), + paddingHorizontal: '3.8%', + }, +}); -- cgit v1.2.3-70-g09d2