diff --git a/app/(auth)/play-offline-video.tsx b/app/(auth)/play-offline-video.tsx index b4310d31..5caa17b5 100644 --- a/app/(auth)/play-offline-video.tsx +++ b/app/(auth)/play-offline-video.tsx @@ -2,7 +2,6 @@ import { Controls } from "@/components/video-player/Controls"; import { useAndroidNavigationBar } from "@/hooks/useAndroidNavigationBar"; import { useOrientation } from "@/hooks/useOrientation"; import { useOrientationSettings } from "@/hooks/useOrientationSettings"; -import useScreenDimensions from "@/hooks/useScreenDimensions"; import { apiAtom } from "@/providers/JellyfinProvider"; import { PlaybackType, @@ -14,7 +13,7 @@ import * as Haptics from "expo-haptics"; import { useFocusEffect } from "expo-router"; import { useAtomValue } from "jotai"; import React, { useCallback, useMemo, useRef, useState } from "react"; -import { Pressable, StatusBar, View } from "react-native"; +import { Pressable, StatusBar, useWindowDimensions, View } from "react-native"; import { useSharedValue } from "react-native-reanimated"; import Video, { OnProgressData, VideoRef } from "react-native-video"; @@ -26,7 +25,7 @@ export default function page() { const videoSource = useVideoSource(playSettings, api, playUrl); const firstTime = useRef(true); - const screenDimensions = useScreenDimensions(); + const dimensions = useWindowDimensions(); useOrientation(); useOrientationSettings(); useAndroidNavigationBar(); @@ -82,8 +81,8 @@ export default function page() { return ( @@ -232,15 +231,18 @@ export default function page() { position: "absolute", top: 0, left: 0, - width: screenDimensions.width, - height: screenDimensions.height, + width: dimensions.width, + height: dimensions.height, zIndex: 0, }} > = ({ - = ({ > - + - = ({ maxHeight: windowDimensions.height, left: insets.left, bottom: Platform.OS === "ios" ? insets.bottom : insets.bottom, + opacity: showControls ? 1 : 0, }, - animatedBottomStyles, ]} pointerEvents={showControls ? "auto" : "none"} className={`flex flex-col p-4 `} @@ -529,7 +490,7 @@ export const Controls: React.FC = ({ - + ); }; diff --git a/hooks/useScreenDimensions.ts b/hooks/useScreenDimensions.ts deleted file mode 100644 index 22fa33ff..00000000 --- a/hooks/useScreenDimensions.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { useState, useEffect } from "react"; -import { Dimensions, ScaledSize } from "react-native"; - -const useScreenDimensions = (): ScaledSize => { - const [screenDimensions, setScreenDimensions] = useState( - Dimensions.get("screen") - ); - - useEffect(() => { - const updateDimensions = () => { - setScreenDimensions(Dimensions.get("screen")); - }; - - const dimensionsListener = Dimensions.addEventListener( - "change", - updateDimensions - ); - - return () => { - dimensionsListener.remove(); - }; - }, []); - - return screenDimensions; -}; - -export default useScreenDimensions; diff --git a/utils/time.ts b/utils/time.ts index 80b44cf0..8c541629 100644 --- a/utils/time.ts +++ b/utils/time.ts @@ -16,7 +16,8 @@ export const runtimeTicksToMinutes = ( const hours = Math.floor(ticks / ticksPerHour); const minutes = Math.floor((ticks % ticksPerHour) / ticksPerMinute); - return `${hours}h ${minutes}m`; + if (hours > 0) return `${hours}h ${minutes}m`; + else return `${minutes}m`; }; export const runtimeTicksToSeconds = (