From 6382a91fb0de911a7f99f5eaa17ed5c050fb7905 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 4 Sep 2024 10:59:06 -0700 Subject: [PATCH] [Video] Use same play button for gifs and videos (#5144) --- src/components/MediaPreview.tsx | 9 ++++--- src/components/video/PlayButtonIcon.tsx | 25 ++++++++++++++++++++ src/view/com/util/post-embeds/GifEmbed.tsx | 23 ++---------------- src/view/com/util/post-embeds/VideoEmbed.tsx | 7 +++--- 4 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 src/components/video/PlayButtonIcon.tsx diff --git a/src/components/MediaPreview.tsx b/src/components/MediaPreview.tsx index 17bae55b..7d7cb2b4 100644 --- a/src/components/MediaPreview.tsx +++ b/src/components/MediaPreview.tsx @@ -11,8 +11,8 @@ import {Trans} from '@lingui/macro' import {parseTenorGif} from '#/lib/strings/embed-player' import {atoms as a} from '#/alf' -import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play' import {Text} from '#/components/Typography' +import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' /** * Streamlined MediaPreview component which just handles images, gifs, and videos @@ -111,6 +111,9 @@ export function ImageItem({ export function GifItem({thumbnail, alt}: {thumbnail: string; alt?: string}) { return ( + + + GIF @@ -137,14 +140,14 @@ export function VideoItem({ a.justify_center, a.align_center, ]}> - + ) } return ( - + ) diff --git a/src/components/video/PlayButtonIcon.tsx b/src/components/video/PlayButtonIcon.tsx new file mode 100644 index 00000000..5415084f --- /dev/null +++ b/src/components/video/PlayButtonIcon.tsx @@ -0,0 +1,25 @@ +import React from 'react' +import {View} from 'react-native' + +import {atoms as a, useTheme} from '#/alf' +import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play' + +export function PlayButtonIcon({size = 44}: {size?: number}) { + const t = useTheme() + + return ( + + + + ) +} diff --git a/src/view/com/util/post-embeds/GifEmbed.tsx b/src/view/com/util/post-embeds/GifEmbed.tsx index 31c4419b..5b6e1c9d 100644 --- a/src/view/com/util/post-embeds/GifEmbed.tsx +++ b/src/view/com/util/post-embeds/GifEmbed.tsx @@ -8,7 +8,6 @@ import { ViewStyle, } from 'react-native' import {AppBskyEmbedExternal} from '@atproto/api' -import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -22,6 +21,7 @@ import {atoms as a, useTheme} from '#/alf' import {Loader} from '#/components/Loader' import * as Prompt from '#/components/Prompt' import {Text} from '#/components/Typography' +import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' import {GifView} from '../../../../../modules/expo-bluesky-gif-view' import {GifViewStateChangeEvent} from '../../../../../modules/expo-bluesky-gif-view/src/GifView.types' @@ -69,24 +69,7 @@ function PlaybackControls({ ) : !isPlaying ? ( - - - + ) : undefined} ) @@ -155,7 +138,6 @@ export function GifEmbed({ accessibilityHint={_(msg`Animated GIF`)} accessibilityLabel={parsedAlt.alt} /> - {!hideAlt && parsedAlt.isPreferred && } @@ -183,7 +165,6 @@ function AltText({text}: {text: string}) { ALT - Alt Text diff --git a/src/view/com/util/post-embeds/VideoEmbed.tsx b/src/view/com/util/post-embeds/VideoEmbed.tsx index 988ba573..d8410951 100644 --- a/src/view/com/util/post-embeds/VideoEmbed.tsx +++ b/src/view/com/util/post-embeds/VideoEmbed.tsx @@ -8,9 +8,9 @@ import {useLingui} from '@lingui/react' import {clamp} from '#/lib/numbers' import {useGate} from '#/lib/statsig/statsig' import {VideoEmbedInnerNative} from '#/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a} from '#/alf' import {Button} from '#/components/Button' -import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play' +import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' import {VisibilityView} from '../../../../../modules/expo-bluesky-swiss-army' import {ErrorBoundary} from '../ErrorBoundary' import {useActiveVideoNative} from './ActiveVideoNativeContext' @@ -18,7 +18,6 @@ import * as VideoFallback from './VideoEmbedInner/VideoFallback' export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) { const {_} = useLingui() - const t = useTheme() const {activeSource, activeViewId, setActiveSource, player} = useActiveVideoNative() const viewId = useId() @@ -95,7 +94,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) { }} label={_(msg`Play video`)} color="secondary"> - + )}