From d22f047f2bd6d14f5c551f39a96ad3a2ded14fb6 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Mon, 25 Nov 2024 15:58:08 +0100 Subject: [PATCH] fix: controls safe areas --- app/(auth)/player/direct-player.tsx | 20 +++++------ app/(auth)/player/transcoding-player.tsx | 22 ++++-------- components/video-player/controls/Controls.tsx | 36 +++++++++++-------- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/app/(auth)/player/direct-player.tsx b/app/(auth)/player/direct-player.tsx index 638c0e7a..f5577887 100644 --- a/app/(auth)/player/direct-player.tsx +++ b/app/(auth)/player/direct-player.tsx @@ -35,6 +35,7 @@ import { useAtomValue } from "jotai"; import React, { useCallback, useMemo, useRef, useState } from "react"; import { Alert, Pressable, View } from "react-native"; import { useSharedValue } from "react-native-reanimated"; +import { SafeAreaView } from "react-native-safe-area-context"; export default function page() { const videoRef = useRef(null); @@ -398,19 +399,19 @@ export default function page() { ); return ( - + { // setShowControls(!showControls); }} - className="absolute z-0 h-full w-full" + style={{ + display: "flex", + width: "100%", + height: "100%", + position: "relative", + flexDirection: "column", + justifyContent: "center", + }} > - {videoRef.current && ( { ); return ( - + { - setShowControls(!showControls); + // setShowControls(!showControls); }} style={{ - flex: 1, - height: "100%", + display: "flex", width: "100%", - position: "absolute", - top: 0, - left: 0, - zIndex: 0, + height: "100%", + position: "relative", + flexDirection: "column", + justifyContent: "center", }} > {videoSource ? ( diff --git a/components/video-player/controls/Controls.tsx b/components/video-player/controls/Controls.tsx index c0388c51..0090fe63 100644 --- a/components/video-player/controls/Controls.tsx +++ b/components/video-player/controls/Controls.tsx @@ -26,7 +26,13 @@ import { import { Image } from "expo-image"; import { useRouter } from "expo-router"; import { useCallback, useEffect, useRef, useState } from "react"; -import { Platform, Pressable, TouchableOpacity, View } from "react-native"; +import { + Dimensions, + Platform, + Pressable, + TouchableOpacity, + View, +} from "react-native"; import { Slider } from "react-native-awesome-slider"; import { runOnJS, @@ -34,7 +40,10 @@ import { useAnimatedReaction, useSharedValue, } from "react-native-reanimated"; -import { useSafeAreaInsets } from "react-native-safe-area-context"; +import { + SafeAreaView, + useSafeAreaInsets, +} from "react-native-safe-area-context"; import { VideoRef } from "react-native-video"; import { ControlProvider } from "./contexts/ControlContext"; import { VideoProvider } from "./contexts/VideoContext"; @@ -306,14 +315,14 @@ export const Controls: React.FC = ({ mediaSource={mediaSource} isVideoLoaded={isVideoLoaded} > - = ({ }} style={{ position: "absolute", - top: 0, - left: 0, - width: "100%", - height: "100%", + width: Dimensions.get("window").width, + height: Dimensions.get("window").height, opacity: showControls ? 0.5 : 0, backgroundColor: "black", }} @@ -434,10 +441,9 @@ export const Controls: React.FC = ({ style={[ { position: "absolute", - width: "100%", - maxHeight: "100%", + right: 0, left: 0, - bottom: Platform.OS === "ios" ? insets.bottom : insets.bottom, + bottom: 0, opacity: showControls ? 1 : 0, }, ]} @@ -592,7 +598,7 @@ export const Controls: React.FC = ({ - + ); };