mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at thread-bug 2.5 kB view raw
1import {View} from 'react-native' 2import {AppBskyLabelerDefs} from '@atproto/api' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5 6import {getLabelingServiceTitle} from '#/lib/moderation' 7import {atoms as a, useBreakpoints, useTheme} from '#/alf' 8import {Button, useButtonContext} from '#/components/Button' 9import {Divider} from '#/components/Divider' 10import * as LabelingServiceCard from '#/components/LabelingServiceCard' 11import {Text} from '#/components/Typography' 12import {ReportDialogProps} from './types' 13 14export function SelectLabelerView({ 15 ...props 16}: ReportDialogProps & { 17 labelers: AppBskyLabelerDefs.LabelerViewDetailed[] 18 onSelectLabeler: (v: string) => void 19}) { 20 const t = useTheme() 21 const {_} = useLingui() 22 const {gtMobile} = useBreakpoints() 23 24 return ( 25 <View style={[a.gap_lg]}> 26 <View style={[a.justify_center, gtMobile ? a.gap_sm : a.gap_xs]}> 27 <Text style={[a.text_2xl, a.font_bold]}> 28 <Trans>Select moderator</Trans> 29 </Text> 30 <Text style={[a.text_md, t.atoms.text_contrast_medium]}> 31 <Trans>To whom would you like to send this report?</Trans> 32 </Text> 33 </View> 34 35 <Divider /> 36 37 <View style={[a.gap_sm]}> 38 {props.labelers.map(labeler => { 39 return ( 40 <Button 41 key={labeler.creator.did} 42 label={_(msg`Send report to ${labeler.creator.displayName}`)} 43 onPress={() => props.onSelectLabeler(labeler.creator.did)}> 44 <LabelerButton labeler={labeler} /> 45 </Button> 46 ) 47 })} 48 </View> 49 </View> 50 ) 51} 52 53function LabelerButton({ 54 labeler, 55}: { 56 labeler: AppBskyLabelerDefs.LabelerViewDetailed 57}) { 58 const t = useTheme() 59 const {hovered, pressed} = useButtonContext() 60 const interacted = hovered || pressed 61 62 return ( 63 <LabelingServiceCard.Outer 64 style={[ 65 a.p_md, 66 a.rounded_sm, 67 t.atoms.bg_contrast_25, 68 interacted && t.atoms.bg_contrast_50, 69 ]}> 70 <LabelingServiceCard.Avatar avatar={labeler.creator.avatar} /> 71 <LabelingServiceCard.Content> 72 <LabelingServiceCard.Title 73 value={getLabelingServiceTitle({ 74 displayName: labeler.creator.displayName, 75 handle: labeler.creator.handle, 76 })} 77 /> 78 <Text style={[t.atoms.text_contrast_medium, a.text_sm, a.font_bold]}> 79 @{labeler.creator.handle} 80 </Text> 81 </LabelingServiceCard.Content> 82 </LabelingServiceCard.Outer> 83 ) 84}