Rework the labeler selection step of the report flow (#3269)

* Rework the labeler selection step of the report flow

* Fix: use gtMobile

* Use primitives, fix avatar

* Spacing tweaks

* Show handle instead of description

---------

Co-authored-by: Eric Bailey <git@esb.lol>
zio/stable
Paul Frazee 2024-03-19 11:38:17 -07:00 committed by GitHub
parent 9277282e6c
commit c9c3bd98b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 53 deletions

View File

@ -104,7 +104,7 @@ export function Default({
}: LabelingServiceProps & ViewStyleProp) { }: LabelingServiceProps & ViewStyleProp) {
return ( return (
<Outer style={style}> <Outer style={style}>
<Avatar /> <Avatar avatar={labeler.creator.avatar} />
<Content> <Content>
<Title <Title
value={getLabelingServiceTitle({ value={getLabelingServiceTitle({

View File

@ -5,12 +5,13 @@ import {useLingui} from '@lingui/react'
import {AppBskyLabelerDefs} from '@atproto/api' import {AppBskyLabelerDefs} from '@atproto/api'
export {useDialogControl as useReportDialogControl} from '#/components/Dialog' export {useDialogControl as useReportDialogControl} from '#/components/Dialog'
import {getLabelingServiceTitle} from '#/lib/moderation'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme, useBreakpoints} from '#/alf'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {Button, useButtonContext} from '#/components/Button' import {Button, useButtonContext} from '#/components/Button'
import {Divider} from '#/components/Divider' import {Divider} from '#/components/Divider'
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron' import * as LabelingServiceCard from '#/components/LabelingServiceCard'
import {ReportDialogProps} from './types' import {ReportDialogProps} from './types'
@ -22,31 +23,29 @@ export function SelectLabelerView({
}) { }) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {gtMobile} = useBreakpoints()
return ( return (
<View style={[a.gap_lg]}> <View style={[a.gap_lg]}>
<View style={[a.justify_center, a.gap_sm]}> <View style={[a.justify_center, gtMobile ? a.gap_sm : a.gap_xs]}>
<Text style={[a.text_2xl, a.font_bold]}> <Text style={[a.text_2xl, a.font_bold]}>
<Trans>Select moderation service</Trans> <Trans>Select moderator</Trans>
</Text> </Text>
<Text style={[a.text_md, t.atoms.text_contrast_medium]}> <Text style={[a.text_md, t.atoms.text_contrast_medium]}>
<Trans>Who do you want to send this report to?</Trans> <Trans>To whom would you like to send this report?</Trans>
</Text> </Text>
</View> </View>
<Divider /> <Divider />
<View style={[a.gap_sm, {marginHorizontal: a.p_md.padding * -1}]}> <View style={[a.gap_xs, {marginHorizontal: a.p_md.padding * -1}]}>
{props.labelers.map(labeler => { {props.labelers.map(labeler => {
return ( return (
<Button <Button
key={labeler.creator.did} key={labeler.creator.did}
label={_(msg`Send report to ${labeler.creator.displayName}`)} label={_(msg`Send report to ${labeler.creator.displayName}`)}
onPress={() => props.onSelectLabeler(labeler.creator.did)}> onPress={() => props.onSelectLabeler(labeler.creator.did)}>
<LabelerButton <LabelerButton labeler={labeler} />
title={labeler.creator.displayName || labeler.creator.handle}
description={labeler.creator.description || ''}
/>
</Button> </Button>
) )
})} })}
@ -56,11 +55,9 @@ export function SelectLabelerView({
} }
function LabelerButton({ function LabelerButton({
title, labeler,
description,
}: { }: {
title: string labeler: AppBskyLabelerDefs.LabelerViewDetailed
description: string
}) { }) {
const t = useTheme() const t = useTheme()
const {hovered, pressed} = useButtonContext() const {hovered, pressed} = useButtonContext()
@ -75,41 +72,21 @@ function LabelerButton({
}, [t]) }, [t])
return ( return (
<View <LabelingServiceCard.Outer
style={[ style={[a.p_md, a.rounded_sm, interacted && styles.interacted]}>
a.w_full, <LabelingServiceCard.Avatar avatar={labeler.creator.avatar} />
a.flex_row, <LabelingServiceCard.Content>
a.align_center, <LabelingServiceCard.Title
a.justify_between, value={getLabelingServiceTitle({
a.p_md, displayName: labeler.creator.displayName,
a.rounded_md, handle: labeler.creator.handle,
{paddingRight: 70}, })}
interacted && styles.interacted,
]}>
<View style={[a.flex_1, a.gap_xs]}>
<Text style={[a.text_md, a.font_bold, t.atoms.text_contrast_medium]}>
{title}
</Text>
<Text style={[a.leading_tight, {maxWidth: 400}]} numberOfLines={3}>
{description}
</Text>
</View>
<View
style={[
a.absolute,
a.inset_0,
a.justify_center,
a.pr_md,
{left: 'auto'},
]}>
<ChevronRight
size="md"
fill={
hovered ? t.palette.primary_500 : t.atoms.text_contrast_low.color
}
/> />
</View> <Text
</View> style={[t.atoms.text_contrast_medium, a.text_sm, a.font_semibold]}>
@{labeler.creator.handle}
</Text>
</LabelingServiceCard.Content>
</LabelingServiceCard.Outer>
) )
} }

View File

@ -9,7 +9,7 @@ import {DMCA_LINK} from '#/components/ReportDialog/const'
import {Link} from '#/components/Link' import {Link} from '#/components/Link'
export {useDialogControl as useReportDialogControl} from '#/components/Dialog' export {useDialogControl as useReportDialogControl} from '#/components/Dialog'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme, useBreakpoints} from '#/alf'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import { import {
Button, Button,
@ -35,6 +35,7 @@ export function SelectReportOptionView({
}) { }) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {gtMobile} = useBreakpoints()
const allReportOptions = useReportOptions() const allReportOptions = useReportOptions()
const reportOptions = allReportOptions[props.params.type] const reportOptions = allReportOptions[props.params.type]
@ -76,7 +77,7 @@ export function SelectReportOptionView({
</Button> </Button>
) : null} ) : null}
<View style={[a.justify_center, a.gap_sm]}> <View style={[a.justify_center, gtMobile ? a.gap_sm : a.gap_xs]}>
<Text style={[a.text_2xl, a.font_bold]}>{i18n.title}</Text> <Text style={[a.text_2xl, a.font_bold]}>{i18n.title}</Text>
<Text style={[a.text_md, t.atoms.text_contrast_medium]}> <Text style={[a.text_md, t.atoms.text_contrast_medium]}>
{i18n.description} {i18n.description}

View File

@ -411,7 +411,7 @@ export function ModerationScreenInner({
t.atoms.bg_contrast_50, t.atoms.bg_contrast_50,
], ],
]}> ]}>
<LabelingService.Avatar /> <LabelingService.Avatar avatar={labeler.creator.avatar} />
<LabelingService.Content> <LabelingService.Content>
<LabelingService.Title <LabelingService.Title
value={getLabelingServiceTitle({ value={getLabelingServiceTitle({