mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at quote-hover 5.5 kB view raw
1import React from 'react' 2import {View} from 'react-native' 3import {AppBskyLabelerDefs} from '@atproto/api' 4import {msg, Trans} from '@lingui/macro' 5import {useLingui} from '@lingui/react' 6 7import {ReportOption, useReportOptions} from '#/lib/moderation/useReportOptions' 8import {Link} from '#/components/Link' 9import {DMCA_LINK} from '#/components/ReportDialog/const' 10export {useDialogControl as useReportDialogControl} from '#/components/Dialog' 11 12import {atoms as a, useBreakpoints, useTheme} from '#/alf' 13import { 14 Button, 15 ButtonIcon, 16 ButtonText, 17 useButtonContext, 18} from '#/components/Button' 19import {Divider} from '#/components/Divider' 20import { 21 ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft, 22 ChevronRight_Stroke2_Corner0_Rounded as ChevronRight, 23} from '#/components/icons/Chevron' 24import {SquareArrowTopRight_Stroke2_Corner0_Rounded as SquareArrowTopRight} from '#/components/icons/SquareArrowTopRight' 25import {Text} from '#/components/Typography' 26import {ReportDialogProps} from './types' 27 28export function SelectReportOptionView({ 29 ...props 30}: ReportDialogProps & { 31 labelers: AppBskyLabelerDefs.LabelerViewDetailed[] 32 onSelectReportOption: (reportOption: ReportOption) => void 33 goBack: () => void 34}) { 35 const t = useTheme() 36 const {_} = useLingui() 37 const {gtMobile} = useBreakpoints() 38 const allReportOptions = useReportOptions() 39 const reportOptions = allReportOptions[props.params.type] 40 41 const i18n = React.useMemo(() => { 42 let title = _(msg`Report this content`) 43 let description = _(msg`Why should this content be reviewed?`) 44 45 if (props.params.type === 'account') { 46 title = _(msg`Report this user`) 47 description = _(msg`Why should this user be reviewed?`) 48 } else if (props.params.type === 'post') { 49 title = _(msg`Report this post`) 50 description = _(msg`Why should this post be reviewed?`) 51 } else if (props.params.type === 'list') { 52 title = _(msg`Report this list`) 53 description = _(msg`Why should this list be reviewed?`) 54 } else if (props.params.type === 'feedgen') { 55 title = _(msg`Report this feed`) 56 description = _(msg`Why should this feed be reviewed?`) 57 } 58 59 return { 60 title, 61 description, 62 } 63 }, [_, props.params.type]) 64 65 return ( 66 <View style={[a.gap_lg]}> 67 {props.labelers?.length > 1 ? ( 68 <Button 69 size="small" 70 variant="solid" 71 color="secondary" 72 shape="round" 73 label={_(msg`Go back to previous step`)} 74 onPress={props.goBack}> 75 <ButtonIcon icon={ChevronLeft} /> 76 </Button> 77 ) : null} 78 79 <View style={[a.justify_center, gtMobile ? a.gap_sm : a.gap_xs]}> 80 <Text style={[a.text_2xl, a.font_bold]}>{i18n.title}</Text> 81 <Text style={[a.text_md, t.atoms.text_contrast_medium]}> 82 {i18n.description} 83 </Text> 84 </View> 85 86 <Divider /> 87 88 <View style={[a.gap_sm]}> 89 {reportOptions.map(reportOption => { 90 return ( 91 <Button 92 key={reportOption.reason} 93 testID={reportOption.reason} 94 label={_(msg`Create report for ${reportOption.title}`)} 95 onPress={() => props.onSelectReportOption(reportOption)}> 96 <ReportOptionButton 97 title={reportOption.title} 98 description={reportOption.description} 99 /> 100 </Button> 101 ) 102 })} 103 104 {(props.params.type === 'post' || props.params.type === 'account') && ( 105 <View 106 style={[ 107 a.flex_row, 108 a.align_center, 109 a.justify_between, 110 a.gap_lg, 111 a.p_md, 112 a.pl_lg, 113 a.rounded_md, 114 t.atoms.bg_contrast_900, 115 ]}> 116 <Text 117 style={[ 118 a.flex_1, 119 t.atoms.text_inverted, 120 a.italic, 121 a.leading_snug, 122 ]}> 123 <Trans>Need to report a copyright violation?</Trans> 124 </Text> 125 <Link 126 to={DMCA_LINK} 127 label={_(msg`View details for reporting a copyright violation`)} 128 size="small" 129 variant="solid" 130 color="secondary"> 131 <ButtonText> 132 <Trans>View details</Trans> 133 </ButtonText> 134 <ButtonIcon position="right" icon={SquareArrowTopRight} /> 135 </Link> 136 </View> 137 )} 138 </View> 139 </View> 140 ) 141} 142 143function ReportOptionButton({ 144 title, 145 description, 146}: { 147 title: string 148 description: string 149}) { 150 const t = useTheme() 151 const {hovered, pressed} = useButtonContext() 152 const interacted = hovered || pressed 153 154 return ( 155 <View 156 style={[ 157 a.w_full, 158 a.flex_row, 159 a.align_center, 160 a.justify_between, 161 a.p_md, 162 a.rounded_md, 163 {paddingRight: 70}, 164 t.atoms.bg_contrast_25, 165 interacted && t.atoms.bg_contrast_50, 166 ]}> 167 <View style={[a.flex_1, a.gap_xs]}> 168 <Text style={[a.text_md, a.font_bold, t.atoms.text_contrast_medium]}> 169 {title} 170 </Text> 171 <Text style={[a.leading_tight, {maxWidth: 400}]}>{description}</Text> 172 </View> 173 174 <View 175 style={[ 176 a.absolute, 177 a.inset_0, 178 a.justify_center, 179 a.pr_md, 180 {left: 'auto'}, 181 ]}> 182 <ChevronRight size="md" fill={t.atoms.text_contrast_low.color} /> 183 </View> 184 </View> 185 ) 186}