import {LabelPreference} from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import React from 'react' import {View} from 'react-native' import Animated, {Easing, FadeIn, Layout} from 'react-native-reanimated' import {atoms as a, useTheme} from '#/alf' import * as ToggleButton from '#/components/forms/ToggleButton' import {Text} from '#/components/Typography' import { CONFIGURABLE_LABEL_GROUPS, ConfigurableLabelGroup, usePreferencesQuery, usePreferencesSetContentLabelMutation, } from '#/state/queries/preferences' export function ModerationOption({ labelGroup, isMounted, }: { labelGroup: ConfigurableLabelGroup isMounted: React.MutableRefObject }) { const {_} = useLingui() const t = useTheme() const groupInfo = CONFIGURABLE_LABEL_GROUPS[labelGroup] const {data: preferences} = usePreferencesQuery() const {mutate, variables} = usePreferencesSetContentLabelMutation() const visibility = variables?.visibility ?? preferences?.contentLabels?.[labelGroup] const onChange = React.useCallback( (vis: string[]) => { mutate({labelGroup, visibility: vis[0] as LabelPreference}) }, [mutate, labelGroup], ) const labels = { hide: _(msg`Hide`), warn: _(msg`Warn`), show: _(msg`Show`), } return ( {groupInfo.title} {groupInfo.subtitle} {labels.hide} {labels.warn} {labels.show} ) }