Skip to content

Commit 6382a91

Browse files
authored
[Video] Use same play button for gifs and videos (#5144)
1 parent 5f5c14d commit 6382a91

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

src/components/MediaPreview.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {Trans} from '@lingui/macro'
1111

1212
import {parseTenorGif} from '#/lib/strings/embed-player'
1313
import {atoms as a} from '#/alf'
14-
import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
1514
import {Text} from '#/components/Typography'
15+
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'
1616

1717
/**
1818
* Streamlined MediaPreview component which just handles images, gifs, and videos
@@ -111,6 +111,9 @@ export function ImageItem({
111111
export function GifItem({thumbnail, alt}: {thumbnail: string; alt?: string}) {
112112
return (
113113
<ImageItem thumbnail={thumbnail} alt={alt}>
114+
<View style={[a.absolute, a.inset_0, a.justify_center, a.align_center]}>
115+
<PlayButtonIcon size={24} />
116+
</View>
114117
<View style={styles.altContainer}>
115118
<Text style={styles.alt}>
116119
<Trans>GIF</Trans>
@@ -137,14 +140,14 @@ export function VideoItem({
137140
a.justify_center,
138141
a.align_center,
139142
]}>
140-
<PlayIcon size="xl" fill="white" />
143+
<PlayButtonIcon size={24} />
141144
</View>
142145
)
143146
}
144147
return (
145148
<ImageItem thumbnail={thumbnail} alt={alt}>
146149
<View style={[a.absolute, a.inset_0, a.justify_center, a.align_center]}>
147-
<PlayIcon size="xl" fill="white" />
150+
<PlayButtonIcon size={24} />
148151
</View>
149152
</ImageItem>
150153
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react'
2+
import {View} from 'react-native'
3+
4+
import {atoms as a, useTheme} from '#/alf'
5+
import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
6+
7+
export function PlayButtonIcon({size = 44}: {size?: number}) {
8+
const t = useTheme()
9+
10+
return (
11+
<View
12+
style={[
13+
a.rounded_full,
14+
a.align_center,
15+
a.justify_center,
16+
{
17+
backgroundColor: t.palette.primary_500,
18+
width: size + 16,
19+
height: size + 16,
20+
},
21+
]}>
22+
<PlayIcon height={size} width={size} style={{color: 'white'}} />
23+
</View>
24+
)
25+
}

src/view/com/util/post-embeds/GifEmbed.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
ViewStyle,
99
} from 'react-native'
1010
import {AppBskyEmbedExternal} from '@atproto/api'
11-
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
1211
import {msg, Trans} from '@lingui/macro'
1312
import {useLingui} from '@lingui/react'
1413

@@ -22,6 +21,7 @@ import {atoms as a, useTheme} from '#/alf'
2221
import {Loader} from '#/components/Loader'
2322
import * as Prompt from '#/components/Prompt'
2423
import {Text} from '#/components/Typography'
24+
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'
2525
import {GifView} from '../../../../../modules/expo-bluesky-gif-view'
2626
import {GifViewStateChangeEvent} from '../../../../../modules/expo-bluesky-gif-view/src/GifView.types'
2727

@@ -69,24 +69,7 @@ function PlaybackControls({
6969
</View>
7070
</View>
7171
) : !isPlaying ? (
72-
<View
73-
style={[
74-
a.rounded_full,
75-
a.align_center,
76-
a.justify_center,
77-
{
78-
backgroundColor: t.palette.primary_500,
79-
width: 60,
80-
height: 60,
81-
},
82-
]}>
83-
<FontAwesomeIcon
84-
icon="play"
85-
size={42}
86-
color="white"
87-
style={{marginLeft: 8}}
88-
/>
89-
</View>
72+
<PlayButtonIcon />
9073
) : undefined}
9174
</Pressable>
9275
)
@@ -155,7 +138,6 @@ export function GifEmbed({
155138
accessibilityHint={_(msg`Animated GIF`)}
156139
accessibilityLabel={parsedAlt.alt}
157140
/>
158-
159141
{!hideAlt && parsedAlt.isPreferred && <AltText text={parsedAlt.alt} />}
160142
</View>
161143
</View>
@@ -183,7 +165,6 @@ function AltText({text}: {text: string}) {
183165
<Trans>ALT</Trans>
184166
</Text>
185167
</TouchableOpacity>
186-
187168
<Prompt.Outer control={control}>
188169
<Prompt.TitleText>
189170
<Trans>Alt Text</Trans>

src/view/com/util/post-embeds/VideoEmbed.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ import {useLingui} from '@lingui/react'
88
import {clamp} from '#/lib/numbers'
99
import {useGate} from '#/lib/statsig/statsig'
1010
import {VideoEmbedInnerNative} from '#/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative'
11-
import {atoms as a, useTheme} from '#/alf'
11+
import {atoms as a} from '#/alf'
1212
import {Button} from '#/components/Button'
13-
import {Play_Filled_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
13+
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'
1414
import {VisibilityView} from '../../../../../modules/expo-bluesky-swiss-army'
1515
import {ErrorBoundary} from '../ErrorBoundary'
1616
import {useActiveVideoNative} from './ActiveVideoNativeContext'
1717
import * as VideoFallback from './VideoEmbedInner/VideoFallback'
1818

1919
export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
2020
const {_} = useLingui()
21-
const t = useTheme()
2221
const {activeSource, activeViewId, setActiveSource, player} =
2322
useActiveVideoNative()
2423
const viewId = useId()
@@ -95,7 +94,7 @@ export function VideoEmbed({embed}: {embed: AppBskyEmbedVideo.View}) {
9594
}}
9695
label={_(msg`Play video`)}
9796
color="secondary">
98-
<PlayIcon width={48} fill={t.palette.white} />
97+
<PlayButtonIcon />
9998
</Button>
10099
</>
101100
)}

0 commit comments

Comments
 (0)