88 lines
3.8 KiB
TypeScript
88 lines
3.8 KiB
TypeScript
// Metro module 9300 (f9301).
|
|
import { useMemo } from "react";
|
|
import { create } from "../../../../_bundle/Module644";
|
|
import { batchUpdates } from "../../../../_bundle/Module705";
|
|
import * as _ReanimatedRexport from "../../../../modules/reanimated/ReanimatedRexport";
|
|
import { useSharedValue } from "../../../../modules/reanimated/ReanimatedRexport";
|
|
import * as _HapticUtils_native from "../../../../modules/haptics/HapticUtils.native";
|
|
let c6123_3 = create(() => ({
|
|
menu: null
|
|
}));
|
|
export function updateContextMenuState(a0, a1, { pan, itemMeasurements, activeIndex }) {
|
|
pan.set(a1);
|
|
const r20 = itemMeasurements.get();
|
|
const r8 = 0 < r20.length;
|
|
let r1 = 0;
|
|
if (r8) {
|
|
do {
|
|
const r22 = r20[r1 + 2];
|
|
const r16 = r20[r1 + 3];
|
|
const r15 = r20[r1 + 1];
|
|
const r26 = r20[r1 + 0];
|
|
const r27 = r1;
|
|
if (a1 >= r15 && a1 <= r15 + r16 && a0 >= r26 && a0 <= r26 + r22) {
|
|
const r35 = r27 / 4;
|
|
if (activeIndex.get() !== r35) {
|
|
activeIndex.set(r35);
|
|
_ReanimatedRexport.runOnJS(_HapticUtils_native.triggerHapticFeedback)(_HapticUtils_native.HapticFeedbackTypes.IMPACT_LIGHT);
|
|
}
|
|
return void 0;
|
|
}
|
|
r1 = r27 + 4;
|
|
} while (r1 < r20.length);
|
|
}
|
|
activeIndex.set(-1);
|
|
}
|
|
updateContextMenuState.__closure = {
|
|
INDEX_BOUNDS_WIDTH_OFFSET: 2,
|
|
INDEX_BOUNDS_HEIGHT_OFFSET: 3,
|
|
INDEX_BOUNDS_PAGE_Y_OFFSET: 1,
|
|
INDEX_BOUNDS_PAGE_X_OFFSET: 0,
|
|
INDEX_BOUNDS_OFFSET: 4,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
triggerHapticFeedback: _HapticUtils_native.triggerHapticFeedback,
|
|
HapticFeedbackTypes: _HapticUtils_native.HapticFeedbackTypes
|
|
};
|
|
updateContextMenuState.__workletHash = 10158111154044;
|
|
updateContextMenuState.__initData = {
|
|
code: "function updateContextMenuState_ContextMenuStateNativeTsx1(absoluteX,absoluteY,state){const{INDEX_BOUNDS_WIDTH_OFFSET,INDEX_BOUNDS_HEIGHT_OFFSET,INDEX_BOUNDS_PAGE_Y_OFFSET,INDEX_BOUNDS_PAGE_X_OFFSET,INDEX_BOUNDS_OFFSET,runOnJS,triggerHapticFeedback,HapticFeedbackTypes}=this.__closure;const{pan:pan,itemMeasurements:itemMeasurements,activeIndex:activeIndex}=state;pan.set(absoluteY);const bounds=itemMeasurements.get();let offset=0;while(offset<bounds.length){const width=bounds[offset+INDEX_BOUNDS_WIDTH_OFFSET];const height=bounds[offset+INDEX_BOUNDS_HEIGHT_OFFSET];const pageY=bounds[offset+INDEX_BOUNDS_PAGE_Y_OFFSET];const pageX=bounds[offset+INDEX_BOUNDS_PAGE_X_OFFSET];const lowerY=pageY;const upperY=pageY+height;const lowerX=pageX;const upperX=pageX+width;if(absoluteY>=lowerY&&absoluteY<=upperY&&absoluteX>=lowerX&&absoluteX<=upperX){const index=offset/INDEX_BOUNDS_OFFSET;if(activeIndex.get()!==index){activeIndex.set(index);runOnJS(triggerHapticFeedback)(HapticFeedbackTypes.IMPACT_LIGHT);}return;}offset+=INDEX_BOUNDS_OFFSET;}activeIndex.set(-1);}"
|
|
};
|
|
export const INDEX_BOUNDS_OFFSET = 4;
|
|
export const INDEX_BOUNDS_PAGE_X_OFFSET = 0;
|
|
export const INDEX_BOUNDS_PAGE_Y_OFFSET = 1;
|
|
export const INDEX_BOUNDS_WIDTH_OFFSET = 2;
|
|
export const INDEX_BOUNDS_HEIGHT_OFFSET = 3;
|
|
export { c6123_3 as ContextMenuStore };
|
|
export function showContextMenu(menu) {
|
|
batchUpdates(() => c6123_3.setState({
|
|
menu
|
|
}));
|
|
}
|
|
export function hideContextMenu() {
|
|
batchUpdates(() => {
|
|
c6123_3.setState((state) => state.menu != null ? {
|
|
menu: null
|
|
} : state);
|
|
});
|
|
}
|
|
export function useActiveContextMenu() {
|
|
return c6123_3((a0) => a0.menu);
|
|
}
|
|
export function useContextMenuState() {
|
|
const sharedValue = useSharedValue(-1);
|
|
const sharedValue2 = useSharedValue([]);
|
|
const sharedValue3 = useSharedValue(-1);
|
|
return useMemo(() => ({
|
|
pan: sharedValue,
|
|
itemMeasurements: sharedValue2,
|
|
activeIndex: sharedValue3
|
|
}), [sharedValue, sharedValue2, sharedValue3]);
|
|
}
|
|
export function resetContextMenuState({ activeIndex, pan, itemMeasurements }) {
|
|
activeIndex.set(-1);
|
|
pan.set(-1);
|
|
if (itemMeasurements.get().length > 0) {
|
|
itemMeasurements.set([]);
|
|
}
|
|
}
|