aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-05-26 17:43:30 -0700
committerShravya Ramesh <shravs1208@gmail.com>2021-05-26 17:43:30 -0700
commit0cdd6943aa37dbcc69ee161f3b853169464950fa (patch)
tree6b0b690529a5210a50a173ee039d562b5b37b0e5
parentc6253ba5aa32638b63eb6ba1fcd11db6f8b6ba90 (diff)
Code refactor minor
-rw-r--r--src/screens/suggestedPeople/SPBody.tsx55
1 files changed, 25 insertions, 30 deletions
diff --git a/src/screens/suggestedPeople/SPBody.tsx b/src/screens/suggestedPeople/SPBody.tsx
index 3d7cf3f2..eb80da49 100644
--- a/src/screens/suggestedPeople/SPBody.tsx
+++ b/src/screens/suggestedPeople/SPBody.tsx
@@ -115,20 +115,30 @@ const SPBody: React.FC<SPBodyProps> = ({
[suggested_people_url],
);
- const NamePlate = () => {
- return (
- <TouchableOpacity
- onPress={() => {
- navigation.navigate('Profile', {
- userXId: loggedInUserId === user.id ? undefined : user.id,
- screenType,
- });
- }}>
- <Text style={styles.firstName}>{user.first_name}</Text>
- <Text style={styles.username}>@{user.username}</Text>
- </TouchableOpacity>
- );
- };
+ const NamePlate = () => (
+ <TouchableOpacity
+ onPress={() => {
+ navigation.navigate('Profile', {
+ userXId: loggedInUserId === user.id ? undefined : user.id,
+ screenType,
+ });
+ }}>
+ <Text style={styles.firstName}>{user.first_name}</Text>
+ <Text style={styles.username}>@{user.username}</Text>
+ </TouchableOpacity>
+ );
+
+ const Badges = () => (
+ // Badges aligned left and spaced as if there are 5 items
+ <View style={styles.badgeContainer}>
+ {localBadges.map(({badge, img}, index) => (
+ <BadgeIcon key={index} badge={badge} img={img} style={styles.badge} />
+ ))}
+ {[0, 0, 0, 0, 0].splice(localBadges.length, 5).map((_, index) => (
+ <View key={index} style={styles.badge} />
+ ))}
+ </View>
+ );
return (
<View>
@@ -149,22 +159,7 @@ const SPBody: React.FC<SPBodyProps> = ({
{user.id !== loggedInUserId && <FriendButton />}
</View>
</View>
- {localBadges.length !== 0 && (
- // Badges aligned left and spaced as if there are 5 items
- <View style={styles.badgeContainer}>
- {localBadges.map(({badge, img}, index) => (
- <BadgeIcon
- key={index}
- badge={badge}
- img={img}
- style={styles.badge}
- />
- ))}
- {[0, 0, 0, 0, 0].splice(localBadges.length, 5).map((_, index) => (
- <View key={index} style={styles.badge} />
- ))}
- </View>
- )}
+ {localBadges.length !== 0 && <Badges />}
<View style={styles.marginManager}>
<MutualFriends user={user} friends={mutual_friends} />
</View>