From 9bf91ce316e875e5000ba535490d98743bac519d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 15 Jan 2025 22:45:27 +0000 Subject: [PATCH] rm blurview, cover for tall videos --- src/screens/Feeds/VibeScreen.tsx | 44 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/screens/Feeds/VibeScreen.tsx b/src/screens/Feeds/VibeScreen.tsx index 27a35c1edc..b80901be38 100644 --- a/src/screens/Feeds/VibeScreen.tsx +++ b/src/screens/Feeds/VibeScreen.tsx @@ -11,7 +11,6 @@ import {Gesture, GestureDetector} from 'react-native-gesture-handler' import {runOnJS} from 'react-native-reanimated' import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context' import {useEvent} from 'expo' -import {BlurView} from 'expo-blur' import {LinearGradient} from 'expo-linear-gradient' import {useVideoPlayer, VideoPlayer, VideoView} from 'expo-video' import { @@ -52,7 +51,6 @@ import {Text} from '#/components/Typography' type Props = NativeStackScreenProps export function VibeScreen({}: Props) { const {top} = useSafeAreaInsets() - const [headerHeight, setHeaderHeight] = useState(0) const setMinShellMode = useSetMinimalShellMode() useFocusEffect( @@ -69,18 +67,13 @@ export function VibeScreen({}: Props) { return ( - - setHeaderHeight(nativeEvent.layout.height) - }> - + ]}> + @@ -90,14 +83,14 @@ export function VibeScreen({}: Props) { - - + + ) } -function YoloFeed({headerHeight}: {headerHeight: number}) { +function YoloFeed() { const isFocused = useIsFocused() const { data, @@ -140,11 +133,10 @@ function YoloFeed({headerHeight}: {headerHeight: number}) { embed={post.embed} loaded={isFocused && Math.abs(index - currentIndex) < 2} active={isFocused && index === currentIndex} - headerHeight={headerHeight} /> ) }, - [player1, player2, player3, currentIndex, headerHeight, isFocused], + [player1, player2, player3, currentIndex, isFocused], ) const onViewableItemsChanged = useCallback( @@ -193,16 +185,15 @@ function VibeItem({ embed, active, loaded, - headerHeight, }: { player: VideoPlayer post: AppBskyFeedDefs.PostView embed: AppBskyEmbedVideo.View active: boolean loaded: boolean - headerHeight: number }) { const {height, width} = useWindowDimensions() + const insets = useSafeAreaInsets() const source = embed.playlist const sourceChangeEvent = useEvent(player, 'sourceChange') as { // incorrect types @@ -214,7 +205,6 @@ function VibeItem({ // videos have a chance to preload const maybePlay = useNonReactiveCallback(() => { if (active && !player.playing) { - console.log('play (nonreactive)') player.play() } }) @@ -234,7 +224,6 @@ function VibeItem({ useEffect(() => { if (active) { - console.log('play (effect)') player.play() } else { // should be a cleanup function, but that causes a crash @@ -242,20 +231,29 @@ function VibeItem({ } }, [active, player]) + const screenAspectRatio = + (width - insets.left - insets.right) / (height - insets.bottom) + + const videoAspectRatio = + (embed.aspectRatio?.width ?? 1) / (embed.aspectRatio?.height ?? 1) + + // if the video is either taller, on only 20% shorter than the screen, + // set the video to be cover rather than contain + const isCloseEnough = videoAspectRatio < screenAspectRatio * 1.2 + return ( - - {active && ( + + {loaded && ( )}