@react-native-ohos/flash-list 1.6.4-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.OpenSource +11 -0
- package/README.md +9 -0
- package/dist/AnimatedFlashList.d.ts +6 -0
- package/dist/AnimatedFlashList.d.ts.map +1 -0
- package/dist/AnimatedFlashList.js +8 -0
- package/dist/AnimatedFlashList.js.map +1 -0
- package/dist/FlashList.d.ts +126 -0
- package/dist/FlashList.d.ts.map +1 -0
- package/dist/FlashList.js +524 -0
- package/dist/FlashList.js.map +1 -0
- package/dist/FlashListProps.d.ts +256 -0
- package/dist/FlashListProps.d.ts.map +1 -0
- package/dist/FlashListProps.js +9 -0
- package/dist/FlashListProps.js.map +1 -0
- package/dist/GridLayoutProviderWithProps.d.ts +42 -0
- package/dist/GridLayoutProviderWithProps.d.ts.map +1 -0
- package/dist/GridLayoutProviderWithProps.js +115 -0
- package/dist/GridLayoutProviderWithProps.js.map +1 -0
- package/dist/MasonryFlashList.d.ts +51 -0
- package/dist/MasonryFlashList.d.ts.map +1 -0
- package/dist/MasonryFlashList.js +252 -0
- package/dist/MasonryFlashList.js.map +1 -0
- package/dist/PureComponentWrapper.d.ts +22 -0
- package/dist/PureComponentWrapper.d.ts.map +1 -0
- package/dist/PureComponentWrapper.js +37 -0
- package/dist/PureComponentWrapper.js.map +1 -0
- package/dist/__tests__/AverageWindow.test.d.ts +2 -0
- package/dist/__tests__/AverageWindow.test.d.ts.map +1 -0
- package/dist/__tests__/AverageWindow.test.js +69 -0
- package/dist/__tests__/AverageWindow.test.js.map +1 -0
- package/dist/__tests__/ContentContainerUtils.test.d.ts +2 -0
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +1 -0
- package/dist/__tests__/ContentContainerUtils.test.js +85 -0
- package/dist/__tests__/ContentContainerUtils.test.js.map +1 -0
- package/dist/__tests__/FlashList.test.d.ts +2 -0
- package/dist/__tests__/FlashList.test.d.ts.map +1 -0
- package/dist/__tests__/FlashList.test.js +792 -0
- package/dist/__tests__/FlashList.test.js.map +1 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +2 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +1 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +143 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +1 -0
- package/dist/__tests__/MasonryFlashList.test.d.ts +2 -0
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +1 -0
- package/dist/__tests__/MasonryFlashList.test.js +254 -0
- package/dist/__tests__/MasonryFlashList.test.js.map +1 -0
- package/dist/__tests__/PlatformHelper.web.test.d.ts +2 -0
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +1 -0
- package/dist/__tests__/PlatformHelper.web.test.js +33 -0
- package/dist/__tests__/PlatformHelper.web.test.js.map +1 -0
- package/dist/__tests__/ViewabilityHelper.test.d.ts +2 -0
- package/dist/__tests__/ViewabilityHelper.test.d.ts.map +1 -0
- package/dist/__tests__/ViewabilityHelper.test.js +187 -0
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -0
- package/dist/__tests__/helpers/mountFlashList.d.ts +19 -0
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +1 -0
- package/dist/__tests__/helpers/mountFlashList.js +44 -0
- package/dist/__tests__/helpers/mountFlashList.js.map +1 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +18 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +1 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.js +49 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +1 -0
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +2 -0
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +1 -0
- package/dist/__tests__/useBlankAreaTracker.test.js +177 -0
- package/dist/__tests__/useBlankAreaTracker.test.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.d.ts +18 -0
- package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -0
- package/dist/benchmark/AutoScrollHelper.js +68 -0
- package/dist/benchmark/AutoScrollHelper.js.map +1 -0
- package/dist/benchmark/JSFPSMonitor.d.ts +23 -0
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -0
- package/dist/benchmark/JSFPSMonitor.js +65 -0
- package/dist/benchmark/JSFPSMonitor.js.map +1 -0
- package/dist/benchmark/roundToDecimalPlaces.d.ts +2 -0
- package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -0
- package/dist/benchmark/roundToDecimalPlaces.js +9 -0
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -0
- package/dist/benchmark/useBenchmark.d.ts +35 -0
- package/dist/benchmark/useBenchmark.d.ts.map +1 -0
- package/dist/benchmark/useBenchmark.js +167 -0
- package/dist/benchmark/useBenchmark.js.map +1 -0
- package/dist/benchmark/useBlankAreaTracker.d.ts +34 -0
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +1 -0
- package/dist/benchmark/useBlankAreaTracker.js +67 -0
- package/dist/benchmark/useBlankAreaTracker.js.map +1 -0
- package/dist/benchmark/useDataMultiplier.d.ts +9 -0
- package/dist/benchmark/useDataMultiplier.d.ts.map +1 -0
- package/dist/benchmark/useDataMultiplier.js +25 -0
- package/dist/benchmark/useDataMultiplier.js.map +1 -0
- package/dist/benchmark/useFlatListBenchmark.d.ts +13 -0
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -0
- package/dist/benchmark/useFlatListBenchmark.js +100 -0
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -0
- package/dist/errors/CustomError.d.ts +8 -0
- package/dist/errors/CustomError.d.ts.map +1 -0
- package/dist/errors/CustomError.js +14 -0
- package/dist/errors/CustomError.js.map +1 -0
- package/dist/errors/ExceptionList.d.ts +24 -0
- package/dist/errors/ExceptionList.d.ts.map +1 -0
- package/dist/errors/ExceptionList.js +26 -0
- package/dist/errors/ExceptionList.js.map +1 -0
- package/dist/errors/Warnings.d.ts +9 -0
- package/dist/errors/Warnings.d.ts.map +1 -0
- package/dist/errors/Warnings.js +13 -0
- package/dist/errors/Warnings.js.map +1 -0
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +19 -0
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +1 -0
- package/dist/fabric/AutoLayoutNativeComponent.js +29 -0
- package/dist/fabric/AutoLayoutNativeComponent.js.map +1 -0
- package/dist/fabric/CellContainerNativeComponent.d.ts +8 -0
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +1 -0
- package/dist/fabric/CellContainerNativeComponent.js +29 -0
- package/dist/fabric/CellContainerNativeComponent.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutView.d.ts +22 -0
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutView.js +48 -0
- package/dist/native/auto-layout/AutoLayoutView.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +4 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +5 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +4 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +29 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +4 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +16 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +3 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +1 -0
- package/dist/native/cell-container/CellContainer.android.d.ts +6 -0
- package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.android.js +9 -0
- package/dist/native/cell-container/CellContainer.android.js.map +1 -0
- package/dist/native/cell-container/CellContainer.d.ts +8 -0
- package/dist/native/cell-container/CellContainer.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.harmony.d.ts +6 -0
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.harmony.js +32 -0
- package/dist/native/cell-container/CellContainer.harmony.js.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts +6 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.js +9 -0
- package/dist/native/cell-container/CellContainer.ios.js.map +1 -0
- package/dist/native/cell-container/CellContainer.js +11 -0
- package/dist/native/cell-container/CellContainer.js.map +1 -0
- package/dist/native/cell-container/CellContainer.web.d.ts +7 -0
- package/dist/native/cell-container/CellContainer.web.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.web.js +13 -0
- package/dist/native/cell-container/CellContainer.web.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +26 -0
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.android.js +23 -0
- package/dist/native/config/PlatformHelper.android.js.map +1 -0
- package/dist/native/config/PlatformHelper.d.ts +26 -0
- package/dist/native/config/PlatformHelper.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.harmony.d.ts +26 -0
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.harmony.js +22 -0
- package/dist/native/config/PlatformHelper.harmony.js.map +1 -0
- package/dist/native/config/PlatformHelper.ios.d.ts +26 -0
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.ios.js +22 -0
- package/dist/native/config/PlatformHelper.ios.js.map +1 -0
- package/dist/native/config/PlatformHelper.js +23 -0
- package/dist/native/config/PlatformHelper.js.map +1 -0
- package/dist/native/config/PlatformHelper.web.d.ts +27 -0
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -0
- package/dist/native/config/PlatformHelper.web.js +25 -0
- package/dist/native/config/PlatformHelper.web.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/AverageWindow.d.ts +21 -0
- package/dist/utils/AverageWindow.d.ts.map +1 -0
- package/dist/utils/AverageWindow.js +49 -0
- package/dist/utils/AverageWindow.js.map +1 -0
- package/dist/utils/ContentContainerUtils.d.ts +27 -0
- package/dist/utils/ContentContainerUtils.d.ts.map +1 -0
- package/dist/utils/ContentContainerUtils.js +48 -0
- package/dist/utils/ContentContainerUtils.js.map +1 -0
- package/dist/viewability/ViewToken.d.ts +8 -0
- package/dist/viewability/ViewToken.d.ts.map +1 -0
- package/dist/viewability/ViewToken.js +3 -0
- package/dist/viewability/ViewToken.js.map +1 -0
- package/dist/viewability/ViewabilityHelper.d.ts +25 -0
- package/dist/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/viewability/ViewabilityHelper.js +104 -0
- package/dist/viewability/ViewabilityHelper.js.map +1 -0
- package/dist/viewability/ViewabilityManager.d.ts +24 -0
- package/dist/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/viewability/ViewabilityManager.js +94 -0
- package/dist/viewability/ViewabilityManager.js.map +1 -0
- package/harmony/flash_list/BuildProfile.ets +5 -0
- package/harmony/flash_list/LICENSE +7 -0
- package/harmony/flash_list/build-profile.json5 +8 -0
- package/harmony/flash_list/hvigorfile.ts +1 -0
- package/harmony/flash_list/index.ets +29 -0
- package/harmony/flash_list/obfuscation-rules.txt +18 -0
- package/harmony/flash_list/oh-package-lock.json5 +17 -0
- package/harmony/flash_list/oh-package.json5 +13 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +63 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +57 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +140 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +66 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +208 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +78 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +53 -0
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +50 -0
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +80 -0
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +67 -0
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +39 -0
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +40 -0
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +40 -0
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +48 -0
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +78 -0
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +89 -0
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +59 -0
- package/harmony/flash_list/src/main/cpp/Props.cpp +52 -0
- package/harmony/flash_list/src/main/cpp/Props.h +64 -0
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +34 -0
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +48 -0
- package/harmony/flash_list/src/main/ets/Logger.ets +64 -0
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +154 -0
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +252 -0
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +113 -0
- package/harmony/flash_list/src/main/module.json5 +7 -0
- package/harmony/flash_list/src/main/resources/base/element/color.json +8 -0
- package/harmony/flash_list/src/main/resources/base/element/string.json +16 -0
- package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
- package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +16 -0
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +16 -0
- package/harmony/flash_list.har +0 -0
- package/jestSetup.js +16 -0
- package/package.json +88 -0
- package/src/AnimatedFlashList.ts +11 -0
- package/src/FlashList.tsx +870 -0
- package/src/FlashListProps.ts +335 -0
- package/src/GridLayoutProviderWithProps.ts +180 -0
- package/src/MasonryFlashList.tsx +476 -0
- package/src/PureComponentWrapper.tsx +42 -0
- package/src/__tests__/AverageWindow.test.ts +80 -0
- package/src/__tests__/ContentContainerUtils.test.ts +130 -0
- package/src/__tests__/FlashList.test.tsx +886 -0
- package/src/__tests__/GridLayoutProviderWithProps.test.ts +179 -0
- package/src/__tests__/MasonryFlashList.test.ts +292 -0
- package/src/__tests__/PlatformHelper.web.test.ts +45 -0
- package/src/__tests__/ViewabilityHelper.test.ts +283 -0
- package/src/__tests__/helpers/mountFlashList.tsx +62 -0
- package/src/__tests__/helpers/mountMasonryFlashList.tsx +70 -0
- package/src/__tests__/useBlankAreaTracker.test.tsx +204 -0
- package/src/benchmark/AutoScrollHelper.ts +70 -0
- package/src/benchmark/JSFPSMonitor.ts +74 -0
- package/src/benchmark/roundToDecimalPlaces.ts +4 -0
- package/src/benchmark/useBenchmark.ts +240 -0
- package/src/benchmark/useBlankAreaTracker.ts +117 -0
- package/src/benchmark/useDataMultiplier.ts +19 -0
- package/src/benchmark/useFlatListBenchmark.ts +107 -0
- package/src/errors/CustomError.ts +10 -0
- package/src/errors/ExceptionList.ts +28 -0
- package/src/errors/Warnings.ts +15 -0
- package/src/fabric/AutoLayoutNativeComponent.ts +51 -0
- package/src/fabric/CellContainerNativeComponent.ts +34 -0
- package/src/index.ts +43 -0
- package/src/native/auto-layout/AutoLayoutView.tsx +73 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +30 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +17 -0
- package/src/native/cell-container/CellContainer.android.ts +7 -0
- package/src/native/cell-container/CellContainer.harmony.ts +30 -0
- package/src/native/cell-container/CellContainer.ios.ts +6 -0
- package/src/native/cell-container/CellContainer.tsx +14 -0
- package/src/native/cell-container/CellContainer.web.tsx +9 -0
- package/src/native/config/PlatformHelper.android.ts +29 -0
- package/src/native/config/PlatformHelper.harmony.ts +51 -0
- package/src/native/config/PlatformHelper.ios.ts +28 -0
- package/src/native/config/PlatformHelper.ts +29 -0
- package/src/native/config/PlatformHelper.web.ts +34 -0
- package/src/utils/AverageWindow.ts +49 -0
- package/src/utils/ContentContainerUtils.ts +92 -0
- package/src/viewability/ViewToken.ts +7 -0
- package/src/viewability/ViewabilityHelper.ts +162 -0
- package/src/viewability/ViewabilityManager.ts +134 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var ViewabilityHelper_1 = tslib_1.__importDefault(require("./ViewabilityHelper"));
|
|
5
|
+
/**
|
|
6
|
+
* Manager for viewability tracking. It holds multiple viewability callback pairs and keeps them updated.
|
|
7
|
+
*/
|
|
8
|
+
var ViewabilityManager = /** @class */ (function () {
|
|
9
|
+
function ViewabilityManager(flashListRef) {
|
|
10
|
+
var _this = this;
|
|
11
|
+
var _a;
|
|
12
|
+
this.viewabilityHelpers = [];
|
|
13
|
+
this.hasInteracted = false;
|
|
14
|
+
this.dispose = function () {
|
|
15
|
+
_this.viewabilityHelpers.forEach(function (viewabilityHelper) {
|
|
16
|
+
return viewabilityHelper.dispose();
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.onVisibleIndicesChanged = function (all) {
|
|
20
|
+
_this.updateViewableItems(all);
|
|
21
|
+
};
|
|
22
|
+
this.recordInteraction = function () {
|
|
23
|
+
if (_this.hasInteracted) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
_this.hasInteracted = true;
|
|
27
|
+
_this.viewabilityHelpers.forEach(function (viewabilityHelper) {
|
|
28
|
+
viewabilityHelper.hasInteracted = true;
|
|
29
|
+
});
|
|
30
|
+
_this.updateViewableItems();
|
|
31
|
+
};
|
|
32
|
+
this.updateViewableItems = function (newViewableIndices) {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
var listSize = (_b = (_a = _this.flashListRef.recyclerlistview_unsafe) === null || _a === void 0 ? void 0 : _a.getRenderedSize()) !== null && _b !== void 0 ? _b : _this.flashListRef.props.estimatedListSize;
|
|
35
|
+
if (listSize === undefined || !_this.shouldListenToVisibleIndices) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
var scrollOffset = ((_d = (_c = _this.flashListRef.recyclerlistview_unsafe) === null || _c === void 0 ? void 0 : _c.getCurrentScrollOffset()) !== null && _d !== void 0 ? _d : 0) - _this.flashListRef.firstItemOffset;
|
|
39
|
+
_this.viewabilityHelpers.forEach(function (viewabilityHelper) {
|
|
40
|
+
var _a;
|
|
41
|
+
viewabilityHelper.updateViewableItems((_a = _this.flashListRef.props.horizontal) !== null && _a !== void 0 ? _a : false, scrollOffset, listSize, function (index) { var _a; return (_a = _this.flashListRef.recyclerlistview_unsafe) === null || _a === void 0 ? void 0 : _a.getLayout(index); }, newViewableIndices);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new `ViewabilityHelper` instance with `onViewableItemsChanged` callback and `ViewabilityConfig`
|
|
46
|
+
* @returns `ViewabilityHelper` instance
|
|
47
|
+
*/
|
|
48
|
+
this.createViewabilityHelper = function (viewabilityConfig, onViewableItemsChanged) {
|
|
49
|
+
var mapViewToken = function (index, isViewable) {
|
|
50
|
+
var _a;
|
|
51
|
+
var item = (_a = _this.flashListRef.props.data) === null || _a === void 0 ? void 0 : _a[index];
|
|
52
|
+
var key = item === undefined || _this.flashListRef.props.keyExtractor === undefined
|
|
53
|
+
? index.toString()
|
|
54
|
+
: _this.flashListRef.props.keyExtractor(item, index);
|
|
55
|
+
return {
|
|
56
|
+
index: index,
|
|
57
|
+
isViewable: isViewable,
|
|
58
|
+
item: item,
|
|
59
|
+
key: key,
|
|
60
|
+
timestamp: Date.now(),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
return new ViewabilityHelper_1.default(viewabilityConfig, function (indices, newlyVisibleIndices, newlyNonvisibleIndices) {
|
|
64
|
+
onViewableItemsChanged === null || onViewableItemsChanged === void 0 ? void 0 : onViewableItemsChanged({
|
|
65
|
+
viewableItems: indices.map(function (index) { return mapViewToken(index, true); }),
|
|
66
|
+
changed: tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(newlyVisibleIndices.map(function (index) { return mapViewToken(index, true); })), false), tslib_1.__read(newlyNonvisibleIndices.map(function (index) {
|
|
67
|
+
return mapViewToken(index, false);
|
|
68
|
+
})), false),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
this.flashListRef = flashListRef;
|
|
73
|
+
if (flashListRef.props.onViewableItemsChanged !== null &&
|
|
74
|
+
flashListRef.props.onViewableItemsChanged !== undefined) {
|
|
75
|
+
this.viewabilityHelpers.push(this.createViewabilityHelper(flashListRef.props.viewabilityConfig, flashListRef.props.onViewableItemsChanged));
|
|
76
|
+
}
|
|
77
|
+
((_a = flashListRef.props.viewabilityConfigCallbackPairs) !== null && _a !== void 0 ? _a : []).forEach(function (pair) {
|
|
78
|
+
_this.viewabilityHelpers.push(_this.createViewabilityHelper(pair.viewabilityConfig, pair.onViewableItemsChanged));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
Object.defineProperty(ViewabilityManager.prototype, "shouldListenToVisibleIndices", {
|
|
82
|
+
/**
|
|
83
|
+
* @returns true if the viewability manager has any viewability callback pairs registered.
|
|
84
|
+
*/
|
|
85
|
+
get: function () {
|
|
86
|
+
return this.viewabilityHelpers.length > 0;
|
|
87
|
+
},
|
|
88
|
+
enumerable: false,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
return ViewabilityManager;
|
|
92
|
+
}());
|
|
93
|
+
exports.default = ViewabilityManager;
|
|
94
|
+
//# sourceMappingURL=ViewabilityManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewabilityManager.js","sourceRoot":"","sources":["../../src/viewability/ViewabilityManager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2022-present, Shopify Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { RNOHPackage } from "@rnoh/react-native-openharmony";
|
|
25
|
+
export * from './src/main/ets/RNAutoLayoutView'
|
|
26
|
+
export * from './src/main/ets/RNAutoLayoutShadow'
|
|
27
|
+
export * from "./src/main/ets/RNCellContainer"
|
|
28
|
+
|
|
29
|
+
export default class FlashListPackage extends RNOHPackage {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"stableOrder": false
|
|
4
|
+
},
|
|
5
|
+
"lockfileVersion": 3,
|
|
6
|
+
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
|
7
|
+
"specifiers": {
|
|
8
|
+
"rnoh@../rnoh": "rnoh@../rnoh"
|
|
9
|
+
},
|
|
10
|
+
"packages": {
|
|
11
|
+
"rnoh@../rnoh": {
|
|
12
|
+
"name": "rnoh",
|
|
13
|
+
"resolved": "../rnoh",
|
|
14
|
+
"registryType": "local"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/flash-list",
|
|
3
|
+
"version": "1.6.4-rc.1",
|
|
4
|
+
"description": "FlashList is a more performant FlatList replacement",
|
|
5
|
+
"main": "index.ets",
|
|
6
|
+
"author": "Huawei",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
12
|
+
},
|
|
13
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "AutoLayoutNode.h"
|
|
26
|
+
#include <memory>
|
|
27
|
+
#include <glog/logging.h>
|
|
28
|
+
|
|
29
|
+
namespace rnoh {
|
|
30
|
+
|
|
31
|
+
AutoLayoutNode::AutoLayoutNode()
|
|
32
|
+
: ArkUINode(NativeNodeApi::getInstance()->createNode(ArkUI_NodeType::ARKUI_NODE_STACK)) {
|
|
33
|
+
maybeThrow(NativeNodeApi::getInstance()->registerNodeEvent(m_nodeHandle, NODE_EVENT_ON_APPEAR, 0, this));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
void AutoLayoutNode::insertChild(ArkUINode &child, std::size_t index) {
|
|
37
|
+
maybeThrow(NativeNodeApi::getInstance()->insertChildAt(m_nodeHandle, child.getArkUINodeHandle(), index));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void AutoLayoutNode::removeChild(ArkUINode &child) {
|
|
41
|
+
maybeThrow(NativeNodeApi::getInstance()->removeChild(m_nodeHandle, child.getArkUINodeHandle()));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void AutoLayoutNode::onNodeEvent(ArkUI_NodeEventType eventType, EventArgs &eventArgs) {
|
|
45
|
+
if (eventType == ArkUI_NodeEventType::NODE_EVENT_ON_APPEAR) {
|
|
46
|
+
m_autoLayoutNodeDelegate->onAppear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void AutoLayoutNode::setAutoLayoutNodeDelegate(AutoLayoutNodeDelegate *scrollNodeDelegate) {
|
|
51
|
+
m_autoLayoutNodeDelegate = scrollNodeDelegate;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
AutoLayoutNode::~AutoLayoutNode() {
|
|
55
|
+
NativeNodeApi::getInstance()->unregisterNodeEvent(m_nodeHandle, NODE_EVENT_ON_APPEAR);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void AutoLayoutNode::setAlign(int32_t align) {
|
|
59
|
+
ArkUI_NumberValue value[] = {{.i32 = align}};
|
|
60
|
+
ArkUI_AttributeItem item = {.value = value, .size = 1};
|
|
61
|
+
maybeThrow(NativeNodeApi::getInstance()->setAttribute(m_nodeHandle, NODE_STACK_ALIGN_CONTENT, &item));
|
|
62
|
+
}
|
|
63
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#ifndef AUTO_LAYOUT_NODE_H
|
|
2
|
+
#define AUTO_LAYOUT_NODE_H
|
|
3
|
+
/**
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
* SOFTWARE.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
#pragma once
|
|
28
|
+
|
|
29
|
+
#include "RNOH/arkui/ArkUINode.h"
|
|
30
|
+
#include "RNOH/arkui/NativeNodeApi.h"
|
|
31
|
+
|
|
32
|
+
namespace rnoh {
|
|
33
|
+
|
|
34
|
+
class AutoLayoutNodeDelegate {
|
|
35
|
+
public:
|
|
36
|
+
virtual ~AutoLayoutNodeDelegate() = default;
|
|
37
|
+
virtual void onAppear(){};
|
|
38
|
+
virtual void emitBlankAreaEvent(){};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
class AutoLayoutNode : public ArkUINode {
|
|
42
|
+
protected:
|
|
43
|
+
AutoLayoutNodeDelegate *m_autoLayoutNodeDelegate;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
AutoLayoutNode();
|
|
47
|
+
~AutoLayoutNode() override;
|
|
48
|
+
|
|
49
|
+
void insertChild(ArkUINode &child, std::size_t index);
|
|
50
|
+
void removeChild(ArkUINode &child);
|
|
51
|
+
void onNodeEvent(ArkUI_NodeEventType eventType, EventArgs &eventArgs) override;
|
|
52
|
+
void setAutoLayoutNodeDelegate(AutoLayoutNodeDelegate *autoLayoutNodeDelegate);
|
|
53
|
+
void setAlign(int32_t align);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace rnoh
|
|
57
|
+
#endif
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
26
|
+
#include <glog/logging.h>
|
|
27
|
+
#include <sys/param.h>
|
|
28
|
+
#include <thread>
|
|
29
|
+
#include "AutoLayoutShadow.h"
|
|
30
|
+
#include <random>
|
|
31
|
+
|
|
32
|
+
namespace rnoh {
|
|
33
|
+
|
|
34
|
+
/**checks for overlaps or gaps.between adjacent items and then applies a correction (Only Grid layouts with varying
|
|
35
|
+
* spans) Performance: RecyclerListView renders very small number of views and this is not going to trigger multiple
|
|
36
|
+
* layouts on Android side. Not expecting any major perf issu.*/
|
|
37
|
+
void AutoLayoutShadow::clearGapsAndOverlaps(std::vector<CellContainerComponentInstance::Shared> sortedItems) {
|
|
38
|
+
if (sortedItems.empty()) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
Float maxBound = 0;
|
|
42
|
+
Float minBound = INT_MAX;
|
|
43
|
+
Float maxBoundNeighbour = 0;
|
|
44
|
+
lastMaxBoundOverall = 0;
|
|
45
|
+
for (int i = 0; i < sortedItems.size() - 1; i++) {
|
|
46
|
+
auto cell = sortedItems[i];
|
|
47
|
+
auto neighbour = sortedItems[i + 1];
|
|
48
|
+
std::optional<facebook::react::LayoutMetrics> neighbourMetrics;
|
|
49
|
+
// Only apply correction if the next cell is consecutive.
|
|
50
|
+
bool isNeighbourConsecutive = neighbour->getIndex() == cell->getIndex() + 1;
|
|
51
|
+
if (isWithinBounds(cell->getLayoutMetrics())) {
|
|
52
|
+
if (!horizontal) {
|
|
53
|
+
maxBound = MAX(maxBound, cell->getBottom());
|
|
54
|
+
minBound = MIN(minBound, cell->getTop());
|
|
55
|
+
maxBoundNeighbour = maxBound;
|
|
56
|
+
if (isNeighbourConsecutive) {
|
|
57
|
+
neighbourMetrics = neighbour->getLayoutMetrics();
|
|
58
|
+
if (cell->getLeft() < neighbour->getLeft()) {
|
|
59
|
+
if (cell->getRight() != neighbour->getLeft()) {
|
|
60
|
+
neighbourMetrics.value().frame.origin.x = cell->getRight();
|
|
61
|
+
}
|
|
62
|
+
if (cell->getTop() != neighbour->getTop()) {
|
|
63
|
+
neighbourMetrics.value().frame.origin.y = cell->getTop();
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
neighbourMetrics.value().frame.origin.y = maxBound;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (isWithinBounds(*neighbourMetrics)) {
|
|
70
|
+
float bottom = neighbourMetrics->frame.origin.y + neighbourMetrics->frame.size.height;
|
|
71
|
+
maxBoundNeighbour = MAX(maxBound, bottom);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
maxBound = MAX(maxBound, cell->getRight());
|
|
75
|
+
minBound = MIN(minBound, cell->getLeft());
|
|
76
|
+
maxBoundNeighbour = maxBound;
|
|
77
|
+
if (isNeighbourConsecutive) {
|
|
78
|
+
neighbourMetrics = neighbour->getLayoutMetrics();
|
|
79
|
+
if (cell->getTop() < neighbour->getTop()) {
|
|
80
|
+
if (cell->getBottom() != neighbour->getTop()) {
|
|
81
|
+
neighbourMetrics.value().frame.origin.y = cell->getBottom();
|
|
82
|
+
}
|
|
83
|
+
if (cell->getLeft() != neighbour->getLeft()) {
|
|
84
|
+
neighbourMetrics.value().frame.origin.x = cell->getLeft();
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
neighbourMetrics.value().frame.origin.x = maxBound;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (isWithinBounds(*neighbourMetrics)) {
|
|
91
|
+
float right = neighbourMetrics->frame.origin.x + neighbourMetrics->frame.size.width;
|
|
92
|
+
maxBoundNeighbour = MAX(maxBound, right);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (horizontal) {
|
|
97
|
+
lastMaxBoundOverall = MAX(lastMaxBoundOverall, cell->getRight());
|
|
98
|
+
float right = neighbourMetrics->frame.origin.x + neighbourMetrics->frame.size.width;
|
|
99
|
+
lastMaxBoundOverall = MAX(lastMaxBoundOverall, neighbour->getRight());
|
|
100
|
+
} else {
|
|
101
|
+
lastMaxBoundOverall = MAX(lastMaxBoundOverall, cell->getBottom());
|
|
102
|
+
float bottom = neighbourMetrics->frame.origin.y + neighbourMetrics->frame.size.height;
|
|
103
|
+
lastMaxBoundOverall = MAX(lastMaxBoundOverall, bottom);
|
|
104
|
+
}
|
|
105
|
+
cell->setLayout(cell->getLayoutMetrics());
|
|
106
|
+
neighbour->setLayout(neighbourMetrics ? neighbourMetrics.value() : neighbour->getLayoutMetrics());
|
|
107
|
+
}
|
|
108
|
+
lastMaxBound = maxBoundNeighbour;
|
|
109
|
+
lastMinBound = minBound;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Offset provider by react can be one frame behind the real one, it's important that this method is called with
|
|
113
|
+
* offset taken directly from scrollview object*/
|
|
114
|
+
Float AutoLayoutShadow::computeBlankFromGivenOffset(Float actualScrollOffset, Float distanceFromWindowStart,
|
|
115
|
+
Float distanceFromWindowEnd) {
|
|
116
|
+
blankOffsetAtStart = lastMinBound - actualScrollOffset - distanceFromWindowStart;
|
|
117
|
+
blankOffsetAtEnd = actualScrollOffset + windowSize - renderOffset - lastMaxBound - distanceFromWindowEnd;
|
|
118
|
+
return MAX(blankOffsetAtStart, blankOffsetAtEnd);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**It's importance to aviod correcting views outside the render window. An item that isn't being recycled might
|
|
122
|
+
* still remain in the view tree. If views outside get considered then gaps between unused items will cause
|
|
123
|
+
* algorithm to fail.*/
|
|
124
|
+
bool AutoLayoutShadow::isWithinBounds(const facebook::react::LayoutMetrics& metrics) {
|
|
125
|
+
auto boundsStart = scrollOffset - renderOffset;
|
|
126
|
+
auto boundsEnd = scrollOffset + windowSize;
|
|
127
|
+
float top = metrics.frame.origin.y;
|
|
128
|
+
float bottom = metrics.frame.origin.y + metrics.frame.size.height;
|
|
129
|
+
float left = metrics.frame.origin.x;
|
|
130
|
+
float right = metrics.frame.origin.x + metrics.frame.size.width;
|
|
131
|
+
|
|
132
|
+
if (!this->horizontal) {
|
|
133
|
+
return (top >= boundsStart || bottom >= boundsStart) &&
|
|
134
|
+
(top <= boundsEnd || bottom <= boundsEnd);
|
|
135
|
+
} else {
|
|
136
|
+
return (left >= boundsStart || right >= boundsStart) &&
|
|
137
|
+
(left <= boundsEnd || right <= boundsEnd);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
// Created on 5/3/2024.
|
|
27
|
+
//
|
|
28
|
+
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
|
|
29
|
+
// please include "napi/native_api.h".
|
|
30
|
+
|
|
31
|
+
#ifndef HARMONY_AUTOLAYOUTSHADOW_H
|
|
32
|
+
#define HARMONY_AUTOLAYOUTSHADOW_H
|
|
33
|
+
|
|
34
|
+
#include "react/renderer/graphics/Float.h"
|
|
35
|
+
#include "CellContainerComponentInstance.h"
|
|
36
|
+
|
|
37
|
+
using namespace facebook;
|
|
38
|
+
using namespace react;
|
|
39
|
+
|
|
40
|
+
namespace rnoh {
|
|
41
|
+
|
|
42
|
+
class AutoLayoutShadow {
|
|
43
|
+
private:
|
|
44
|
+
Float lastMaxBound; // Tracks where the last pixel is drawn in the visible window
|
|
45
|
+
Float lastMinBound; // Tracks where first pixel is drawn in the visible window
|
|
46
|
+
bool isWithinBounds(const facebook::react::LayoutMetrics& metrics);
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
bool horizontal{false};
|
|
50
|
+
Float scrollOffset{0};
|
|
51
|
+
Float offsetFromStart{0};
|
|
52
|
+
Float windowSize{0};
|
|
53
|
+
Float renderOffset{0};
|
|
54
|
+
Float blankOffsetAtStart{0}; // Tracks blank area from the top
|
|
55
|
+
Float blankOffsetAtEnd{0}; // Tracks blank area from the bottom
|
|
56
|
+
Float lastMaxBoundOverall{0}; // Tracks where the last pixel is drawn in the overall
|
|
57
|
+
|
|
58
|
+
AutoLayoutShadow(){};
|
|
59
|
+
~AutoLayoutShadow(){};
|
|
60
|
+
void clearGapsAndOverlaps(std::vector<CellContainerComponentInstance::Shared> sortedItems);
|
|
61
|
+
Float computeBlankFromGivenOffset(Float actualScrollOffset, Float distanceFromWindowStart,
|
|
62
|
+
Float distanceFromWindowEnd);
|
|
63
|
+
};
|
|
64
|
+
} // namespace rnoh
|
|
65
|
+
|
|
66
|
+
#endif // HARMONY_AUTOLAYOUTSHADOW_H
|