175 lines
6.7 KiB
TypeScript
175 lines
6.7 KiB
TypeScript
// Metro module 16003 (f16004).
|
|
import { useContext, useMemo } from "react";
|
|
import MediaEngineStore from "../../../../stores/MediaEngineStore";
|
|
import { CONTROLS_BUTTON_SIZE_LARGE, CONTROLS_BUTTON_SIZE_NORMAL } from "./VoicePanelControlsConstants";
|
|
import { InputModes } from "../../../../Constants";
|
|
import { MicButton, PTTButton } from "./buttons/VoicePanelMicButton";
|
|
import VoicePanelConnectButton from "./buttons/VoicePanelConnectButton";
|
|
import VoicePanelChatButton from "./buttons/VoicePanelChatButton";
|
|
import VoicePanelDisconnectCancelButton from "./buttons/VoicePanelDisconnectCancelButton";
|
|
import VoicePanelVideoButton from "./buttons/VoicePanelVideoButton";
|
|
import VoicePanelSoundboardButton from "./buttons/VoicePanelSoundboardButton";
|
|
import VoicePanelScreenshareButton from "./buttons/VoicePanelScreenshareButton";
|
|
import VoicePanelDrawerToggleButton from "./buttons/VoicePanelDrawerToggleButton";
|
|
import MobileGoLiveEntrypointExperiment, { MobileGoLiveEntrypointTreatment } from "../../../go_live/MobileGoLiveEntrypointExperiment";
|
|
import { isMetaQuest } from "../../../device/MetaQuestUtils.android";
|
|
import VoicePanelStateContext from "../VoicePanelStateContext";
|
|
import useIsConnectedToVoiceChannel from "../hooks/useIsConnectedToVoiceChannel";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { useDerivedValue } from "../../../reanimated/ReanimatedRexport";
|
|
import * as _VoicePanelControlsUtils from "../utils/VoicePanelControlsUtils";
|
|
import useStateFromSharedValue from "../../../reanimated/native/useStateFromSharedValue";
|
|
let __initData;
|
|
let c11471_9 = {
|
|
mic: (a0, a1) => <MicButton key={a0} {...a1} />,
|
|
ptt: (a0, a1) => <PTTButton key={a0} {...a1} />,
|
|
micConnected: (a0, a1) => <MicButton key={a0} {...a1} />,
|
|
connect: (a0, a1) => <VoicePanelConnectButton key={a0} {...a1} />,
|
|
chat: (a0, a1) => <VoicePanelChatButton key={a0} {...a1} />,
|
|
disconnectCancel: (a0, a1) => <VoicePanelDisconnectCancelButton key={a0} {...a1} />,
|
|
video: (a0, a1) => <VoicePanelVideoButton key={a0} {...a1} />,
|
|
soundboard: (a0, a1) => <VoicePanelSoundboardButton key={a0} {...a1} />,
|
|
screenshare: (a0, a1) => <VoicePanelScreenshareButton key={a0} {...a1} />,
|
|
drawerToggle: (a0, a1) => <VoicePanelDrawerToggleButton key={a0} {...a1} />
|
|
};
|
|
__initData = {
|
|
code: "function useControlsButtonsTsx1(){const{getControlsDefaultWidth,windowDimensions,safeArea}=this.__closure;return getControlsDefaultWidth(windowDimensions.get().width,safeArea.get().left,safeArea.get().right);}"
|
|
};
|
|
export default function useControlsButtons() {
|
|
let c22710_5;
|
|
const context = useContext(VoicePanelStateContext);
|
|
const { channelId, windowDimensions, safeArea } = context;
|
|
const isConnectedToVoiceChannel = useIsConnectedToVoiceChannel(channelId);
|
|
let c22710_2 = isConnectedToVoiceChannel;
|
|
const treatment = MobileGoLiveEntrypointExperiment.useConfig({
|
|
location: "VoicePanelControlButtons"
|
|
}).treatment;
|
|
const stateFromStores = useStateFromStores([MediaEngineStore], () => MediaEngineStore.getMode() === InputModes.PUSH_TO_TALK);
|
|
const r36 = () => _VoicePanelControlsUtils.getControlsDefaultWidth(windowDimensions.get().width, safeArea.get().left, safeArea.get().right);
|
|
r36.__closure = {
|
|
getControlsDefaultWidth: _VoicePanelControlsUtils.getControlsDefaultWidth,
|
|
windowDimensions,
|
|
safeArea
|
|
};
|
|
r36.__workletHash = 16456936876254;
|
|
r36.__initData = __initData;
|
|
const stateFromSharedValue = useStateFromSharedValue(useDerivedValue(r36));
|
|
c22710_5 = stateFromSharedValue;
|
|
return useMemo(() => {
|
|
let c28205_0 = false;
|
|
let c28205_1 = 0;
|
|
const r36 = (function getButtons(a0, a1, a2) {
|
|
const r1 = [];
|
|
if (a0) {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-video",
|
|
render: c11471_9.video
|
|
});
|
|
if (!a1) {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-mic",
|
|
render: c11471_9.micConnected
|
|
});
|
|
}
|
|
if (a2 === MobileGoLiveEntrypointTreatment.SCREENSHARE_REPLACES_CHAT) {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-screenshare",
|
|
render: c11471_9.screenshare
|
|
});
|
|
} else {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-chat",
|
|
render: c11471_9.chat
|
|
});
|
|
}
|
|
if (a1) {
|
|
r1.push({
|
|
type: "icon-large",
|
|
key: "connected-ptt",
|
|
render: c11471_9.ptt
|
|
});
|
|
}
|
|
if (a2 === MobileGoLiveEntrypointTreatment.SCREENSHARE_REPLACES_SOUNDBOARD) {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-screenshare",
|
|
render: c11471_9.screenshare
|
|
});
|
|
} else {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-soundboard",
|
|
render: c11471_9.soundboard
|
|
});
|
|
}
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "connected-disconnect",
|
|
render: c11471_9.disconnectCancel
|
|
});
|
|
} else {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "disconnected-mute",
|
|
render: c11471_9.mic
|
|
});
|
|
r1.push({
|
|
type: "label",
|
|
key: "disconnected-connect",
|
|
render: c11471_9.connect
|
|
});
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "disconnected-chat",
|
|
render: c11471_9.chat
|
|
});
|
|
}
|
|
if (isMetaQuest()) {
|
|
r1.push({
|
|
type: "icon-normal",
|
|
key: "drawer-toggle",
|
|
render: c11471_9.drawerToggle
|
|
});
|
|
}
|
|
return r1;
|
|
})(c22710_2, stateFromStores, treatment).map((item) => {
|
|
if (item.type === "label") {
|
|
c28205_0 = true;
|
|
}
|
|
let height = CONTROLS_BUTTON_SIZE_NORMAL;
|
|
if (item.type === "icon-large") {
|
|
c28205_1 = c28205_1 + 1;
|
|
height = CONTROLS_BUTTON_SIZE_LARGE;
|
|
}
|
|
return {
|
|
...item,
|
|
height,
|
|
width: item.type !== "label" ? height : -1,
|
|
x: 0,
|
|
y: 0
|
|
};
|
|
});
|
|
const r7 = c28205_0 ? 16 : (c22710_5 - c28205_1 * CONTROLS_BUTTON_SIZE_LARGE - (r36.length - c28205_1) * CONTROLS_BUTTON_SIZE_NORMAL - 32) / (r36.length - 1);
|
|
let r55 = 16;
|
|
for (const item of r36) {
|
|
const width = item.width;
|
|
let r65 = width;
|
|
if (width === -1) {
|
|
const width2 = c22710_5 - (32 + (r36.length - 1) * CONTROLS_BUTTON_SIZE_NORMAL + (r36.length - 1) * r7);
|
|
r65 = width2;
|
|
item.width = width2;
|
|
}
|
|
const r77 = r55;
|
|
const r79 = c22710_5 / 2;
|
|
const r80 = r65;
|
|
item.x = r77 - r79 + r80 / 2;
|
|
r55 = r77 + (r80 + r7);
|
|
}
|
|
return r36;
|
|
}, [isConnectedToVoiceChannel, stateFromStores, stateFromSharedValue, treatment]);
|
|
};
|