mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
28 lines
766 B
TypeScript
28 lines
766 B
TypeScript
import { useSettings } from "@/utils/atoms/settings";
|
|
import * as ScreenOrientation from "expo-screen-orientation";
|
|
import { useEffect } from "react";
|
|
|
|
export const useOrientationSettings = () => {
|
|
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]);
|
|
};
|