fix: orientation lock being activated even when auto rotate is on

This commit is contained in:
Fredrik Burmester
2025-03-07 07:53:50 +01:00
parent 4b8e8cddb5
commit 3d7889e19a

View File

@@ -1,30 +1,30 @@
import { Stack } from "expo-router";
import React, { useEffect } from "react";
import { SystemBars } from "react-native-edge-to-edge";
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
import { useSettings } from "@/utils/atoms/settings";
import { Stack } from "expo-router";
import React, { useLayoutEffect } from "react";
import { Platform } from "react-native";
import { SystemBars } from "react-native-edge-to-edge";
export default function Layout() {
const [settings] = useSettings();
useEffect(() => {
useLayoutEffect(() => {
if (Platform.isTV) return;
if (settings.defaultVideoOrientation) {
if (!settings.followDeviceOrientation && settings.defaultVideoOrientation) {
ScreenOrientation.lockAsync(settings.defaultVideoOrientation);
}
return () => {
if (Platform.isTV) return;
if (settings.autoRotate === true) {
if (settings.followDeviceOrientation === true) {
ScreenOrientation.unlockAsync();
} else {
ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP);
}
};
}, [settings.defaultVideoOrientation, settings.autoRotate]);
}, [settings.autoDownload, settings.defaultVideoOrientation]);
return (
<>