use thumbnails, improve perf significantly
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
import {Gesture, GestureDetector} from 'react-native-gesture-handler'
|
||||||
import {runOnJS} from 'react-native-reanimated'
|
import {runOnJS} from 'react-native-reanimated'
|
||||||
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
|
import {Image} from 'expo-image'
|
||||||
import {LinearGradient} from 'expo-linear-gradient'
|
import {LinearGradient} from 'expo-linear-gradient'
|
||||||
import {useVideoPlayer, VideoPlayer, VideoView} from 'expo-video'
|
import {useVideoPlayer, VideoPlayer, VideoView} from 'expo-video'
|
||||||
import {
|
import {
|
||||||
@@ -135,12 +136,11 @@ function YoloFeed() {
|
|||||||
player={player}
|
player={player}
|
||||||
post={post}
|
post={post}
|
||||||
embed={post.embed}
|
embed={post.embed}
|
||||||
loaded={
|
active={
|
||||||
isFocused &&
|
isFocused &&
|
||||||
Math.abs(index - currentIndex) < 2 &&
|
index === currentIndex &&
|
||||||
currentSource === post.embed.playlist
|
currentSource === post.embed.playlist
|
||||||
}
|
}
|
||||||
active={isFocused && index === currentIndex}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -248,13 +248,12 @@ function VibeItem({
|
|||||||
player,
|
player,
|
||||||
post,
|
post,
|
||||||
embed,
|
embed,
|
||||||
loaded,
|
active,
|
||||||
}: {
|
}: {
|
||||||
player: VideoPlayer
|
player: VideoPlayer
|
||||||
post: AppBskyFeedDefs.PostView
|
post: AppBskyFeedDefs.PostView
|
||||||
embed: AppBskyEmbedVideo.View
|
embed: AppBskyEmbedVideo.View
|
||||||
active: boolean
|
active: boolean
|
||||||
loaded: boolean
|
|
||||||
}) {
|
}) {
|
||||||
const {height, width} = useWindowDimensions()
|
const {height, width} = useWindowDimensions()
|
||||||
const insets = useSafeAreaInsets()
|
const insets = useSafeAreaInsets()
|
||||||
@@ -276,12 +275,31 @@ function VibeItem({
|
|||||||
width,
|
width,
|
||||||
}}>
|
}}>
|
||||||
<SafeAreaView edges={['left', 'right', 'bottom']} style={[a.flex_1]}>
|
<SafeAreaView edges={['left', 'right', 'bottom']} style={[a.flex_1]}>
|
||||||
{loaded && (
|
{active && (
|
||||||
<VideoView
|
<VideoView
|
||||||
style={[a.flex_1]}
|
style={[a.flex_1]}
|
||||||
player={player}
|
player={player}
|
||||||
nativeControls={false}
|
nativeControls={false}
|
||||||
contentFit={isCloseEnough ? 'cover' : 'contain'}
|
contentFit={isCloseEnough ? 'cover' : 'contain'}
|
||||||
|
accessibilityIgnoresInvertColors
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{embed.thumbnail && (
|
||||||
|
<Image
|
||||||
|
accessibilityIgnoresInvertColors
|
||||||
|
source={{uri: embed.thumbnail}}
|
||||||
|
style={[
|
||||||
|
a.flex_1,
|
||||||
|
a.absolute,
|
||||||
|
{
|
||||||
|
zIndex: -1,
|
||||||
|
top: 0,
|
||||||
|
left: insets.left,
|
||||||
|
right: insets.right,
|
||||||
|
bottom: insets.bottom,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
contentFit={isCloseEnough ? 'cover' : 'contain'}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<VibeOverlay player={player} post={post} />
|
<VibeOverlay player={player} post={post} />
|
||||||
|
|||||||
Reference in New Issue
Block a user