310 lines
18 KiB
TypeScript
310 lines
18 KiB
TypeScript
// Metro module 15789 (f15790).
|
|
import { useRef, useMemo } from "react";
|
|
import { LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE, LAUNCH_PAD_END_TRANSLATION_THRESHOLD, LAUNCH_PAD_END_VELOCITY_THRESHOLD, LAUNCH_PAD_PULL_TAB_HEIGHT, LAUNCH_PAD_PULL_TAB_HIT_SLOP, LAUNCH_PAD_PULL_TAB_SCALE_FACTOR, LAUNCH_PAD_PULL_TAB_WIDTH, LaunchPadTypes } from "./LaunchPadConstants";
|
|
import { useIsModalOpen } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
|
|
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
|
|
import * as _Module5273 from "../../../_bundle/Module5273";
|
|
import { Gesture } from "../../../_bundle/Module5273";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
import * as _useWindowDimensionsSharedValue_native from "../../screen/useWindowDimensionsSharedValue.native";
|
|
import updateSharedValueIfChanged_native from "../../reanimated/utils/updateSharedValueIfChanged.native";
|
|
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import * as _HapticUtils_native from "../../haptics/HapticUtils.native";
|
|
const __initData = {
|
|
code: "function useLaunchPadGestureTsx1(){const{updateSharedValueIfChanged,gestureState,updaters}=this.__closure;updateSharedValueIfChanged(gestureState,{active:false,initialLaunchPadPosition:0,initialPullTabPosition:0,initialTouchX:0,initialTouchY:0,positionOffsetX:0,positionOffsetY:0,startTime:-1});updaters.setLaunchPadPullTabScale(1.0);}"
|
|
};
|
|
const __initData2 = {
|
|
code: "function useLaunchPadGestureTsx2(){const{gestureState,updaters,updateSharedValueIfChanged}=this.__closure;const{initialLaunchPadPosition:initialLaunchPadPosition,active:active}=gestureState.get();if(active){if(initialLaunchPadPosition===1){updaters.setLaunchPadPosition(1);}else{updaters.setLaunchPadPosition(0);}}updateSharedValueIfChanged(gestureState,{active:false,initialLaunchPadPosition:0,initialPullTabPosition:0,initialTouchX:0,initialTouchY:0,positionOffsetX:0,positionOffsetY:0,startTime:-1});}"
|
|
};
|
|
const __initData3 = {
|
|
code: "function useLaunchPadGestureTsx3({velocityX:velocityX,velocityY:velocityY,translationX:translationX,translationY:translationY}){const{gestureState,launchPadType,LaunchPadTypes,LAUNCH_PAD_END_TRANSLATION_THRESHOLD,LAUNCH_PAD_END_VELOCITY_THRESHOLD,updaters,launchPadSharedState}=this.__closure;const{requiresPop:requiresPop,startShown:startShown}=gestureState.get();if(requiresPop){if(!startShown){const isPullTabTapComplete=launchPadType===LaunchPadTypes.PULL_TAB&&Math.abs(translationX)<=LAUNCH_PAD_END_TRANSLATION_THRESHOLD&&Math.abs(translationY)<=LAUNCH_PAD_END_TRANSLATION_THRESHOLD&&Math.abs(velocityX)<=LAUNCH_PAD_END_VELOCITY_THRESHOLD&&Math.abs(velocityY)<=LAUNCH_PAD_END_VELOCITY_THRESHOLD;if(isPullTabTapComplete){updaters.setLaunchPadPosition(1);}else{updaters.setLaunchPadPosition(0);}}else{updaters.setLaunchPadPosition(1);}}else if(Math.abs(velocityX)<LAUNCH_PAD_END_VELOCITY_THRESHOLD){if(launchPadSharedState.get()>=0.5){updaters.setLaunchPadPosition(1);}else{updaters.setLaunchPadPosition(0);}}else if(velocityX>0){updaters.setLaunchPadPosition(0);}else{updaters.setLaunchPadPosition(1);}}"
|
|
};
|
|
const __initData4 = {
|
|
code: "function useLaunchPadGestureTsx4({translationX:translationX,translationY:translationY,absoluteX:absoluteX}){const{gestureState,getWindowDimensionsWorklet,POP_RESISTANCE,launchPadType,LaunchPadTypes,PIP_POP_DISTANCE,updaters,updateSharedValueIfChanged,runOnJS,triggerHapticFeedback,HapticFeedbackTypes}=this.__closure;if(!gestureState.get().active)return;const{initialTouchX:initialTouchX,requiresPop:requiresPop}=gestureState.get();const{width:windowWidth}=getWindowDimensionsWorklet();const newXOffset=absoluteX-initialTouchX;const distance=Math.max(newXOffset*-1,0);const resistance=distance*POP_RESISTANCE;const positionOffsetX=absoluteX-gestureState.get().initialTouchX;const launchPadPosition=1-(gestureState.get().initialTouchX+translationX-(launchPadType!==LaunchPadTypes.PULL_TAB?40:0))/windowWidth;if(requiresPop&&distance<=PIP_POP_DISTANCE){if(launchPadType!==LaunchPadTypes.PULL_TAB){const a=(distance-resistance)/windowWidth;updaters.setLaunchPadPosition(a);}else{updaters.setLaunchPadPullTabTranslation(translationY);}updateSharedValueIfChanged(gestureState,{positionOffsetX:positionOffsetX});}else{if(requiresPop){updateSharedValueIfChanged(gestureState,{requiresPop:false,positionOffsetX:positionOffsetX});runOnJS(triggerHapticFeedback)(HapticFeedbackTypes.IMPACT_MEDIUM);}else{updateSharedValueIfChanged(gestureState,{positionOffsetX:positionOffsetX});}updaters.setLaunchPadPosition(launchPadPosition);}}"
|
|
};
|
|
const __initData5 = {
|
|
code: "function useLaunchPadGestureTsx5(event,manager){const{gestureState,State,getWindowDimensionsWorklet,launchPadType,LaunchPadTypes,LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE,LAUNCH_PAD_PULL_TAB_WIDTH,LAUNCH_PAD_PULL_TAB_HIT_SLOP,LaunchPadPullTabState,LAUNCH_PAD_PULL_TAB_HEIGHT,updaters,LAUNCH_PAD_PULL_TAB_SCALE_FACTOR,launchPadSharedState,MANUAL_ACTIVATION_THRESHOLD}=this.__closure;const{active:active,initialLaunchPadPosition:initialLaunchPadPosition,initialTouchX:initialTouchX,initialTouchY:initialTouchY}=gestureState.get();if(event.state!==State.BEGAN||active)return;const currentTouch=event.changedTouches[0];if(currentTouch==null){manager.fail();return;}const{x:x,y:y}=currentTouch;const{width:windowWidth}=getWindowDimensionsWorklet();switch(launchPadType){case LaunchPadTypes.DISABLED:manager.fail();return;case LaunchPadTypes.GESTURE_EDGE:if(initialLaunchPadPosition===0&&initialTouchX<windowWidth-LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE){manager.fail();return;}break;case LaunchPadTypes.PULL_TAB:{if(initialLaunchPadPosition>0)break;const inPullTabX=x>windowWidth-LAUNCH_PAD_PULL_TAB_WIDTH-LAUNCH_PAD_PULL_TAB_HIT_SLOP&&x<windowWidth;const inPullTabY=y>LaunchPadPullTabState.get().position-LAUNCH_PAD_PULL_TAB_HIT_SLOP&&y<LaunchPadPullTabState.get().position+LAUNCH_PAD_PULL_TAB_HEIGHT+LAUNCH_PAD_PULL_TAB_HIT_SLOP;if(!inPullTabX||!inPullTabY){manager.fail();return;}gestureState.set({...gestureState.get(),initialPullTabPosition:LaunchPadPullTabState.get().position,active:true});updaters.setLaunchPadPullTabScale(LAUNCH_PAD_PULL_TAB_SCALE_FACTOR);updaters.setLaunchPadShown(true);manager.activate();return;}case LaunchPadTypes.GESTURE_FULL:break;default:launchPadType;manager.fail();return;}const horizontalDistance=x-initialTouchX;const verticalDistance=Math.abs(y-initialTouchY);const hasMovedCorrectDirection=launchPadSharedState.get()>0&&horizontalDistance>0||launchPadSharedState.get()<=0&&horizontalDistance<0;if(hasMovedCorrectDirection&&Math.abs(horizontalDistance)>verticalDistance){if(Math.abs(horizontalDistance)<MANUAL_ACTIVATION_THRESHOLD){return;}gestureState.set({...gestureState.get(),active:true});updaters.setLaunchPadShown(true);manager.activate();return;}manager.fail();}"
|
|
};
|
|
const __initData6 = {
|
|
code: "function useLaunchPadGestureTsx6(event){const{gestureState,launchPadSharedState}=this.__closure;const{x:x,y:y}=event.changedTouches[0];gestureState.set({active:false,initialLaunchPadPosition:launchPadSharedState.get(),initialPullTabPosition:0,initialTouchX:x,initialTouchY:y,positionOffsetX:0,positionOffsetY:0,startTime:Date.now(),requiresPop:launchPadSharedState.get()===0,startShown:!(launchPadSharedState.get()===0)});}"
|
|
};
|
|
export default function useLaunchPadGesture({ launchPadType, launchPadSharedState, LaunchPadPullTabState, gestureState, updaters }) {
|
|
const isModalOpen = useIsModalOpen();
|
|
const safeAreaInsets_native = useSafeAreaInsets_native();
|
|
let c22444_6 = safeAreaInsets_native;
|
|
const ref = useRef(void 0);
|
|
return {
|
|
gesture: useMemo(() => {
|
|
const right = launchPadType === LaunchPadTypes.GESTURE_FULL ? -1 * LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE : 0;
|
|
const r41 = Gesture.Pan().enabled(isModalOpen ? !isModalOpen : launchPadType !== LaunchPadTypes.DISABLED).withRef(ref).minDistance(0).maxPointers(1).manualActivation(isAndroid());
|
|
const r49 = r41.hitSlop({
|
|
top: -1 * c22444_6.top,
|
|
left: 0,
|
|
bottom: -1 * c22444_6.bottom,
|
|
right
|
|
});
|
|
const w = function w(a0) {
|
|
const r10 = a0.changedTouches[0];
|
|
const { x: initialTouchX, y: initialTouchY } = r10;
|
|
gestureState.set({
|
|
active: false,
|
|
initialLaunchPadPosition: launchPadSharedState.get(),
|
|
initialPullTabPosition: 0,
|
|
initialTouchX,
|
|
initialTouchY,
|
|
positionOffsetX: 0,
|
|
positionOffsetY: 0,
|
|
startTime: Date.now(),
|
|
requiresPop: launchPadSharedState.get() === 0,
|
|
startShown: !(launchPadSharedState.get() === 0)
|
|
});
|
|
};
|
|
w.__closure = {
|
|
gestureState,
|
|
launchPadSharedState
|
|
};
|
|
w.__workletHash = 14359599806316;
|
|
w.__initData = __initData6;
|
|
const r56 = r49.onTouchesDown(w);
|
|
const X = function X(a0, a1) {
|
|
const r7 = gestureState.get();
|
|
const { active, initialLaunchPadPosition, initialTouchX, initialTouchY } = r7;
|
|
if (a0.state === _Module5273.State.BEGAN && !active) {
|
|
const r27 = a0.changedTouches[0];
|
|
if (r27 != null) {
|
|
const { x: r30, y: r31 } = r27;
|
|
const width = _useWindowDimensionsSharedValue_native.getWindowDimensionsWorklet().width;
|
|
if (LaunchPadTypes.DISABLED === launchPadType) {
|
|
a1.fail();
|
|
return void 0;
|
|
}
|
|
if (LaunchPadTypes.GESTURE_EDGE === launchPadType) {
|
|
if (initialLaunchPadPosition === 0 && initialTouchX < width - LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE) {
|
|
a1.fail();
|
|
return void 0;
|
|
}
|
|
} else if (LaunchPadTypes.PULL_TAB === launchPadType) {
|
|
if (!(initialLaunchPadPosition > 0)) {
|
|
const r50 = r31 > LaunchPadPullTabState.get().position - LAUNCH_PAD_PULL_TAB_HIT_SLOP && r31 < LaunchPadPullTabState.get().position + LAUNCH_PAD_PULL_TAB_HEIGHT + LAUNCH_PAD_PULL_TAB_HIT_SLOP;
|
|
if (r30 > width - LAUNCH_PAD_PULL_TAB_WIDTH - LAUNCH_PAD_PULL_TAB_HIT_SLOP && (r30 < width && r50)) {
|
|
gestureState.set({
|
|
...gestureState.get(),
|
|
initialPullTabPosition: LaunchPadPullTabState.get().position,
|
|
active: true
|
|
});
|
|
updaters.setLaunchPadPullTabScale(LAUNCH_PAD_PULL_TAB_SCALE_FACTOR);
|
|
updaters.setLaunchPadShown(true);
|
|
a1.activate();
|
|
} else {
|
|
a1.fail();
|
|
}
|
|
return void 0;
|
|
}
|
|
} else if (LaunchPadTypes.GESTURE_FULL !== launchPadType) {
|
|
a1.fail();
|
|
return void 0;
|
|
}
|
|
L25: {
|
|
const r83 = r30 - initialTouchX;
|
|
const r88 = Math.abs(r31 - initialTouchY);
|
|
if (!(launchPadSharedState.get() > 0 && r83 > 0)) {
|
|
if (!(launchPadSharedState.get() <= 0)) {
|
|
break L25;
|
|
}
|
|
if (!(r83 < 0)) {
|
|
break L25;
|
|
}
|
|
}
|
|
if (Math.abs(r83) > r88) {
|
|
if (Math.abs(r83) < 3) {
|
|
return void 0;
|
|
}
|
|
gestureState.set({
|
|
...gestureState.get(),
|
|
active: true
|
|
});
|
|
updaters.setLaunchPadShown(true);
|
|
a1.activate();
|
|
return void 0;
|
|
}
|
|
}
|
|
a1.fail();
|
|
} else {
|
|
a1.fail();
|
|
}
|
|
}
|
|
};
|
|
X.__closure = {
|
|
gestureState,
|
|
State: _Module5273.State,
|
|
getWindowDimensionsWorklet: _useWindowDimensionsSharedValue_native.getWindowDimensionsWorklet,
|
|
launchPadType,
|
|
LaunchPadTypes,
|
|
LAUNCH_PAD_EDGE_GESTURE_AFFORDANCE,
|
|
LAUNCH_PAD_PULL_TAB_WIDTH,
|
|
LAUNCH_PAD_PULL_TAB_HIT_SLOP,
|
|
LaunchPadPullTabState,
|
|
LAUNCH_PAD_PULL_TAB_HEIGHT,
|
|
updaters,
|
|
LAUNCH_PAD_PULL_TAB_SCALE_FACTOR,
|
|
launchPadSharedState,
|
|
MANUAL_ACTIVATION_THRESHOLD: 3
|
|
};
|
|
X.__workletHash = 17469318427529;
|
|
X.__initData = __initData5;
|
|
const r73 = r56.onTouchesMove(X);
|
|
const I = function I(a0) {
|
|
L13: {
|
|
const { translationX, translationY, absoluteX } = a0;
|
|
if (gestureState.get().active) {
|
|
const r21 = gestureState.get();
|
|
const { initialTouchX, requiresPop } = r21;
|
|
const width = _useWindowDimensionsSharedValue_native.getWindowDimensionsWorklet().width;
|
|
const r10 = Math;
|
|
const r1 = -1 * (absoluteX - initialTouchX);
|
|
let r29 = 0;
|
|
const r30 = r10.max(r1, 0);
|
|
const positionOffsetX = absoluteX - gestureState.get().initialTouchX;
|
|
const r38 = gestureState.get().initialTouchX + translationX;
|
|
if (launchPadType !== LaunchPadTypes.PULL_TAB) {
|
|
r29 = 40;
|
|
}
|
|
const r42 = (r38 - r29) / width;
|
|
if (requiresPop && r30 <= 70) {
|
|
if (launchPadType !== LaunchPadTypes.PULL_TAB) {
|
|
updaters.setLaunchPadPosition((r30 - 0.5 * r30) / width);
|
|
} else {
|
|
updaters.setLaunchPadPullTabTranslation(translationY);
|
|
}
|
|
updateSharedValueIfChanged_native(gestureState, {
|
|
positionOffsetX
|
|
});
|
|
break L13;
|
|
}
|
|
if (requiresPop) {
|
|
updateSharedValueIfChanged_native(gestureState, {
|
|
requiresPop: false,
|
|
positionOffsetX
|
|
});
|
|
_ReanimatedRexport.runOnJS(_HapticUtils_native.triggerHapticFeedback)(_HapticUtils_native.HapticFeedbackTypes.IMPACT_MEDIUM);
|
|
} else {
|
|
updateSharedValueIfChanged_native(gestureState, {
|
|
positionOffsetX
|
|
});
|
|
}
|
|
updaters.setLaunchPadPosition(1 - r42);
|
|
}
|
|
}
|
|
};
|
|
I.__closure = {
|
|
gestureState,
|
|
getWindowDimensionsWorklet: _useWindowDimensionsSharedValue_native.getWindowDimensionsWorklet,
|
|
POP_RESISTANCE: 0.5,
|
|
launchPadType,
|
|
LaunchPadTypes,
|
|
PIP_POP_DISTANCE: 70,
|
|
updaters,
|
|
updateSharedValueIfChanged: updateSharedValueIfChanged_native,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
triggerHapticFeedback: _HapticUtils_native.triggerHapticFeedback,
|
|
HapticFeedbackTypes: _HapticUtils_native.HapticFeedbackTypes
|
|
};
|
|
I.__workletHash = 8073380735713;
|
|
I.__initData = __initData4;
|
|
const r93 = r73.onChange(I);
|
|
const v = function v(a0) {
|
|
L16: {
|
|
const { velocityX, velocityY, translationX, translationY } = a0;
|
|
const r13 = gestureState.get();
|
|
const { requiresPop, startShown } = r13;
|
|
if (requiresPop) {
|
|
L15: {
|
|
if (!startShown) {
|
|
if (launchPadType === LaunchPadTypes.PULL_TAB && Math.abs(translationX) <= LAUNCH_PAD_END_TRANSLATION_THRESHOLD && Math.abs(translationY) <= LAUNCH_PAD_END_TRANSLATION_THRESHOLD && Math.abs(velocityX) <= LAUNCH_PAD_END_VELOCITY_THRESHOLD && Math.abs(velocityY) <= LAUNCH_PAD_END_VELOCITY_THRESHOLD) {
|
|
break L15;
|
|
}
|
|
updaters.setLaunchPadPosition(0);
|
|
break L16;
|
|
}
|
|
}
|
|
updaters.setLaunchPadPosition(1);
|
|
} else if (Math.abs(velocityX) < LAUNCH_PAD_END_VELOCITY_THRESHOLD) {
|
|
if (launchPadSharedState.get() >= 0.5) {
|
|
updaters.setLaunchPadPosition(1);
|
|
} else {
|
|
updaters.setLaunchPadPosition(0);
|
|
}
|
|
} else if (velocityX > 0) {
|
|
updaters.setLaunchPadPosition(0);
|
|
} else {
|
|
updaters.setLaunchPadPosition(1);
|
|
}
|
|
}
|
|
};
|
|
v.__closure = {
|
|
gestureState,
|
|
launchPadType,
|
|
LaunchPadTypes,
|
|
LAUNCH_PAD_END_TRANSLATION_THRESHOLD,
|
|
LAUNCH_PAD_END_VELOCITY_THRESHOLD,
|
|
updaters,
|
|
launchPadSharedState
|
|
};
|
|
v.__workletHash = 13108163303108;
|
|
v.__initData = __initData3;
|
|
const r101 = r93.onEnd(v);
|
|
const b = function b() {
|
|
const r6 = gestureState.get();
|
|
const initialLaunchPadPosition = r6.initialLaunchPadPosition;
|
|
if (r6.active) {
|
|
if (initialLaunchPadPosition === 1) {
|
|
updaters.setLaunchPadPosition(1);
|
|
} else {
|
|
updaters.setLaunchPadPosition(0);
|
|
}
|
|
}
|
|
updateSharedValueIfChanged_native(gestureState, {
|
|
active: false,
|
|
initialLaunchPadPosition: 0,
|
|
initialPullTabPosition: 0,
|
|
initialTouchX: 0,
|
|
initialTouchY: 0,
|
|
positionOffsetX: 0,
|
|
positionOffsetY: 0,
|
|
startTime: -1
|
|
});
|
|
};
|
|
b.__closure = {
|
|
gestureState,
|
|
updaters,
|
|
updateSharedValueIfChanged: updateSharedValueIfChanged_native
|
|
};
|
|
b.__workletHash = 11677880944102;
|
|
b.__initData = __initData2;
|
|
const r109 = r101.onTouchesCancelled(b);
|
|
const t = function t() {
|
|
updateSharedValueIfChanged_native(gestureState, {
|
|
active: false,
|
|
initialLaunchPadPosition: 0,
|
|
initialPullTabPosition: 0,
|
|
initialTouchX: 0,
|
|
initialTouchY: 0,
|
|
positionOffsetX: 0,
|
|
positionOffsetY: 0,
|
|
startTime: -1
|
|
});
|
|
updaters.setLaunchPadPullTabScale(1);
|
|
};
|
|
t.__closure = {
|
|
updateSharedValueIfChanged: updateSharedValueIfChanged_native,
|
|
gestureState,
|
|
updaters
|
|
};
|
|
t.__workletHash = 14463491499289;
|
|
t.__initData = __initData;
|
|
return r109.onFinalize(t);
|
|
}, [gestureState, safeAreaInsets_native, isModalOpen, LaunchPadPullTabState, launchPadSharedState, launchPadType, updaters]),
|
|
gestureRef: ref
|
|
};
|
|
};
|