Add all groups

This commit is contained in:
Eric Bailey
2024-02-07 20:14:23 -06:00
parent e0061056dc
commit fabf6809fc
2 changed files with 23 additions and 21 deletions
@@ -3,23 +3,17 @@ import {View} from 'react-native'
import {useLingui} from '@lingui/react'
import {msg} from '@lingui/macro'
import {
CONFIGURABLE_LABEL_GROUPS,
ConfigurableLabelGroup,
} from '#/state/queries/preferences'
import {useLabelGroupStrings} from '#/lib/moderation'
import {useTheme, atoms as a} from '#/alf'
import {Text} from '#/components/Typography'
import * as ToggleButton from '#/components/forms/ToggleButton'
export function PreferenceRow({
labelGroup,
}: {
labelGroup: ConfigurableLabelGroup
}) {
export function PreferenceRow({labelGroup}: {labelGroup: string}) {
const t = useTheme()
const {_} = useLingui()
const groupInfo = CONFIGURABLE_LABEL_GROUPS[labelGroup]
const labelGroupStrings = useLabelGroupStrings()
const groupInfoStrings = labelGroupStrings[labelGroup]
const labels = {
hide: _(msg`Hide`),
@@ -38,15 +32,15 @@ export function PreferenceRow({
a.align_center,
]}>
<View style={[a.gap_xs, {width: '50%'}]}>
<Text style={[a.font_bold]}>{groupInfo.title}</Text>
<Text style={[a.font_bold]}>{groupInfoStrings.name}</Text>
<Text style={[t.atoms.text_contrast_700, a.leading_snug]}>
{groupInfo.subtitle}
{groupInfoStrings.description}
</Text>
</View>
<View style={[a.justify_center, {minHeight: 35}]}>
<ToggleButton.Group
label={_(
msg`Configure content filtering setting for category: ${groupInfo.title.toLowerCase()}`,
msg`Configure content filtering setting for category: ${groupInfoStrings.name.toLowerCase()}`,
)}
values={['warn']}
onChange={() => {}}>
+16 -8
View File
@@ -1,9 +1,10 @@
import React from 'react'
import {Dimensions, View} from 'react-native'
import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {AppBskyModerationDefs} from '@atproto/api'
import {AppBskyModerationDefs, LabelGroupDefinition} from '@atproto/api'
import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {LABEL_GROUPS} from '@atproto/api'
import {usePalette} from '#/lib/hooks/usePalette'
import {CommonNavigatorParams} from '#/lib/routes/types'
@@ -136,6 +137,11 @@ export function ProfileModserviceScreenInner({
const [likeUri, setLikeUri] = React.useState<string>(
modInfo.viewer?.like || '',
)
const groups = React.useMemo<
[keyof typeof LABEL_GROUPS, LabelGroupDefinition][]
>(() => {
return Object.entries(LABEL_GROUPS).filter(([, def]) => def.configurable)
}, [])
const isLiked = !!likeUri
// const isSaved = false // TODO
@@ -249,15 +255,17 @@ export function ProfileModserviceScreenInner({
</View>
<View style={[a.gap_md, a.mt_xl]}>
<Divider />
<PreferenceRow labelGroup="nsfw" />
<Divider />
<PreferenceRow labelGroup="nudity" />
<Divider />
<PreferenceRow labelGroup="suggestive" />
{groups.map(([name, def]) => {
return (
<React.Fragment key={def.id}>
<Divider />
<PreferenceRow labelGroup={name} />
</React.Fragment>
)
})}
</View>
<View style={{height: 20}} />
<View style={{height: 100}} />
</ScrollView>
)
}