Files
discord-decomp/modules/video_calls/native/components/usePipDimensions.tsx
T
2026-11-01 12:12:55 +02:00

58 lines
1.7 KiB
TypeScript

// Metro module 10524 (f10525).
import { useMemo } from "react";
import { useIsViewingActivity } from "../../../activities/native/useIsViewingActivity";
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
import { OrientationType } from "../../../device/native/DeviceOrientation";
let c7066_4 = 0.5625;
export default function usePipDimensions({ channelId, forcedOrientation = null }) {
let c18108_0 = forcedOrientation;
const isViewingActivity = useIsViewingActivity({
channelId
});
const windowDimensions_native = useWindowDimensions_native();
const { width, height } = windowDimensions_native;
return useMemo(() => {
let height2, width2;
let r2 = width > height;
const r4 = c18108_0 === OrientationType.LANDSCAPE || (r2 ? c18108_0 !== OrientationType.PORTRAIT : r2);
L18: {
height2 = 96;
width2 = 96;
if (!isViewingActivity) {
if (!r2 && !r4) {
const r28 = Math.min(0.25 * height, 300);
width2 = r28 * c7066_4;
height2 = r28;
break L18;
}
if (!r2 && r4) {
const r36 = Math.min(0.5 * width, 400);
height2 = r36 * c7066_4;
width2 = r36;
break L18;
}
if (r2 && r4) {
const r52 = Math.min(0.25 * width, 400);
height2 = r52 * c7066_4;
width2 = r52;
break L18;
}
if (r2) {
r2 = !r4;
}
height2 = 1;
width2 = 1;
if (r2) {
const r44 = Math.min(0.5 * height, 300);
width2 = r44 * c7066_4;
height2 = r44;
}
}
}
return {
height: height2,
width: width2
};
}, [height, width, forcedOrientation, isViewingActivity]);
};