forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
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 {type Shadow} from '#/state/cache/types'
8import {atoms as a, useTheme, web} from '#/alf'
9import {NewskieDialog} from '#/components/NewskieDialog'
10import {Text} from '#/components/Typography'
11import {IS_IOS, IS_NATIVE} from '#/env'
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_sm, a.align_center, {maxWidth: '100%'}]}
27 pointerEvents={disableTaps ? 'none' : IS_IOS ? 'auto' : 'box-none'}>
28 <NewskieDialog profile={profile} disabled={disableTaps} />
29 {profile.viewer?.followedBy && !blockHide ? (
30 <View style={[t.atoms.bg_contrast_50, 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({
51 wordBreak: 'break-all',
52 direction: 'ltr',
53 unicodeBidi: 'isolate',
54 }),
55 ]}>
56 {invalidHandle
57 ? _(msg`鈿營nvalid Handle`)
58 : sanitizeHandle(
59 profile.handle,
60 '@',
61 // forceLTR handled by CSS above on web
62 IS_NATIVE,
63 )}
64 </Text>
65 </View>
66 )
67}