mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {View} from 'react-native'
2import {type AppBskyActorDefs} from '@atproto/api'
3import {msg, Trans} from '@lingui/macro'
4import {useLingui} from '@lingui/react'
5
6import {isInvalidHandle, sanitizeHandle} from '#/lib/strings/handles'
7import {isIOS} from '#/platform/detection'
8import {type Shadow} from '#/state/cache/types'
9import {atoms as a, useTheme, web} from '#/alf'
10import {NewskieDialog} from '#/components/NewskieDialog'
11import {Text} from '#/components/Typography'
12
13export function ProfileHeaderHandle({
14 profile,
15 disableTaps,
16}: {
17 profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
18 disableTaps?: boolean
19}) {
20 const t = useTheme()
21 const {_} = useLingui()
22 const invalidHandle = isInvalidHandle(profile.handle)
23 const blockHide = profile.viewer?.blocking || profile.viewer?.blockedBy
24 return (
25 <View
26 style={[a.flex_row, a.gap_xs, a.align_center, {maxWidth: '100%'}]}
27 pointerEvents={disableTaps ? 'none' : isIOS ? 'auto' : 'box-none'}>
28 <NewskieDialog profile={profile} disabled={disableTaps} />
29 {profile.viewer?.followedBy && !blockHide ? (
30 <View style={[t.atoms.bg_contrast_25, a.rounded_xs, a.px_sm, a.py_xs]}>
31 <Text style={[t.atoms.text, a.text_sm]}>
32 <Trans>Follows you</Trans>
33 </Text>
34 </View>
35 ) : undefined}
36 <Text
37 emoji
38 numberOfLines={1}
39 style={[
40 invalidHandle
41 ? [
42 a.border,
43 a.text_xs,
44 a.px_sm,
45 a.py_xs,
46 a.rounded_xs,
47 {borderColor: t.palette.contrast_200},
48 ]
49 : [a.text_md, a.leading_snug, t.atoms.text_contrast_medium],
50 web({wordBreak: 'break-all'}),
51 ]}>
52 {invalidHandle
53 ? _(msg`⚠Invalid Handle`)
54 : sanitizeHandle(profile.handle, '@')}
55 </Text>
56 </View>
57 )
58}