import React from 'react' import { StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle, } from 'react-native' import {ComAtprotoLabelDefs} from '@atproto/api' import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' import {Text} from '../text/Text' import {addStyle} from 'lib/styles' export function ContentHider({ testID, isMuted, labels, style, containerStyle, children, }: React.PropsWithChildren<{ testID?: string isMuted?: boolean labels: ComAtprotoLabelDefs.Label[] | undefined style?: StyleProp containerStyle?: StyleProp }>) { const pal = usePalette('default') const [override, setOverride] = React.useState(false) const store = useStores() const labelPref = store.preferences.getLabelPreference(labels) if (!isMuted && labelPref.pref === 'show') { return ( {children} ) } if (labelPref.pref === 'hide') { return null } return ( {isMuted ? ( <>Post from an account you muted. ) : ( <>Warning: {labelPref.desc.warning || labelPref.desc.title} )} setOverride(v => !v)}> {override ? 'Hide' : 'Show'} {override && ( {children} )} ) } const styles = StyleSheet.create({ container: { marginBottom: 10, borderWidth: 1, borderRadius: 12, }, description: { flexDirection: 'row', alignItems: 'center', paddingVertical: 14, paddingLeft: 14, paddingRight: 18, borderRadius: 12, }, descriptionOpen: { borderBottomLeftRadius: 0, borderBottomRightRadius: 0, }, icon: { marginRight: 10, }, showBtn: { marginLeft: 'auto', }, childrenContainer: { paddingHorizontal: 12, paddingTop: 8, }, child: {}, })