From a49a5a351d2b58631d067c0524c5ebb097a3d5fe Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 9 Apr 2024 00:58:18 +0100 Subject: Use ALF for the embed consent modal (#3336) --- src/components/dialogs/EmbedConsent.tsx | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/components/dialogs/EmbedConsent.tsx (limited to 'src/components/dialogs/EmbedConsent.tsx') diff --git a/src/components/dialogs/EmbedConsent.tsx b/src/components/dialogs/EmbedConsent.tsx new file mode 100644 index 000000000..c3fefd9f0 --- /dev/null +++ b/src/components/dialogs/EmbedConsent.tsx @@ -0,0 +1,119 @@ +import React, {useCallback} from 'react' +import {View} from 'react-native' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import { + type EmbedPlayerSource, + embedPlayerSources, + externalEmbedLabels, +} from '#/lib/strings/embed-player' +import {useSetExternalEmbedPref} from '#/state/preferences' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' +import * as Dialog from '#/components/Dialog' +import {Button, ButtonText} from '../Button' +import {Text} from '../Typography' + +export function EmbedConsentDialog({ + control, + source, + onAccept, +}: { + control: Dialog.DialogControlProps + source: EmbedPlayerSource + onAccept: () => void +}) { + const {_} = useLingui() + const t = useTheme() + const setExternalEmbedPref = useSetExternalEmbedPref() + const {gtMobile} = useBreakpoints() + + const onShowAllPress = useCallback(() => { + for (const key of embedPlayerSources) { + setExternalEmbedPref(key, 'show') + } + onAccept() + control.close() + }, [control, onAccept, setExternalEmbedPref]) + + const onShowPress = useCallback(() => { + setExternalEmbedPref(source, 'show') + onAccept() + control.close() + }, [control, onAccept, setExternalEmbedPref, source]) + + const onHidePress = useCallback(() => { + setExternalEmbedPref(source, 'hide') + control.close() + }, [control, setExternalEmbedPref, source]) + + return ( + + + + + + + External Media + + + + + + This content is hosted by {externalEmbedLabels[source]}. Do you + want to enable external media? + + + + + + 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. + + + + + + + + + + + + ) +} -- cgit 1.4.1