Files
discord-decomp/modules/voice_panel/native/hooks/useTapGestures.tsx
T
2026-11-01 12:12:55 +02:00

106 lines
4.0 KiB
TypeScript

// Metro module 15962 (f15963).
import { useContext, useRef, useLayoutEffect, useMemo } from "react";
import VoicePanelStateContext from "../VoicePanelStateContext";
import { Gesture } from "../../../../_bundle/Module5273";
import * as _ReanimatedRexport from "../../../reanimated/ReanimatedRexport";
import * as _HapticUtils_native from "../../../haptics/HapticUtils.native";
const __initData = {
code: "function useTapGesturesTsx1(){const{runOnJS,handleEvent}=this.__closure;return runOnJS(handleEvent)('double');}"
};
const __initData2 = {
code: "function useTapGesturesTsx2(event,manager){const{isFocusedVideoZoomed}=this.__closure;if(isFocusedVideoZoomed.get()){manager.fail();}}"
};
const __initData3 = {
code: "function useTapGesturesTsx3(){const{runOnJS,handleEvent}=this.__closure;return runOnJS(handleEvent)('single');}"
};
const __initData4 = {
code: "function useTapGesturesTsx4(){const{runOnJS,triggerHapticFeedback,HapticFeedbackTypes,handleEvent}=this.__closure;runOnJS(triggerHapticFeedback)(HapticFeedbackTypes.IMPACT_MEDIUM);runOnJS(handleEvent)('long');}"
};
export default function useTapGestures(a0) {
const current = a0;
const isFocusedVideoZoomed = useContext(VoicePanelStateContext).isFocusedVideoZoomed;
const ref = useRef(a0);
const r1 = a0.onSingleTap != null;
let c22656_3 = r1;
const r2 = a0.onDoubleTap != null;
let c22656_4 = r2;
const r20 = a0.onLongPress != null;
let c22656_5 = r20;
const gesturesEnabled = a0.gesturesEnabled;
useLayoutEffect(() => {
ref.current = current;
});
return useMemo(() => {
const handleEvent2 = function handleEvent(a0) {
if (a0 === "single") {
const current4 = ref.current;
const onSingleTap = current4.onSingleTap;
if (onSingleTap != null) {
onSingleTap.call(current4);
}
} else if (a0 === "double") {
const current3 = ref.current;
const onDoubleTap = current3.onDoubleTap;
if (onDoubleTap != null) {
onDoubleTap.call(current3);
}
} else if (a0 === "long") {
const current2 = ref.current;
const onLongPress = current2.onLongPress;
if (onLongPress != null) {
onLongPress.call(current2);
}
}
};
const r9 = Gesture.Tap();
let r12 = gesturesEnabled;
const r29 = r9.enabled(gesturesEnabled ? c22656_4 : gesturesEnabled).maxDistance(30).numberOfTaps(2);
const S = function S(a0, a1) {
if (isFocusedVideoZoomed.get()) {
a1.fail();
}
};
S.__closure = {
isFocusedVideoZoomed
};
S.__workletHash = 3236469126950;
S.__initData = __initData2;
const r34 = r29.onTouchesDown(S);
const b = () => _ReanimatedRexport.runOnJS(handleEvent2)("double");
b.__closure = {
runOnJS: _ReanimatedRexport.runOnJS,
handleEvent: handleEvent2
};
b.__workletHash = 13571114432746;
b.__initData = __initData;
const r43 = r34.onStart(b);
const r53 = Gesture.Tap().enabled(gesturesEnabled ? c22656_3 : gesturesEnabled).maxDistance(30);
const c = () => _ReanimatedRexport.runOnJS(handleEvent2)("single");
c.__closure = {
runOnJS: _ReanimatedRexport.runOnJS,
handleEvent: handleEvent2
};
c.__workletHash = 14109132753191;
c.__initData = __initData3;
const r61 = r53.onStart(c);
const r66 = Gesture.LongPress();
if (gesturesEnabled) {
r12 = c22656_5;
}
const r68 = r66.enabled(r12);
const n = function n() {
_ReanimatedRexport.runOnJS(_HapticUtils_native.triggerHapticFeedback)(_HapticUtils_native.HapticFeedbackTypes.IMPACT_MEDIUM);
_ReanimatedRexport.runOnJS(handleEvent2)("long");
};
n.__closure = {
runOnJS: _ReanimatedRexport.runOnJS,
triggerHapticFeedback: _HapticUtils_native.triggerHapticFeedback,
HapticFeedbackTypes: _HapticUtils_native.HapticFeedbackTypes,
handleEvent: handleEvent2
};
n.__workletHash = 1947700378974;
n.__initData = __initData4;
return Gesture.Exclusive(r43, r61, r68.onStart(n));
}, [r1, r2, r20, gesturesEnabled, isFocusedVideoZoomed]);
};