mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {Pressable, StyleProp, View, ViewStyle} from 'react-native'
3import {ComAtprotoLabelDefs} from '@atproto/api'
4import {Text} from '../text/Text'
5import {usePalette} from 'lib/hooks/usePalette'
6import {msg, Trans} from '@lingui/macro'
7import {useLingui} from '@lingui/react'
8import {useModalControls} from '#/state/modals'
9
10export function LabelInfo({
11 details,
12 labels,
13 style,
14}: {
15 details: {did: string} | {uri: string; cid: string}
16 labels: ComAtprotoLabelDefs.Label[] | undefined
17 style?: StyleProp<ViewStyle>
18}) {
19 const pal = usePalette('default')
20 const {_} = useLingui()
21 const {openModal} = useModalControls()
22
23 if (!labels) {
24 return null
25 }
26 labels = labels.filter(l => !l.val.startsWith('!'))
27 if (!labels.length) {
28 return null
29 }
30
31 return (
32 <View
33 style={[
34 pal.viewLight,
35 {
36 flexDirection: 'row',
37 flexWrap: 'wrap',
38 paddingHorizontal: 12,
39 paddingVertical: 10,
40 borderRadius: 8,
41 },
42 style,
43 ]}>
44 <Text type="sm" style={pal.text}>
45 <Trans>
46 A content warning has been applied to this{' '}
47 {'did' in details ? 'account' : 'post'}.
48 </Trans>{' '}
49 </Text>
50 <Pressable
51 accessibilityRole="button"
52 accessibilityLabel={_(msg`Appeal this decision`)}
53 accessibilityHint=""
54 onPress={() => openModal({name: 'appeal-label', ...details})}>
55 <Text type="sm" style={pal.link}>
56 <Trans>Appeal this decision.</Trans>
57 </Text>
58 </Pressable>
59 </View>
60 )
61}