mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {StyleSheet, View} from 'react-native'
3import {ModerationUI} from '@atproto/api'
4import {useStores} from 'state/index'
5import {s} from 'lib/styles'
6import {Text} from '../util/text/Text'
7import {TextLink} from '../util/Link'
8import {usePalette} from 'lib/hooks/usePalette'
9import {isDesktopWeb} from 'platform/detection'
10import {listUriToHref} from 'lib/strings/url-helpers'
11import {Button} from '../util/forms/Button'
12
13export const snapPoints = [300]
14
15export function Component({
16 context,
17 moderation,
18}: {
19 context: 'account' | 'content'
20 moderation: ModerationUI
21}) {
22 const store = useStores()
23 const pal = usePalette('default')
24
25 let name
26 let description
27 if (!moderation.cause) {
28 name = 'Content Warning'
29 description =
30 'Moderator has chosen to set a general warning on the content.'
31 } else if (moderation.cause.type === 'blocking') {
32 name = 'User Blocked'
33 description = 'You have blocked this user. You cannot view their content.'
34 } else if (moderation.cause.type === 'blocked-by') {
35 name = 'User Blocks You'
36 description = 'This user has blocked you. You cannot view their content.'
37 } else if (moderation.cause.type === 'block-other') {
38 name = 'Content Not Available'
39 description =
40 'This content is not available because one of the users involved has blocked the other.'
41 } else if (moderation.cause.type === 'muted') {
42 if (moderation.cause.source.type === 'list') {
43 const list = moderation.cause.source.list
44 name = <>Account Muted by List</>
45 description = (
46 <>
47 This user is included the{' '}
48 <TextLink
49 type="2xl"
50 href={listUriToHref(list.uri)}
51 text={list.name}
52 style={pal.link}
53 />{' '}
54 list which you have muted.
55 </>
56 )
57 } else {
58 name = 'Account Muted'
59 description = 'You have muted this user.'
60 }
61 } else {
62 name = moderation.cause.labelDef.strings[context].en.name
63 description = moderation.cause.labelDef.strings[context].en.description
64 }
65
66 return (
67 <View testID="moderationDetailsModal" style={[styles.container, pal.view]}>
68 <Text type="title-xl" style={[pal.text, styles.title]}>
69 {name}
70 </Text>
71 <Text type="2xl" style={[pal.text, styles.description]}>
72 {description}
73 </Text>
74 <View style={s.flex1} />
75 <Button
76 type="primary"
77 style={styles.btn}
78 onPress={() => store.shell.closeModal()}>
79 <Text type="button-lg" style={[pal.textLight, s.textCenter, s.white]}>
80 Okay
81 </Text>
82 </Button>
83 </View>
84 )
85}
86
87const styles = StyleSheet.create({
88 container: {
89 flex: 1,
90 paddingHorizontal: isDesktopWeb ? 0 : 14,
91 },
92 title: {
93 textAlign: 'center',
94 fontWeight: 'bold',
95 marginBottom: 12,
96 },
97 description: {
98 textAlign: 'center',
99 },
100 btn: {
101 paddingVertical: 14,
102 marginTop: isDesktopWeb ? 40 : 0,
103 marginBottom: isDesktopWeb ? 0 : 40,
104 },
105})