diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 702ec43ccd..444e02be8b 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -105,9 +105,9 @@ export function Inner(props: DialogInnerProps) { return ( + + + ) } diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index 83ae8647c3..30fb4b61ec 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -148,7 +148,7 @@ export function Inner({ a.rounded_md, a.w_full, a.border, - gtMobile ? a.p_xl : a.p_lg, + gtMobile ? a.p_2xl : a.p_xl, t.atoms.bg, { maxWidth: 600, diff --git a/src/components/dialogs/ReportDialog/index.tsx b/src/components/dialogs/ReportDialog/index.tsx index 9fcb4de911..b7f4851e15 100644 --- a/src/components/dialogs/ReportDialog/index.tsx +++ b/src/components/dialogs/ReportDialog/index.tsx @@ -1,9 +1,18 @@ import React from 'react' -import {View} from 'react-native' +import {View, Dimensions} from 'react-native' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {LABEL_GROUPS, LabelGroupDefinition} from '@atproto/api' +import {useSafeAreaInsets} from 'react-native-safe-area-context' +import {atoms as a, useTheme} from '#/alf' import {Text} from '#/components/Typography' import * as Dialog from '#/components/Dialog' import {GlobalDialogProps} from '#/components/dialogs' +import {Button, useButtonContext} from '#/components/Button' +import {Divider} from '#/components/Divider' +import {useLabelGroupStrings} from '#/lib/moderation' +import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron' export type ReportDialogProps = | { @@ -16,20 +25,138 @@ export type ReportDialogProps = did: string } -export function ReportDialog(props: GlobalDialogProps) { - const control = Dialog.useDialogControl() +function LabelGroupButton({labelGroup}: {labelGroup: string}) { + const t = useTheme() + const {hovered, focused, pressed} = useButtonContext() + const labelGroupStrings = useLabelGroupStrings() + const groupInfoStrings = labelGroupStrings[labelGroup] + const interacted = hovered || focused || pressed - const onClose = React.useCallback(() => { - props.cleanup() - }, [props]) + const styles = React.useMemo(() => { + return { + interacted: { + backgroundColor: t.palette.contrast_50, + }, + } + }, [t]) return ( - - - - hello {JSON.stringify(props)} + + + + {groupInfoStrings.name} + + + {groupInfoStrings.description} + + + + + + + + ) +} + +/** + * TODO copyright link out to DMCA + * TODO add "other" option + */ +export function ReportDialog({ + params, + cleanup, +}: GlobalDialogProps) { + const t = useTheme() + const {_} = useLingui() + const insets = useSafeAreaInsets() + const control = Dialog.useDialogControl() + const [_labelGroup, setLabelGroup] = React.useState('') + const labelGroupStrings = useLabelGroupStrings() + + // REQUIRED CLEANUP + const onClose = React.useCallback(() => cleanup(), [cleanup]) + + const i18n = React.useMemo(() => { + let title = _(msg`Report this post`) + let description = _(msg`Why should this post be reviewed?`) + + if (params.type === 'user') { + title = _(msg`Report this user`) + description = _(msg`Why should this user be reviewed?`) + } + + return { + title, + description, + } + }, [_, params.type]) + + const groups = React.useMemo< + [keyof typeof LABEL_GROUPS, LabelGroupDefinition][] + >(() => { + return Object.entries(LABEL_GROUPS).filter(([, def]) => def.configurable) + }, []) + + return ( + + + + + + + {i18n.title} + + {i18n.description} + + + + + + + {groups.map(([name, def]) => { + const groupStrings = labelGroupStrings[name] + return ( + + ) + })} + - + ) } diff --git a/src/components/dialogs/index.tsx b/src/components/dialogs/index.tsx index 5122703ccd..8118f5f5a1 100644 --- a/src/components/dialogs/index.tsx +++ b/src/components/dialogs/index.tsx @@ -92,7 +92,9 @@ export function GlobalDialog() { return React.useMemo( () => activeDialogs.map(({component: Comp, props, options}, i) => { - return + return ( + + ) }), [activeDialogs, cleanup], ) diff --git a/src/lib/build-flags.ts b/src/lib/build-flags.ts index f85cbd9f84..f5889e8347 100644 --- a/src/lib/build-flags.ts +++ b/src/lib/build-flags.ts @@ -1,3 +1,4 @@ export const LOGIN_INCLUDE_DEV_SERVERS = true export const PWI_ENABLED = true export const NEW_ONBOARDING_ENABLED = true +export const NEW_REPORT_DIALOG_ENABLED = true diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index eed7cd593c..edb21f2380 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -33,6 +33,7 @@ import {isWeb} from '#/platform/detection' import {richTextToString} from '#/lib/strings/rich-text-helpers' import {useOpenGlobalDialog} from '#/components/dialogs' import {ReportDialog} from '#/components/dialogs/ReportDialog' +import {NEW_REPORT_DIALOG_ENABLED} from '#/lib/build-flags' let PostDropdownBtn = ({ testID, @@ -212,12 +213,15 @@ let PostDropdownBtn = ({ hasSession && { label: _(msg`Report post`), onPress() { - openDialog(ReportDialog, {type: 'post', uri: postUri, cid: postCid}) - // openModal({ - // name: 'report', - // uri: postUri, - // cid: postCid, - // }) + if (NEW_REPORT_DIALOG_ENABLED) { + openDialog(ReportDialog, {type: 'post', uri: postUri, cid: postCid}) + } else { + openModal({ + name: 'report', + uri: postUri, + cid: postCid, + }) + } }, testID: 'postDropdownReportBtn', icon: {