mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {View} from 'react-native'
3import {AppBskyActorDefs} from '@atproto/api'
4import {msg, plural} from '@lingui/macro'
5import {useLingui} from '@lingui/react'
6
7import {makeProfileLink} from '#/lib/routes/links'
8import {Shadow} from '#/state/cache/types'
9import {formatCount} from '#/view/com/util/numeric/format'
10import {atoms as a, useTheme} from '#/alf'
11import {InlineLinkText} from '#/components/Link'
12import {Text} from '#/components/Typography'
13
14export function ProfileHeaderMetrics({
15 profile,
16}: {
17 profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
18}) {
19 const t = useTheme()
20 const {_, i18n} = useLingui()
21 const following = formatCount(i18n, profile.followsCount || 0)
22 const followers = formatCount(i18n, profile.followersCount || 0)
23 const pluralizedFollowers = plural(profile.followersCount || 0, {
24 one: 'follower',
25 other: 'followers',
26 })
27 const pluralizedFollowings = plural(profile.followsCount || 0, {
28 one: 'following',
29 other: 'following',
30 })
31
32 return (
33 <View
34 style={[a.flex_row, a.gap_sm, a.align_center, a.pb_md]}
35 pointerEvents="box-none">
36 <InlineLinkText
37 testID="profileHeaderFollowersButton"
38 style={[a.flex_row, t.atoms.text]}
39 to={makeProfileLink(profile, 'followers')}
40 label={`${followers} ${pluralizedFollowers}`}>
41 <Text style={[a.font_bold, a.text_md]}>{followers} </Text>
42 <Text style={[t.atoms.text_contrast_medium, a.text_md]}>
43 {pluralizedFollowers}
44 </Text>
45 </InlineLinkText>
46 <InlineLinkText
47 testID="profileHeaderFollowsButton"
48 style={[a.flex_row, t.atoms.text]}
49 to={makeProfileLink(profile, 'follows')}
50 label={_(msg`${following} following`)}>
51 <Text style={[a.font_bold, a.text_md]}>{following} </Text>
52 <Text style={[t.atoms.text_contrast_medium, a.text_md]}>
53 {pluralizedFollowings}
54 </Text>
55 </InlineLinkText>
56 <Text style={[a.font_bold, t.atoms.text, a.text_md]}>
57 {formatCount(i18n, profile.postsCount || 0)}{' '}
58 <Text style={[t.atoms.text_contrast_medium, a.font_normal, a.text_md]}>
59 {plural(profile.postsCount || 0, {one: 'post', other: 'posts'})}
60 </Text>
61 </Text>
62 </View>
63 )
64}