Skip to content

Commit cf80968

Browse files
committed
Update profile.tsx
1 parent c1a757f commit cf80968

File tree

1 file changed

+72
-64
lines changed

1 file changed

+72
-64
lines changed

app/(user-flow)/profile.tsx

Lines changed: 72 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -181,25 +181,25 @@ function ProfileStatsGridComponent({
181181
label: 'Following',
182182
description: 'Users followed',
183183
value: displayValues.following,
184-
accent: true,
184+
smallValue: false,
185185
},
186186
{
187187
label: 'Followers',
188188
description: 'Total count',
189189
value: displayValues.followers,
190-
accent: true,
190+
smallValue: false,
191191
},
192192
{
193193
label: 'Reputation',
194194
description: 'Network score',
195195
value: displayValues.reputation,
196-
accent: false,
196+
smallValue: false,
197197
},
198198
{
199199
label: 'Joined',
200200
description: 'Account created',
201201
value: displayValues.joined,
202-
accent: false,
202+
smallValue: true,
203203
},
204204
],
205205
[displayValues]
@@ -223,12 +223,7 @@ function ProfileStatsGridComponent({
223223
{showSkeleton ? (
224224
<>
225225
<Skeleton style={[styles.skeletonLabel, { backgroundColor: getPrimaryColor('700') }]} />
226-
<Skeleton
227-
style={[
228-
styles.skeletonValue,
229-
{ backgroundColor: getPrimaryColor('700'), width: stat.accent ? 100 : 60 },
230-
]}
231-
/>
226+
<Skeleton style={[styles.skeletonValue, { backgroundColor: getPrimaryColor('700') }]} />
232227
<Skeleton style={[styles.skeletonDesc, { backgroundColor: getPrimaryColor('700') }]} />
233228
</>
234229
) : (
@@ -243,7 +238,7 @@ function ProfileStatsGridComponent({
243238
<Text
244239
bold
245240
overpass
246-
size={stat.accent ? 24 : 16}
241+
size={stat.smallValue ? 16 : 20}
247242
style={{ color: getPrimaryColor('0'), marginBottom: 2 }}>
248243
{stat.value}
249244
</Text>
@@ -281,7 +276,15 @@ function TopFollowersComponent({
281276
const { getPrimaryColor } = useTheme();
282277
const fadeAnim = useRef(new Animated.Value(0)).current;
283278

284-
// Filter to only show followers with profile info
279+
// Calculate responsive avatar size for 3-column grid
280+
// Available width = screen width - padding (32) - gaps (24 for 2 gaps between 3 items)
281+
const GRID_PADDING = 32;
282+
const GRID_GAP = 12;
283+
const COLUMNS = 3;
284+
const itemWidth = (SCREEN_WIDTH - GRID_PADDING - GRID_GAP * (COLUMNS - 1)) / COLUMNS;
285+
const avatarSize = Math.min(itemWidth - 16, 64); // Leave some padding, max 64
286+
287+
// Filter to only show followers with profile info (max 6 for 3x2 grid)
285288
const followersWithProfiles = useMemo(
286289
() => getFollowersWithProfiles(topFollowers).slice(0, 6),
287290
[topFollowers]
@@ -310,6 +313,54 @@ function TopFollowersComponent({
310313
});
311314
};
312315

316+
const renderItem = (follower: TopFollower) => (
317+
<TouchableOpacity
318+
key={follower.pubkey}
319+
style={[styles.topFollowerGridItem, { width: itemWidth }]}
320+
onPress={() => handleFollowerPress(follower)}
321+
activeOpacity={0.7}>
322+
<Avatar
323+
picture={getFollowerPicture(follower)}
324+
seed={follower.pubkey}
325+
size={avatarSize}
326+
variant="person"
327+
name={getFollowerDisplayName(follower)}
328+
/>
329+
<Text
330+
size={11}
331+
bold
332+
numberOfLines={1}
333+
style={{
334+
color: getPrimaryColor('200'),
335+
marginTop: 6,
336+
textAlign: 'center',
337+
width: itemWidth - 8,
338+
}}>
339+
{getFollowerDisplayName(follower)}
340+
</Text>
341+
</TouchableOpacity>
342+
);
343+
344+
const renderSkeleton = (index: number) => (
345+
<View key={index} style={[styles.topFollowerGridItem, { width: itemWidth }]}>
346+
<Skeleton
347+
style={[
348+
styles.topFollowerAvatar,
349+
{ width: avatarSize, height: avatarSize, backgroundColor: getPrimaryColor('700') },
350+
]}
351+
/>
352+
<Skeleton
353+
style={{
354+
width: itemWidth - 24,
355+
height: 12,
356+
borderRadius: 4,
357+
marginTop: 6,
358+
backgroundColor: getPrimaryColor('700'),
359+
}}
360+
/>
361+
</View>
362+
);
363+
313364
return (
314365
<View style={{ paddingHorizontal: 16 }}>
315366
<Text
@@ -320,55 +371,10 @@ function TopFollowersComponent({
320371
TOP FOLLOWERS
321372
</Text>
322373
{isLoading ? (
323-
<HStack gap={12} style={{ flexWrap: 'wrap' }}>
324-
{[0, 1, 2].map((i) => (
325-
<View key={i} style={styles.topFollowerItem}>
326-
<Skeleton
327-
style={[styles.topFollowerAvatar, { backgroundColor: getPrimaryColor('700') }]}
328-
/>
329-
<Skeleton
330-
style={{
331-
width: 60,
332-
height: 12,
333-
borderRadius: 4,
334-
marginTop: 6,
335-
backgroundColor: getPrimaryColor('700'),
336-
}}
337-
/>
338-
</View>
339-
))}
340-
</HStack>
374+
<View style={styles.topFollowersGrid}>{[0, 1, 2, 3, 4, 5].map(renderSkeleton)}</View>
341375
) : (
342376
<Animated.View style={{ opacity: fadeAnim }}>
343-
<HStack gap={12} style={{ flexWrap: 'wrap' }}>
344-
{followersWithProfiles.map((follower) => (
345-
<TouchableOpacity
346-
key={follower.pubkey}
347-
style={styles.topFollowerItem}
348-
onPress={() => handleFollowerPress(follower)}
349-
activeOpacity={0.7}>
350-
<Avatar
351-
picture={getFollowerPicture(follower)}
352-
seed={follower.pubkey}
353-
size={48}
354-
variant="person"
355-
name={getFollowerDisplayName(follower)}
356-
/>
357-
<Text
358-
size={11}
359-
bold
360-
numberOfLines={1}
361-
style={{
362-
color: getPrimaryColor('200'),
363-
marginTop: 6,
364-
textAlign: 'center',
365-
maxWidth: 64,
366-
}}>
367-
{getFollowerDisplayName(follower)}
368-
</Text>
369-
</TouchableOpacity>
370-
))}
371-
</HStack>
377+
<View style={styles.topFollowersGrid}>{followersWithProfiles.map(renderItem)}</View>
372378
</Animated.View>
373379
)}
374380
<Spacer size={16} />
@@ -868,15 +874,17 @@ const styles = StyleSheet.create({
868874
height: 14,
869875
borderRadius: 4,
870876
},
871-
topFollowerItem: {
877+
topFollowersGrid: {
878+
flexDirection: 'row',
879+
flexWrap: 'wrap',
880+
gap: 12,
881+
},
882+
topFollowerGridItem: {
872883
alignItems: 'center',
873-
width: 64,
874884
marginBottom: 8,
875885
},
876886
topFollowerAvatar: {
877-
width: 48,
878-
height: 48,
879-
borderRadius: 24,
887+
borderRadius: 32,
880888
},
881889
});
882890

0 commit comments

Comments
 (0)