diff options
Diffstat (limited to 'src/view/com/util/post-embeds/ExternalGifEmbed.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/ExternalGifEmbed.tsx | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx index b2720752c..1f966d710 100644 --- a/src/view/com/util/post-embeds/ExternalGifEmbed.tsx +++ b/src/view/com/util/post-embeds/ExternalGifEmbed.tsx @@ -5,19 +5,21 @@ import { LayoutChangeEvent, Pressable, StyleSheet, - View, } from 'react-native' import {Image, ImageLoadEventData} 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 {EmbedPlayerParams, getGifDims} from '#/lib/strings/embed-player' import {isIOS, isNative, isWeb} from '#/platform/detection' import {useExternalEmbedsPrefs} from '#/state/preferences' +import {atoms as a, useTheme} from '#/alf' import {useDialogControl} from '#/components/Dialog' import {EmbedConsentDialog} from '#/components/dialogs/EmbedConsent' +import {Fill} from '#/components/Fill' +import {MediaInsetBorder} from '#/components/MediaInsetBorder' +import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' export function ExternalGifEmbed({ link, @@ -26,6 +28,7 @@ export function ExternalGifEmbed({ link: AppBskyEmbedExternal.ViewExternal params: EmbedPlayerParams }) { + const t = useTheme() const externalEmbedsPrefs = useExternalEmbedsPrefs() const {_} = useLingui() @@ -113,26 +116,19 @@ export function ExternalGifEmbed({ <Pressable style={[ {height: imageDims.height}, - styles.topRadius, styles.gifContainer, + a.rounded_sm, + a.overflow_hidden, + { + borderBottomLeftRadius: 0, + borderBottomRightRadius: 0, + }, ]} onPress={onPlayPress} onLayout={onLayout} accessibilityRole="button" accessibilityHint={_(msg`Plays the GIF`)} accessibilityLabel={_(msg`Play ${link.title}`)}> - {(!isPrefetched || !isAnimating) && ( // If we have not loaded or are not animating, show the overlay - <View style={[styles.layer, styles.overlayLayer]}> - <View style={[styles.overlayContainer, styles.topRadius]}> - {!isAnimating || !isPlayerActive ? ( // Play button when not animating or not active - <FontAwesomeIcon icon="play" size={42} color="white" /> - ) : ( - // Activity indicator while gif loads - <ActivityIndicator size="large" color="white" /> - )} - </View> - </View> - )} <Image source={{ uri: @@ -150,6 +146,35 @@ export function ExternalGifEmbed({ accessibilityHint={link.title} cachePolicy={isIOS ? 'disk' : 'memory-disk'} // cant control playback with memory-disk on ios /> + + {(!isPrefetched || !isAnimating) && ( + <Fill style={[a.align_center, a.justify_center]}> + <Fill + style={[ + t.name === 'light' ? t.atoms.bg_contrast_975 : t.atoms.bg, + { + opacity: 0.3, + }, + ]} + /> + + {!isAnimating || !isPlayerActive ? ( // Play button when not animating or not active + <PlayButtonIcon /> + ) : ( + // Activity indicator while gif loads + <ActivityIndicator size="large" color="white" /> + )} + </Fill> + )} + <MediaInsetBorder + opaque + style={[ + { + borderBottomLeftRadius: 0, + borderBottomRightRadius: 0, + }, + ]} + /> </Pressable> </> ) @@ -171,7 +196,6 @@ const styles = StyleSheet.create({ flex: 1, justifyContent: 'center', alignItems: 'center', - backgroundColor: 'rgba(0,0,0,0.5)', }, overlayLayer: { zIndex: 2, |