This commit is contained in:
Eric Bailey
2024-02-08 18:52:05 -06:00
parent e45cc6f774
commit 9b5f80be7e
+27 -5
View File
@@ -9,7 +9,12 @@ import {atoms as a, useTheme, tokens, native} from '#/alf'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import * as Dialog from '#/components/Dialog' import * as Dialog from '#/components/Dialog'
import {GlobalDialogProps} from '#/components/dialogs' import {GlobalDialogProps} from '#/components/dialogs'
import {Button, ButtonIcon, useButtonContext} from '#/components/Button' import {
Button,
ButtonIcon,
ButtonText,
useButtonContext,
} from '#/components/Button'
import {Divider} from '#/components/Divider' import {Divider} from '#/components/Divider'
import {useLabelGroupStrings} from '#/lib/moderation' import {useLabelGroupStrings} from '#/lib/moderation'
import { import {
@@ -22,6 +27,8 @@ import * as Toggle from '#/components/forms/Toggle'
import {GradientFill} from '#/components/GradientFill' import {GradientFill} from '#/components/GradientFill'
import * as TextField from '#/components/forms/TextField' import * as TextField from '#/components/forms/TextField'
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
import {Loader} from '#/components/Loader'
import * as Toast from '#/view/com/util/Toast'
export type ReportDialogProps = export type ReportDialogProps =
| { | {
@@ -139,9 +146,11 @@ function ModServiceToggle({title}: {title: string}) {
function SubmitView({ function SubmitView({
selectedLabelGroup, selectedLabelGroup,
goBack, goBack,
onSubmitComplete,
}: { }: {
selectedLabelGroup: string selectedLabelGroup: string
goBack: () => void goBack: () => void
onSubmitComplete: () => void
}) { }) {
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
@@ -149,6 +158,17 @@ function SubmitView({
const groupInfoStrings = labelGroupStrings[selectedLabelGroup] const groupInfoStrings = labelGroupStrings[selectedLabelGroup]
const [selectedServices, setSelectedServices] = React.useState<string[]>([]) const [selectedServices, setSelectedServices] = React.useState<string[]>([])
const [details, setDetails] = React.useState<string>('') const [details, setDetails] = React.useState<string>('')
const [submitting, setSubmitting] = React.useState<boolean>(false)
const submit = React.useCallback(async () => {
setSubmitting(true)
await new Promise(resolve => setTimeout(resolve, 1000))
setSubmitting(false)
Toast.show(`Thank you. Your report has been sent.`)
onSubmitComplete()
}, [onSubmitComplete])
return ( return (
<View style={[a.gap_2xl]}> <View style={[a.gap_2xl]}>
@@ -242,8 +262,10 @@ function SubmitView({
size="large" size="large"
variant="gradient" variant="gradient"
color="gradient_midnight" color="gradient_midnight"
label={_(msg`Submit`)}> label={_(msg`Submit`)}
Submit onPress={submit}>
<ButtonText>Submit</ButtonText>
{submitting && <ButtonIcon icon={Loader} />}
</Button> </Button>
</View> </View>
</View> </View>
@@ -262,8 +284,7 @@ export function ReportDialog({
const {_} = useLingui() const {_} = useLingui()
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
const control = Dialog.useDialogControl() const control = Dialog.useDialogControl()
const [selectedLabelGroup, setSelectedLabelGroup] = const [selectedLabelGroup, setSelectedLabelGroup] = React.useState<string>('')
React.useState<string>('nudity')
const labelGroupStrings = useLabelGroupStrings() const labelGroupStrings = useLabelGroupStrings()
// REQUIRED CLEANUP // REQUIRED CLEANUP
@@ -307,6 +328,7 @@ export function ReportDialog({
<SubmitView <SubmitView
selectedLabelGroup={selectedLabelGroup} selectedLabelGroup={selectedLabelGroup}
goBack={() => setSelectedLabelGroup('')} goBack={() => setSelectedLabelGroup('')}
onSubmitComplete={control.close}
/> />
) : ( ) : (
<View style={[a.gap_lg]}> <View style={[a.gap_lg]}>