mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-03-06 01:36:17 +00:00
fix(types): resolve TypeScript errors in orientation handling
- Import OrientationLock and Orientation types from .tv.ts module - Add explicit type annotations to orientation event handlers - Change ScreenOrientationEnum to use Record<number, string> - Use OrientationLock enum type instead of runtime value This fixes ReactCodegen build failures caused by TypeScript errors.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
|
||||
import { OrientationLock } from "@/packages/expo-screen-orientation";
|
||||
import { Orientation } from "../packages/expo-screen-orientation.tv";
|
||||
import {
|
||||
Orientation,
|
||||
OrientationLock,
|
||||
} from "../packages/expo-screen-orientation.tv";
|
||||
|
||||
const orientationToOrientationLock = (
|
||||
orientation: Orientation,
|
||||
@@ -30,13 +32,15 @@ export const useOrientation = () => {
|
||||
if (Platform.isTV) return;
|
||||
|
||||
const orientationSubscription =
|
||||
ScreenOrientation.addOrientationChangeListener((event) => {
|
||||
setOrientation(
|
||||
orientationToOrientationLock(event.orientationInfo.orientation),
|
||||
);
|
||||
});
|
||||
ScreenOrientation.addOrientationChangeListener(
|
||||
(event: { orientationInfo: { orientation: Orientation } }) => {
|
||||
setOrientation(
|
||||
orientationToOrientationLock(event.orientationInfo.orientation),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ScreenOrientation.getOrientationAsync().then((orientation) => {
|
||||
ScreenOrientation.getOrientationAsync().then((orientation: Orientation) => {
|
||||
setOrientation(orientationToOrientationLock(orientation));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user