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/profile/legacy/UsersFromContacts.tsx | 106 +++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 src/screens/profile/legacy/UsersFromContacts.tsx (limited to 'src/screens/profile/legacy') diff --git a/src/screens/profile/legacy/UsersFromContacts.tsx b/src/screens/profile/legacy/UsersFromContacts.tsx new file mode 100644 index 00000000..5499799e --- /dev/null +++ b/src/screens/profile/legacy/UsersFromContacts.tsx @@ -0,0 +1,106 @@ +import React from 'react'; +import {FlatList, StyleSheet, Text, TouchableOpacity, View} from 'react-native'; +import {useDispatch, useStore} from 'react-redux'; +import {ProfilePreview} from '../../../components/profile'; +import {TAGG_LIGHT_BLUE} from '../../../constants/constants'; +import {RootState} from '../../../store/rootReducer'; +import {ScreenType} from '../../../types/types'; +import {normalize} from '../../../utils'; +import {handleAddFriend} from '../../../utils/friends'; +import {SearchResultType} from '../InviteFriendsScreen'; + +interface UsersFromContactsProps { + screenType: ScreenType; + results: SearchResultType; + setResults: Function; +} + +const UsersFromContacts: React.FC = ({ + 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