aboutsummaryrefslogtreecommitdiff
path: root/src/components/suggestedPeople/MutualFriends.tsx
blob: f72104d4bc7c5d5a65b91f55026a9c5e35fb362a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import React, {useState} from 'react';
import {SafeAreaView, StyleSheet, Text, View} from 'react-native';
import {normalize} from 'react-native-elements';
import {ScrollView, TouchableOpacity} from 'react-native-gesture-handler';
import {BottomDrawer, TabsGradient} from '../../components';
import {ProfilePreviewType, ScreenType} from '../../types';
import {isIPhoneX, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
import {ProfilePreview} from '../profile';

interface MutualFriendsProps {
  user: ProfilePreviewType;
  friends: ProfilePreviewType[];
}

const MutualFriends: React.FC<MutualFriendsProps> = ({
  user,
  friends,
}): JSX.Element => {
  // Getting list of first 4 friends to display on suggested people screen
  const friendsPreview = friends.slice(0, 4);

  // Count to be displayed after + symbol
  const count = friends.length - friendsPreview.length;

  const [drawerVisible, setDrawerVisible] = useState(false);

  return (
    <>
      {friends && friends.length > 0 && (
        <SafeAreaView>
          <View style={styles.body}>
            <Text style={styles.title}>Mutual Friends</Text>
            <View style={styles.previewProfilesContainer}>
              {friendsPreview.map((profilePreview) => (
                <ProfilePreview
                  previewType={'Suggested People Screen'}
                  screenType={ScreenType.SuggestedPeople}
                  profilePreview={profilePreview}
                />
              ))}
              {friends && friends.length > 4 && (
                <TouchableOpacity onPress={() => setDrawerVisible(true)}>
                  <View style={styles.mutualFriendsButton}>
                    <Text style={styles.plusSign}>+</Text>
                    <Text style={styles.count}>{count}</Text>
                  </View>
                </TouchableOpacity>
              )}
              <BottomDrawer
                initialSnapPosition={isIPhoneX() ? '43%' : '50%'}
                showHeader={false}
                isOpen={drawerVisible}
                setIsOpen={setDrawerVisible}>
                <View style={styles.mainContainer}>
                  <View style={styles.headerContainer}>
                    <View style={styles.headerTextContainer}>
                      <Text style={styles.headerTitle}>Mutual Friends</Text>
                      <Text style={styles.headerDescription} numberOfLines={2}>
                        @{user.username} and you are both friends with
                      </Text>
                    </View>
                  </View>
                  <View style={styles.scrollViewContainer}>
                    <ScrollView
                      contentContainerStyle={styles.scrollView}
                      horizontal
                      showsHorizontalScrollIndicator={false}>
                      {friends.map((profilePreview) => (
                        <ProfilePreview
                          previewType={'Suggested People Drawer'}
                          screenType={ScreenType.SuggestedPeople}
                          profilePreview={profilePreview}
                          setMFDrawer={setDrawerVisible}
                        />
                      ))}
                    </ScrollView>
                  </View>
                  <TouchableOpacity
                    style={styles.cancelButton}
                    onPress={() => setDrawerVisible(false)}>
                    <Text style={styles.cancelButtonText}>Cancel</Text>
                  </TouchableOpacity>
                </View>
              </BottomDrawer>
            </View>
          </View>
        </SafeAreaView>
      )}
      <TabsGradient />
    </>
  );
};

const styles = StyleSheet.create({
  body: {
    width: SCREEN_WIDTH * 0.9,
    height: isIPhoneX() ? SCREEN_HEIGHT * 0.065 : SCREEN_HEIGHT * 0.08,
    flexDirection: 'column',
    justifyContent: 'flex-start',
    marginBottom: isIPhoneX() ? 25 : 5,
  },
  title: {
    fontSize: normalize(12),
    lineHeight: normalize(12),
    color: '#fff',
    fontWeight: 'bold',
    letterSpacing: normalize(0.1),
    paddingBottom: '3.5%',
  },
  mutualFriendsButton: {
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
  },
  plusSign: {
    fontSize: normalize(16),
    lineHeight: normalize(18),
    color: '#fff',
    fontWeight: 'bold',
    letterSpacing: normalize(0.1),
  },
  count: {
    fontSize: normalize(13),
    lineHeight: normalize(16),
    color: '#fff',
    fontWeight: 'bold',
    letterSpacing: normalize(0.1),
  },
  previewProfilesContainer: {
    flexDirection: 'row',
    alignItems: 'center',
  },
  mainContainer: {
    flexDirection: 'column',
    backgroundColor: '#f9f9f9',
    width: SCREEN_WIDTH,
    height: SCREEN_HEIGHT * 0.46,
    borderTopRightRadius: normalize(13),
    borderTopLeftRadius: normalize(13),
    borderWidth: 0.5,
    borderColor: '#fff',
  },
  headerContainer: {
    width: SCREEN_WIDTH + 2,
    height: isIPhoneX() ? '28%' : '35%',
    borderTopRightRadius: normalize(13),
    borderTopLeftRadius: normalize(13),
    borderWidth: 1,
    borderColor: '#fff',
    backgroundColor: '#fff',
    shadowColor: '#7D7D7D',
    shadowOffset: {width: 3, height: 3},
    shadowRadius: 5,
    shadowOpacity: 0.15,
    marginBottom: 5.5,
    alignSelf: 'center',
  },
  headerTextContainer: {
    flexDirection: 'column',
    alignItems: 'center',
    justifyContent: 'flex-start',
    height: '100%',
    width: '90%',
    alignSelf: 'center',
    marginTop: '4%',
  },
  headerTitle: {
    fontSize: normalize(16),
    fontWeight: '700',
    lineHeight: normalize(20.29),
    marginBottom: '0.5%',
    letterSpacing: normalize(0.1),
  },
  headerDescription: {
    fontSize: normalize(13),
    lineHeight: normalize(15),
    fontWeight: '600',
    color: '#828282',
    paddingTop: '2%',
    letterSpacing: normalize(0.05),
    textAlign: 'center',
  },
  scrollViewContainer: {
    height: isIPhoneX() ? 153 : 135,
    shadowColor: 'rgb(125, 125, 125)',
    marginTop: '1%',
  },
  scrollView: {
    height: '95%',
    padding: 0,
    marginHorizontal: '5%',
  },
  cancelButton: {
    backgroundColor: '#F0F0F0',
    height: 100,
    flexDirection: 'row',
    justifyContent: 'center',
  },
  cancelButtonText: {
    top: isIPhoneX() ? '6%' : '7%',
    color: '#698DD3',
    fontSize: normalize(16),
    fontWeight: '700',
    lineHeight: normalize(20),
    letterSpacing: normalize(0.1),
  },
});

export default MutualFriends;