import React, {Fragment} from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types' import { EmbedPlayerSource, externalEmbedLabels, } from '#/lib/strings/embed-player' import { useExternalEmbedsPrefs, useSetExternalEmbedPref, } from '#/state/preferences' import {atoms as a, native} from '#/alf' import {Admonition} from '#/components/Admonition' import * as Toggle from '#/components/forms/Toggle' import * as Layout from '#/components/Layout' import * as SettingsList from './components/SettingsList' type Props = NativeStackScreenProps< CommonNavigatorParams, 'PreferencesExternalEmbeds' > export function ExternalMediaPreferencesScreen({}: Props) { const {_} = useLingui() return ( External media may allow websites to collect information about you and your device. No information is sent or requested until you press the "play" button. Enable media players for {native()} {Object.entries(externalEmbedLabels) // TODO: Remove special case when we disable the old integration. .filter(([key]) => key !== 'tenor') .map(([key, label]) => ( {native()} ))} ) } function PrefSelector({ source, label, }: { source: EmbedPlayerSource label: string }) { const setExternalEmbedPref = useSetExternalEmbedPref() const sources = useExternalEmbedsPrefs() return ( setExternalEmbedPref( source, sources?.[source] === 'show' ? 'hide' : 'show', ) } style={[ a.flex_1, a.py_md, native([a.justify_between, a.flex_row_reverse]), ]}> {label} ) }