decord/source/5405_useRecyclerViewController.js

457 lines
17 KiB
JavaScript
Raw Normal View History

2026-07-23 10:11:24 +00:00
// Module ID: 5405
2026-07-25 08:10:48 +00:00
// Function ID: 46328
2026-07-20 16:05:17 +00:00
// Name: useRecyclerViewController
2026-07-23 10:11:24 +00:00
// Dependencies: [5406, 5359, 31, 27, 5407, 5408, 5374, 5409, 5403]
2026-07-20 16:05:17 +00:00
// Exports: useRecyclerViewController
2026-07-23 10:11:24 +00:00
// Module 5405 (useRecyclerViewController)
import asyncGeneratorStep from "asyncGeneratorStep";
import _slicedToArray from "_slicedToArray";
import result from "result";
import { I18nManager } from "get ActivityIndicator";
let closure_4;
let closure_5;
let closure_6;
let closure_7;
let closure_8;
const require = arg1;
({ useCallback: closure_4, useImperativeHandle: closure_5, useMemo: closure_6, useRef: closure_7, useState: closure_8 } = result);
2026-07-20 16:05:17 +00:00
export const useRecyclerViewController = function useRecyclerViewController(recyclerViewManager, arg1, arg2, arg3) {
2026-07-23 10:11:24 +00:00
const _require = recyclerViewManager;
2026-07-20 16:05:17 +00:00
const dependencyMap = arg2;
2026-07-23 10:11:24 +00:00
let asyncGeneratorStep = arg3;
const unmountFlag = _require(5407).useUnmountFlag();
let obj = _require(5407);
const callback = unmountFlag(callback4(0), 2)[1];
const callback2 = _setTimeout(false);
const callback3 = _setTimeout(recyclerViewManager.getDataLength());
let tmp2 = unmountFlag(callback4(0), 2);
_setTimeout = _require(5408).useUnmountAwareTimeout().setTimeout;
callback4 = _setTimeout(undefined);
2026-07-20 16:05:17 +00:00
let closure_9 = _setTimeout(undefined);
let closure_10 = _setTimeout([]);
const items = [recyclerViewManager];
2026-07-23 10:11:24 +00:00
let tmp3 = callback((arg0, arg1) => {
if (undefined !== store.updateScrollOffset(arg0)) {
const current = ref7.current;
2026-07-20 16:05:17 +00:00
current.push(arg1);
callback((arg0) => arg0 + 1);
} else {
arg1();
}
}, items);
2026-07-23 10:11:24 +00:00
let closure_11 = tmp3;
2026-07-20 16:05:17 +00:00
const items1 = [recyclerViewManager];
2026-07-23 10:11:24 +00:00
const computeFirstVisibleIndexForOffsetCorrection = callback(() => {
if (store.getIsFirstLayoutComplete()) {
if (store.hasStableDataKeys()) {
if (store.getDataLength() > 0) {
if (store.shouldMaintainVisibleContentPosition()) {
2026-07-20 16:05:17 +00:00
const _Math = Math;
2026-07-23 10:11:24 +00:00
const bound = Math.max(0, store.computeVisibleIndices().startIndex);
2026-07-20 16:05:17 +00:00
if (tmp6) {
2026-07-23 10:11:24 +00:00
closure_8.current = store.getDataKey(bound);
2026-07-20 16:05:17 +00:00
const _Object = Object;
2026-07-23 10:11:24 +00:00
closure_9.current = Object.assign({}, store.getLayout(bound));
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
tmp6 = undefined !== bound && bound >= 0;
2026-07-20 16:05:17 +00:00
}
}
}
}
}, items1);
const items2 = [recyclerViewManager, arg3, arg2, _setTimeout, tmp3, computeFirstVisibleIndexForOffsetCorrection];
const items3 = [recyclerViewManager, arg2, _setTimeout, unmountFlag, tmp3];
2026-07-23 10:11:24 +00:00
const applyOffsetCorrection = callback(() => {
2026-07-20 16:05:17 +00:00
let data;
let horizontal;
2026-07-23 10:11:24 +00:00
({ horizontal, data } = store.props);
let current = ref7.current;
ref7.current = [];
2026-07-20 16:05:17 +00:00
const item = current.forEach((arg0) => arg0());
2026-07-23 10:11:24 +00:00
const dataLength = store.getDataLength();
if (store.getIsFirstLayoutComplete()) {
if (store.hasStableDataKeys()) {
2026-07-20 16:05:17 +00:00
if (dataLength > 0) {
2026-07-23 10:11:24 +00:00
if (store.shouldMaintainVisibleContentPosition()) {
if (ref5.current) {
const engagedIndices = store.getEngagedIndices();
let findValueResult = engagedIndices.findValue((bound) => outer1_0.getDataKey(bound) === outer1_8.current);
2026-07-20 16:05:17 +00:00
if (null == findValueResult) {
if (tmp5) {
let findIndexResult;
if (null != data) {
2026-07-23 10:11:24 +00:00
findIndexResult = data.findIndex((arg0, bound) => outer1_0.getDataKey(bound) === outer1_8.current);
2026-07-20 16:05:17 +00:00
}
const tmp11 = findIndexResult;
}
findValueResult = tmp11;
}
if (undefined !== findValueResult) {
if (findValueResult >= 0) {
2026-07-23 10:11:24 +00:00
const point = store.getLayout(findValueResult);
2026-07-20 16:05:17 +00:00
if (horizontal) {
2026-07-23 10:11:24 +00:00
let diff = point.x - ref6.current.x;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
diff = point.y - ref6.current.y;
2026-07-20 16:05:17 +00:00
}
const _Object = Object;
2026-07-23 10:11:24 +00:00
ref6.current = Object.assign({}, store.getLayout(findValueResult));
2026-07-20 16:05:17 +00:00
if (0 !== diff) {
2026-07-23 10:11:24 +00:00
if (!ref3.current) {
if (!store.animationOptimizationsEnabled) {
if (store(ref[6]).PlatformConfig.supportsOffsetCorrection) {
const current2 = ref2.current;
2026-07-20 16:05:17 +00:00
if (null != current2) {
current2.scrollBy(diff);
}
} else {
const obj = {};
2026-07-23 10:11:24 +00:00
const sum = store.getAbsoluteLastScrollOffset() + diff;
2026-07-20 16:05:17 +00:00
if (horizontal) {
obj.x = sum;
obj.animated = false;
let tmp24 = obj;
} else {
obj.y = sum;
obj.animated = false;
tmp24 = obj;
}
2026-07-23 10:11:24 +00:00
current = ref.current;
2026-07-20 16:05:17 +00:00
if (null != current) {
current.scrollTo(tmp24);
}
}
if (tmp5) {
2026-07-23 10:11:24 +00:00
tmp3(store.getAbsoluteLastScrollOffset() + diff, () => {
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
store.ignoreScrollEvents = true;
2026-07-20 16:05:17 +00:00
_setTimeout(() => {
2026-07-23 10:11:24 +00:00
outer1_0.ignoreScrollEvents = false;
2026-07-20 16:05:17 +00:00
}, 100);
}
}
}
}
}
}
}
computeFirstVisibleIndexForOffsetCorrection();
}
}
}
}
2026-07-23 10:11:24 +00:00
ref4.current = store.getDataLength();
2026-07-20 16:05:17 +00:00
}, items2);
2026-07-23 10:11:24 +00:00
const handlerMethods = callback3(() => {
let obj = {};
2026-07-20 16:05:17 +00:00
Object.defineProperty(obj, "props", { get: () => store.props, set: undefined });
obj.scrollToOffset = function scrollToOffset(arg0) {
let animated;
let offset;
let skipFirstItemOffset;
({ offset, animated, skipFirstItemOffset } = arg0);
const horizontal = store.props.horizontal;
2026-07-23 10:11:24 +00:00
if (outer1_1.current) {
2026-07-20 16:05:17 +00:00
if (!tmp3) {
let obj = 0;
let num2 = 0;
if (!tmp) {
num2 = store.firstItemOffset;
}
let assign = offset + num2;
let current = {};
if (horizontal) {
current.x = assign;
current.y = obj;
let tmp11 = current;
} else {
current.x = obj;
current.y = assign;
tmp11 = current;
}
2026-07-23 10:11:24 +00:00
current = outer1_1.current;
2026-07-20 16:05:17 +00:00
const _Object = Object;
assign = Object.assign;
obj = { animated };
animated = current.scrollTo(assign({}, tmp11, obj));
} else {
2026-07-23 10:11:24 +00:00
current = store(5409);
2026-07-20 16:05:17 +00:00
const firstItemOffset = store.firstItemOffset;
2026-07-23 10:11:24 +00:00
const sum = current.adjustOffsetForRTL(offset, store.getChildContainerDimensions().width, store.getWindowSize().width) + (tmp ? firstItemOffset : -firstItemOffset);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
tmp3 = isRTL.isRTL && horizontal;
2026-07-20 16:05:17 +00:00
}
};
obj.clearLayoutCacheOnUpdate = function clearLayoutCacheOnUpdate() {
const result = store.markLayoutManagerDirty();
};
obj.flashScrollIndicators = function flashScrollIndicators() {
2026-07-23 10:11:24 +00:00
const current = outer1_1.current;
2026-07-20 16:05:17 +00:00
const result = current.flashScrollIndicators();
};
obj.getNativeScrollRef = function getNativeScrollRef() {
2026-07-23 10:11:24 +00:00
return outer1_1.current;
2026-07-20 16:05:17 +00:00
};
obj.getScrollResponder = function getScrollResponder() {
2026-07-23 10:11:24 +00:00
const current = outer1_1.current;
2026-07-20 16:05:17 +00:00
return current.getScrollResponder();
};
obj.getScrollableNode = function getScrollableNode() {
2026-07-23 10:11:24 +00:00
const current = outer1_1.current;
2026-07-20 16:05:17 +00:00
return current.getScrollableNode();
};
2026-07-23 10:11:24 +00:00
let closure_0 = ref2(async () => {
2026-07-20 16:05:17 +00:00
let animated;
if (arguments.length > 0) {
if (undefined !== arguments[0]) {
const first = arguments[0];
}
animated = {}.animated;
2026-07-23 10:11:24 +00:00
const data = engagedIndices.props.data;
2026-07-20 16:05:17 +00:00
if (data) {
if (data.length > 0) {
const diff = data.length - 1;
2026-07-23 10:11:24 +00:00
engagedIndices = engagedIndices.getEngagedIndices();
2026-07-20 16:05:17 +00:00
if (!engagedIndices.includes(diff)) {
2026-07-23 10:11:24 +00:00
let obj = { index: diff, animated };
return yield outer2_13.scrollToIndex(obj);
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-23 10:11:24 +00:00
outer2_7(() => {
const current = outer3_1.current;
2026-07-20 16:05:17 +00:00
if (null != current) {
const obj = { animated };
current.scrollToEnd(obj);
}
}, 0);
}
});
obj.scrollToEnd = function scrollToEnd() {
return store(...arguments);
};
obj.scrollToTop = function scrollToTop() {
if (arguments.length > 0) {
if (undefined !== arguments[0]) {
const first = arguments[0];
}
const obj = { offset: 0, animated: {}.animated };
2026-07-23 10:11:24 +00:00
outer1_13.scrollToOffset(obj);
2026-07-20 16:05:17 +00:00
}
};
obj.scrollToIndex = function scrollToIndex(arg0) {
2026-07-23 10:11:24 +00:00
let closure_0;
let closure_1;
let asyncGeneratorStep;
let _slicedToArray;
({ index: closure_0, animated: closure_1, viewPosition: asyncGeneratorStep, viewOffset: _slicedToArray } = arg0);
return new Promise((arg0) => {
let store = arg0;
const horizontal = store.props.horizontal;
if (outer2_1.current) {
if (store >= 0) {
if (store < store.getDataLength()) {
outer2_5.current = true;
let result = store.setOffsetProjectionEnabled(false);
let finishScrollToIndex = function getFinalOffset() {
const size = store.getLayout(store);
2026-07-20 16:05:17 +00:00
const tmp = horizontal ? size.x : size.y;
if (undefined !== finishScrollToIndex) {
2026-07-23 10:11:24 +00:00
const size2 = store.getWindowSize();
2026-07-20 16:05:17 +00:00
let diff = tmp;
if (undefined !== finishScrollToIndex) {
2026-07-23 10:11:24 +00:00
diff = tmp - ((horizontal ? size2.width : size2.height) - (horizontal ? size.width : size.height)) * finishScrollToIndex;
2026-07-20 16:05:17 +00:00
}
let sum = diff;
2026-07-23 10:11:24 +00:00
if (undefined !== _slicedToArray) {
sum = diff + _slicedToArray;
2026-07-20 16:05:17 +00:00
}
} else {
sum = tmp;
}
2026-07-23 10:11:24 +00:00
return sum + store.firstItemOffset;
2026-07-20 16:05:17 +00:00
};
2026-07-23 10:11:24 +00:00
const absoluteLastScrollOffset = store.getAbsoluteLastScrollOffset();
let size = store.getWindowSize();
let closure_4 = 2 * (horizontal ? size.width : size.height);
2026-07-20 16:05:17 +00:00
function getStartScrollOffset() {
const tmp2 = finishScrollToIndex();
2026-07-23 10:11:24 +00:00
if (tmp2 > _slicedToArray) {
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
let bound = Math.max(tmp2 - closure_4, tmp);
2026-07-23 10:11:24 +00:00
store.setScrollDirection("forward");
2026-07-20 16:05:17 +00:00
} else {
const _Math = Math;
bound = Math.min(tmp2 + closure_4, tmp);
2026-07-23 10:11:24 +00:00
store.setScrollDirection("backward");
2026-07-20 16:05:17 +00:00
}
return bound;
}
let closure_6 = finishScrollToIndex();
const startScrollOffset = getStartScrollOffset();
let closure_8 = closure_6;
function performScrollStep(arg0) {
2026-07-23 10:11:24 +00:00
const store = arg0;
if (outer3_3.current) {
store();
2026-07-20 16:05:17 +00:00
} else if (arg0 >= 5) {
finishScrollToIndex();
} else {
if (horizontal) {
let sum = closure_8 + arg0 / 4 * (startScrollOffset - closure_8);
} else {
sum = startScrollOffset + arg0 / 4 * (closure_8 - startScrollOffset);
}
2026-07-23 10:11:24 +00:00
outer3_11(sum, () => { ... });
const tmp = outer3_11;
2026-07-20 16:05:17 +00:00
}
}
finishScrollToIndex = function finishScrollToIndex() {
2026-07-23 10:11:24 +00:00
let maxScrollOffset = finishScrollToIndex();
maxScrollOffset = store.getMaxScrollOffset();
2026-07-20 16:05:17 +00:00
if (horizontal) {
2026-07-23 10:11:24 +00:00
let obj = { offset: startScrollOffset, animated: false, skipFirstItemOffset: true };
outer3_13.scrollToOffset(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
obj = { offset: maxScrollOffset, animated: horizontal, skipFirstItemOffset: true };
outer3_13.scrollToOffset(obj);
2026-07-20 16:05:17 +00:00
let num = 200;
if (horizontal) {
num = 300;
}
2026-07-23 10:11:24 +00:00
outer3_7(() => { ... }, num);
2026-07-20 16:05:17 +00:00
};
size = performScrollStep(0);
}
}
}
2026-07-23 10:11:24 +00:00
arg0();
2026-07-20 16:05:17 +00:00
});
};
obj.scrollToItem = function scrollToItem(item) {
2026-07-23 10:11:24 +00:00
item = item.item;
2026-07-20 16:05:17 +00:00
const data = store.props.data;
2026-07-23 10:11:24 +00:00
if (outer1_1.current) {
2026-07-20 16:05:17 +00:00
if (data) {
const findIndexResult = data.findIndex((arg0) => arg0 === item);
if (findIndexResult >= 0) {
const obj = { index: findIndexResult, animated: tmp, viewPosition: tmp2, viewOffset: tmp3 };
2026-07-23 10:11:24 +00:00
outer1_13.scrollToIndex(obj);
2026-07-20 16:05:17 +00:00
}
}
}
};
obj.getFirstItemOffset = function getFirstItemOffset() {
return store.firstItemOffset;
};
obj.getWindowSize = function getWindowSize() {
return store.getWindowSize();
};
obj.getLayout = function getLayout(currentStickyIndex) {
return store.tryGetLayout(currentStickyIndex);
};
obj.getAbsoluteLastScrollOffset = function getAbsoluteLastScrollOffset() {
return store.getAbsoluteLastScrollOffset();
};
obj.getChildContainerDimensions = function getChildContainerDimensions() {
return store.getChildContainerDimensions();
};
obj.recordInteraction = function recordInteraction() {
store.recordInteraction();
};
obj.computeVisibleIndices = function computeVisibleIndices() {
return store.computeVisibleIndices();
};
obj.getFirstVisibleIndex = function getFirstVisibleIndex() {
return store.computeVisibleIndices().startIndex;
};
obj.recomputeViewableItems = function recomputeViewableItems() {
const result = store.recomputeViewableItems();
};
obj.updateViewableItems = function updateViewableItems() {
const itemViewability = store.computeItemViewability();
};
obj.prepareForLayoutAnimationRender = function prepareForLayoutAnimationRender() {
if (!store.props.keyExtractor) {
const _console = console;
2026-07-23 10:11:24 +00:00
console.warn(store(5403).WarningMessages.keyExtractorNotDefinedForAnimation);
2026-07-20 16:05:17 +00:00
}
store.animationOptimizationsEnabled = true;
};
return obj;
}, items3);
const items4 = [handlerMethods, recyclerViewManager, _setTimeout];
const items5 = [handlerMethods, arg2, recyclerViewManager];
2026-07-23 10:11:24 +00:00
const applyInitialScrollIndex = callback(() => {
2026-07-20 16:05:17 +00:00
let data;
let horizontal;
let initialScrollIndexParams;
2026-07-23 10:11:24 +00:00
({ data, initialScrollIndexParams, horizontal } = store.props);
const initialScrollIndex = store.getInitialScrollIndex();
2026-07-20 16:05:17 +00:00
let num = -1;
if (null != initialScrollIndex) {
num = initialScrollIndex;
}
let length;
if (null != data) {
length = data.length;
}
let num2 = 0;
if (null != length) {
num2 = length;
}
if (num >= 0) {
if (num < num2) {
2026-07-23 10:11:24 +00:00
if (!store.isInitialScrollComplete) {
if (store.getIsFirstLayoutComplete()) {
2026-07-20 16:05:17 +00:00
_setTimeout(() => {
sum.isInitialScrollComplete = true;
2026-07-23 10:11:24 +00:00
outer1_5.current = false;
2026-07-20 16:05:17 +00:00
}, 100);
closure_5.current = true;
let viewOffset;
if (null != initialScrollIndexParams) {
viewOffset = initialScrollIndexParams.viewOffset;
}
let num4 = 0;
if (null != viewOffset) {
num4 = viewOffset;
}
2026-07-23 10:11:24 +00:00
let point = store.getLayout(num);
2026-07-20 16:05:17 +00:00
if (horizontal) {
let sum = point.x + num4;
} else {
sum = point.y + num4;
}
2026-07-23 10:11:24 +00:00
store = sum;
2026-07-20 16:05:17 +00:00
num4 = handlerMethods.scrollToOffset;
2026-07-23 10:11:24 +00:00
let obj = { offset: sum, animated: false, skipFirstItemOffset: false };
2026-07-20 16:05:17 +00:00
point = num4(obj);
_setTimeout(() => {
2026-07-23 10:11:24 +00:00
const obj = { offset: closure_0, animated: false, skipFirstItemOffset: false };
outer1_13.scrollToOffset(obj);
2026-07-20 16:05:17 +00:00
}, 0);
}
}
}
}
}, items4);
2026-07-23 10:11:24 +00:00
callback2(arg1, () => {
const merged = Object.assign({}, ref.current, handlerMethods);
2026-07-22 07:54:56 +00:00
const obj = {
2026-07-20 16:05:17 +00:00
get() {
2026-07-23 10:11:24 +00:00
return outer1_0.props;
},
enumerable: true,
configurable: true
2026-07-22 07:54:56 +00:00
};
Object.defineProperty(merged, "props", obj);
2026-07-20 16:05:17 +00:00
return merged;
}, items5);
return { applyOffsetCorrection, computeFirstVisibleIndexForOffsetCorrection, applyInitialScrollIndex, handlerMethods };
};