mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-03-23 01:36:25 +00:00
Working
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { OrientationChangeEvent } from "expo-screen-orientation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import {
|
||||
addOrientationChangeListener,
|
||||
@@ -53,27 +53,28 @@ export const useOrientation = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const lockOrientation = async (
|
||||
lock: (typeof OrientationLock)[keyof typeof OrientationLock],
|
||||
) => {
|
||||
if (Platform.isTV) return;
|
||||
const lockOrientation = useCallback(
|
||||
async (lock: (typeof OrientationLock)[keyof typeof OrientationLock]) => {
|
||||
if (Platform.isTV) return;
|
||||
|
||||
if (lock === OrientationLock.DEFAULT) {
|
||||
await unlockAsync();
|
||||
} else {
|
||||
await lockAsync(lock);
|
||||
}
|
||||
};
|
||||
if (lock === OrientationLock.DEFAULT) {
|
||||
await unlockAsync();
|
||||
} else {
|
||||
await lockAsync(lock);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const unlockOrientationFn = async () => {
|
||||
const unlockOrientation = useCallback(async () => {
|
||||
if (Platform.isTV) return;
|
||||
await unlockAsync();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return {
|
||||
orientation,
|
||||
setOrientation,
|
||||
lockOrientation,
|
||||
unlockOrientation: unlockOrientationFn,
|
||||
unlockOrientation,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user