mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
31 lines
848 B
TypeScript
31 lines
848 B
TypeScript
import { useSettings } from "@/utils/atoms/settings";
|
|
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
|
|
import { useEffect } from "react";
|
|
import { Platform } from "react-native";
|
|
|
|
export const useOrientationSettings = () => {
|
|
if (Platform.isTV) return;
|
|
|
|
const [settings] = useSettings();
|
|
|
|
useEffect(() => {
|
|
if (settings?.autoRotate) {
|
|
ScreenOrientation.lockAsync(
|
|
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
|
|
);
|
|
} else if (settings?.defaultVideoOrientation) {
|
|
ScreenOrientation.lockAsync(settings.defaultVideoOrientation);
|
|
}
|
|
|
|
return () => {
|
|
if (settings?.autoRotate) {
|
|
ScreenOrientation.unlockAsync();
|
|
} else {
|
|
ScreenOrientation.lockAsync(
|
|
ScreenOrientation.OrientationLock.PORTRAIT_UP
|
|
);
|
|
}
|
|
};
|
|
}, [settings]);
|
|
};
|