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) --- .../com/util/post-embeds/ExternalPlayerEmbed.tsx | 86 ++++++++++++---------- 1 file changed, 46 insertions(+), 40 deletions(-) (limited to 'src/view/com/util/post-embeds/ExternalPlayerEmbed.tsx') diff --git a/src/view/com/util/post-embeds/ExternalPlayerEmbed.tsx b/src/view/com/util/post-embeds/ExternalPlayerEmbed.tsx index cf2db5b33..9fdede877 100644 --- a/src/view/com/util/post-embeds/ExternalPlayerEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalPlayerEmbed.tsx @@ -13,20 +13,23 @@ import Animated, { useAnimatedRef, useFrameCallback, } from 'react-native-reanimated' -import {Image} from 'expo-image' -import {WebView} from 'react-native-webview' import {useSafeAreaInsets} from 'react-native-safe-area-context' +import {WebView} from 'react-native-webview' +import {Image} from 'expo-image' +import {AppBskyEmbedExternal} from '@atproto/api' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' -import {AppBskyEmbedExternal} from '@atproto/api' -import {EmbedPlayerParams, getPlayerAspect} from 'lib/strings/embed-player' + +import {NavigationProp} from '#/lib/routes/types' +import {EmbedPlayerParams, getPlayerAspect} from '#/lib/strings/embed-player' +import {isNative} from '#/platform/detection' +import {useExternalEmbedsPrefs} from '#/state/preferences' +import {atoms as a} from '#/alf' +import {useDialogControl} from '#/components/Dialog' +import {EmbedConsentDialog} from '#/components/dialogs/EmbedConsent' import {EventStopper} from '../EventStopper' -import {isNative} from 'platform/detection' -import {NavigationProp} from 'lib/routes/types' -import {useExternalEmbedsPrefs} from 'state/preferences' -import {useModalControls} from 'state/modals' interface ShouldStartLoadRequest { url: string @@ -48,7 +51,7 @@ function PlaceholderOverlay({ if (isPlayerActive && !isLoading) return null return ( - + + { - setPlayerActive(true) - }, - }) + consentDialogControl.open() return } setPlayerActive(true) }, - [externalEmbedsPrefs, openModal, params.source], + [externalEmbedsPrefs, consentDialogControl, params.source], ) + const onAcceptConsent = React.useCallback(() => { + setPlayerActive(true) + }, []) + return ( - - {link.thumb && (!isPlayerActive || isLoading) && ( - - )} - + - - + + + {link.thumb && (!isPlayerActive || isLoading) && ( + + )} + + + + ) } @@ -226,13 +239,6 @@ const styles = StyleSheet.create({ borderTopLeftRadius: 6, borderTopRightRadius: 6, }, - layer: { - position: 'absolute', - top: 0, - left: 0, - right: 0, - bottom: 0, - }, overlayContainer: { flex: 1, justifyContent: 'center', -- cgit 1.4.1