import React, {useState} from 'react' import {StyleSheet, TouchableOpacity, View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useModalControls} from '#/state/modals' import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {colors, s} from 'lib/styles' import {isWeb} from 'platform/detection' import {ScrollView} from 'view/com/modals/util' import {Button} from '../util/forms/Button' import {SelectableBtn} from '../util/forms/SelectableBtn' import {Text} from '../util/text/Text' const ADULT_CONTENT_LABELS = ['sexual', 'nudity', 'porn'] export const snapPoints = ['50%'] export function Component({ labels, hasMedia, onChange, }: { labels: string[] hasMedia: boolean onChange: (labels: string[]) => void }) { const pal = usePalette('default') const {closeModal} = useModalControls() const {isMobile} = useWebMediaQueries() const [selected, setSelected] = useState(labels) const {_} = useLingui() const toggleAdultLabel = (label: string) => { const hadLabel = selected.includes(label) const stripped = selected.filter(l => !ADULT_CONTENT_LABELS.includes(l)) const final = !hadLabel ? stripped.concat([label]) : stripped setSelected(final) onChange(final) } const removeAdultLabel = () => { const final = selected.filter(l => !ADULT_CONTENT_LABELS.includes(l)) setSelected(final) onChange(final) } const hasAdultSelection = selected.includes('sexual') || selected.includes('nudity') || selected.includes('porn') return ( Add a content warning Adult Content {hasAdultSelection ? ( ) : null} {hasMedia ? ( <> toggleAdultLabel('sexual')} accessibilityHint="" style={s.flex1} /> toggleAdultLabel('nudity')} accessibilityHint="" style={s.flex1} /> toggleAdultLabel('porn')} accessibilityHint="" style={s.flex1} /> {selected.includes('sexual') ? ( Pictures meant for adults. ) : selected.includes('nudity') ? ( Artistic or non-erotic nudity. ) : selected.includes('porn') ? ( Sexual activity or erotic nudity. ) : ( If none are selected, suitable for all ages. )} ) : ( Not Applicable. {' '} This warning is only available for posts with media attached. )} { closeModal() }} style={styles.btn} accessibilityRole="button" accessibilityLabel={_(msg`Confirm`)} accessibilityHint=""> Done ) } const styles = StyleSheet.create({ container: { flex: 1, paddingBottom: isWeb ? 0 : 40, }, titleSection: { paddingTop: isWeb ? 0 : 4, paddingBottom: isWeb ? 14 : 10, }, title: { textAlign: 'center', fontWeight: '600', marginBottom: 5, }, description: { textAlign: 'center', paddingHorizontal: 32, }, section: { borderTopWidth: 1, paddingVertical: 20, }, adultExplainer: { paddingLeft: 5, paddingTop: 10, }, btn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', borderRadius: 32, padding: 14, backgroundColor: colors.blue3, }, btnContainer: { paddingTop: 20, paddingHorizontal: 20, }, })