@react-native-ohos/flash-list 1.8.3 → 2.1.1-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 +1 -1
- package/README.OpenSource +1 -1
- package/dist/AnimatedFlashList.d.ts +4 -28
- package/dist/AnimatedFlashList.d.ts.map +1 -1
- package/dist/AnimatedFlashList.js +5 -30
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -179
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +1 -599
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +285 -278
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js +5 -31
- package/dist/FlashListProps.js.map +1 -1
- package/dist/FlashListRef.d.ts +305 -0
- package/dist/FlashListRef.d.ts.map +1 -0
- package/dist/FlashListRef.js +2 -0
- package/dist/FlashListRef.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.d.ts +17 -40
- package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -1
- package/dist/benchmark/AutoScrollHelper.js +59 -90
- package/dist/benchmark/AutoScrollHelper.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts +22 -45
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +59 -87
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.d.ts +1 -24
- package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.js +4 -31
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +40 -57
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +119 -189
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useDataMultiplier.d.ts +8 -31
- package/dist/benchmark/useDataMultiplier.d.ts.map +1 -1
- package/dist/benchmark/useDataMultiplier.js +19 -47
- package/dist/benchmark/useDataMultiplier.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts +14 -35
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +92 -122
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/ErrorMessages.d.ts +16 -0
- package/dist/errors/ErrorMessages.d.ts.map +1 -0
- package/dist/errors/ErrorMessages.js +16 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +6 -0
- package/dist/errors/WarningMessages.d.ts.map +1 -0
- package/dist/errors/WarningMessages.js +7 -0
- package/dist/errors/WarningMessages.js.map +1 -0
- package/dist/index.d.ts +15 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -54
- package/dist/index.js.map +1 -1
- package/dist/isNewArch.d.ts +2 -0
- package/dist/isNewArch.d.ts.map +1 -0
- package/dist/isNewArch.js +22 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +6 -48
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +6 -45
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +6 -48
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.d.ts +29 -48
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.js +29 -44
- package/dist/native/config/PlatformHelper.harmony.js.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +6 -48
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +6 -44
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +6 -45
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +6 -49
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +6 -47
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
- package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
- package/dist/recyclerview/LayoutCommitObserver.js +58 -0
- package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
- package/dist/recyclerview/RecyclerView.d.ts +13 -0
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerView.js +368 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +46 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js +10 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts +78 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.js +343 -0
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts +2 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.js +2 -0
- package/dist/recyclerview/RecyclerViewProps.js.map +1 -0
- package/dist/recyclerview/RenderStackManager.d.ts +86 -0
- package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
- package/dist/recyclerview/RenderStackManager.js +252 -0
- package/dist/recyclerview/RenderStackManager.js.map +1 -0
- package/dist/recyclerview/ViewHolder.d.ts +45 -0
- package/dist/recyclerview/ViewHolder.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolder.js +94 -0
- package/dist/recyclerview/ViewHolder.js.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts +63 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.js +87 -0
- package/dist/recyclerview/ViewHolderCollection.js.map +1 -0
- package/dist/recyclerview/components/CompatScroller.d.ts +7 -0
- package/dist/recyclerview/components/CompatScroller.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatScroller.js +7 -0
- package/dist/recyclerview/components/CompatScroller.js.map +1 -0
- package/dist/recyclerview/components/CompatView.d.ts +7 -0
- package/dist/recyclerview/components/CompatView.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatView.js +7 -0
- package/dist/recyclerview/components/CompatView.js.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts +29 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.js +33 -0
- package/dist/recyclerview/components/ScrollAnchor.js.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts +38 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.js +112 -0
- package/dist/recyclerview/components/StickyHeaders.js.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +51 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js +95 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +105 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js +202 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +14 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js +44 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.js +64 -0
- package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts +17 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.js +132 -0
- package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts +14 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.js +38 -0
- package/dist/recyclerview/hooks/useLayoutState.js.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.js +15 -0
- package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts +25 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.js +67 -0
- package/dist/recyclerview/hooks/useOnLoad.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +28 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js +507 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +8 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js +32 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts +18 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.js +49 -0
- package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts +27 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js +90 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +58 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts +10 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js +25 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +79 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js +221 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts +296 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js +279 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +51 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js +151 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +81 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +269 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts +12 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js +14 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -0
- package/dist/recyclerview/utils/componentUtils.d.ts +19 -0
- package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -0
- package/dist/recyclerview/utils/componentUtils.js +27 -0
- package/dist/recyclerview/utils/componentUtils.js.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts +24 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.js +76 -0
- package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.d.ts +52 -0
- package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.js +99 -0
- package/dist/recyclerview/utils/measureLayout.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.js +79 -0
- package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts +8 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js +2 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts +26 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js +98 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts +25 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js +94 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.d.ts +33 -43
- package/dist/utils/AverageWindow.d.ts.map +1 -1
- package/dist/utils/AverageWindow.js +66 -71
- package/dist/utils/AverageWindow.js.map +1 -1
- package/jestSetup.js +23 -37
- package/package.json +15 -24
- package/src/AnimatedFlashList.ts +2 -25
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +109 -100
- package/src/FlashListRef.ts +320 -0
- package/src/benchmark/AutoScrollHelper.ts +0 -24
- package/src/benchmark/JSFPSMonitor.ts +2 -26
- package/src/benchmark/roundToDecimalPlaces.ts +0 -24
- package/src/benchmark/useBenchmark.ts +59 -105
- package/src/benchmark/useDataMultiplier.ts +0 -24
- package/src/benchmark/useFlatListBenchmark.ts +43 -32
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +9 -0
- package/src/index.ts +18 -46
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +3 -49
- package/src/native/config/PlatformHelper.harmony.ts +3 -24
- package/src/native/config/PlatformHelper.ios.ts +3 -48
- package/src/native/config/PlatformHelper.ts +3 -49
- package/src/native/config/PlatformHelper.web.ts +4 -55
- package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
- package/src/recyclerview/RecyclerView.tsx +616 -0
- package/src/recyclerview/RecyclerViewContextProvider.ts +65 -0
- package/src/recyclerview/RecyclerViewManager.ts +461 -0
- package/src/recyclerview/RecyclerViewProps.ts +1 -0
- package/src/recyclerview/RenderStackManager.ts +317 -0
- package/src/recyclerview/ViewHolder.tsx +180 -0
- package/src/recyclerview/ViewHolderCollection.tsx +193 -0
- package/src/recyclerview/components/CompatScroller.ts +9 -0
- package/src/recyclerview/components/CompatView.ts +9 -0
- package/src/recyclerview/components/ScrollAnchor.tsx +66 -0
- package/src/recyclerview/components/StickyHeaders.tsx +222 -0
- package/src/recyclerview/helpers/ConsecutiveNumbers.ts +120 -0
- package/src/recyclerview/helpers/EngagedIndicesTracker.ts +301 -0
- package/src/recyclerview/helpers/RenderTimeTracker.ts +50 -0
- package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
- package/src/recyclerview/hooks/useBoundDetection.ts +176 -0
- package/src/recyclerview/hooks/useLayoutState.ts +55 -0
- package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
- package/src/recyclerview/hooks/useOnLoad.ts +80 -0
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +633 -0
- package/src/recyclerview/hooks/useRecyclerViewManager.ts +42 -0
- package/src/recyclerview/hooks/useRecyclingState.ts +67 -0
- package/src/recyclerview/hooks/useSecondaryProps.tsx +124 -0
- package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
- package/src/recyclerview/hooks/useUnmountFlag.ts +27 -0
- package/src/recyclerview/layout-managers/GridLayoutManager.ts +256 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +568 -0
- package/src/recyclerview/layout-managers/LinearLayoutManager.ts +171 -0
- package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +323 -0
- package/src/recyclerview/utils/adjustOffsetForRTL.ts +17 -0
- package/src/recyclerview/utils/componentUtils.ts +28 -0
- package/src/recyclerview/utils/findVisibleIndex.ts +93 -0
- package/src/recyclerview/utils/measureLayout.ts +128 -0
- package/src/recyclerview/utils/measureLayout.web.ts +102 -0
- package/src/recyclerview/viewability/ViewToken.ts +7 -0
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -33
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +23 -46
- package/src/utils/AverageWindow.ts +33 -24
- package/dist/GridLayoutProviderWithProps.d.ts +0 -65
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -138
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -74
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -275
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -45
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -60
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -57
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -90
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -31
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -37
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -47
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -49
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -32
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -36
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +0 -42
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.js +0 -29
- package/dist/fabric/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.d.ts +0 -31
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.js +0 -29
- package/dist/fabric/CellContainerNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -45
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -71
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -39
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -26
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -32
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -31
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.js +0 -32
- package/dist/native/cell-container/CellContainer.harmony.js.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -32
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -34
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -30
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -36
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -50
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -71
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts +0 -31
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js +0 -26
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts +0 -49
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityHelper.js +0 -130
- package/dist/viewability/ViewabilityHelper.js.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts +0 -48
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js +0 -131
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/harmony/flash_list/BuildProfile.ets +0 -17
- package/harmony/flash_list/LICENSE +0 -7
- package/harmony/flash_list/build-profile.json5 +0 -8
- package/harmony/flash_list/hvigorfile.ts +0 -1
- package/harmony/flash_list/index.ets +0 -27
- package/harmony/flash_list/obfuscation-rules.txt +0 -18
- package/harmony/flash_list/oh-package.json5 +0 -24
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +0 -63
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +0 -54
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +0 -140
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +0 -66
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +0 -208
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +0 -78
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +0 -53
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +0 -50
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +0 -12
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +0 -80
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +0 -64
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +0 -39
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +0 -48
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +0 -85
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +0 -87
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +0 -57
- package/harmony/flash_list/src/main/cpp/Props.cpp +0 -52
- package/harmony/flash_list/src/main/cpp/Props.h +0 -64
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +0 -34
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +0 -48
- package/harmony/flash_list/src/main/ets/Logger.ets +0 -64
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +0 -154
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +0 -277
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +0 -113
- package/harmony/flash_list/src/main/module.json5 +0 -9
- package/harmony/flash_list/src/main/resources/base/element/color.json +0 -8
- package/harmony/flash_list/src/main/resources/base/element/string.json +0 -16
- 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 +0 -5
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +0 -16
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +0 -16
- package/harmony/flash_list.har +0 -0
- package/src/FlashList.tsx +0 -949
- package/src/GridLayoutProviderWithProps.ts +0 -204
- package/src/MasonryFlashList.tsx +0 -499
- package/src/PureComponentWrapper.tsx +0 -65
- package/src/benchmark/useBlankAreaTracker.ts +0 -141
- package/src/errors/CustomError.ts +0 -34
- package/src/errors/ExceptionList.ts +0 -52
- package/src/errors/Warnings.ts +0 -39
- package/src/fabric/AutoLayoutNativeComponent.ts +0 -52
- package/src/fabric/CellContainerNativeComponent.ts +0 -35
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -97
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -41
- package/src/native/cell-container/CellContainer.android.ts +0 -31
- package/src/native/cell-container/CellContainer.harmony.ts +0 -31
- package/src/native/cell-container/CellContainer.ios.ts +0 -31
- package/src/native/cell-container/CellContainer.tsx +0 -38
- package/src/native/cell-container/CellContainer.web.tsx +0 -33
- package/src/utils/ContentContainerUtils.ts +0 -116
- package/src/viewability/ViewToken.ts +0 -31
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
// Interface of layout manager for app's listviews
|
|
2
|
+
|
|
3
|
+
import { MultiTypeAverageWindow } from "../../utils/AverageWindow";
|
|
4
|
+
import { ConsecutiveNumbers } from "../helpers/ConsecutiveNumbers";
|
|
5
|
+
import {
|
|
6
|
+
findFirstVisibleIndex,
|
|
7
|
+
findLastVisibleIndex,
|
|
8
|
+
} from "../utils/findVisibleIndex";
|
|
9
|
+
import { areDimensionsNotEqual } from "../utils/measureLayout";
|
|
10
|
+
import { ErrorMessages } from "../../errors/ErrorMessages";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Base abstract class for layout managers in the recycler view system.
|
|
14
|
+
* Provides common functionality for managing item layouts and dimensions.
|
|
15
|
+
* Supports both horizontal and vertical layouts with dynamic item sizing.
|
|
16
|
+
*/
|
|
17
|
+
export abstract class RVLayoutManager {
|
|
18
|
+
/** Whether the layout is horizontal (true) or vertical (false) */
|
|
19
|
+
protected horizontal: boolean;
|
|
20
|
+
/** Array of layout information for all items */
|
|
21
|
+
protected layouts: RVLayout[];
|
|
22
|
+
/** Dimensions of the visible window/viewport */
|
|
23
|
+
protected windowSize: RVDimension;
|
|
24
|
+
/** Maximum number of columns in the layout */
|
|
25
|
+
protected maxColumns: number;
|
|
26
|
+
|
|
27
|
+
/** Whether to optimize item placement for better space utilization */
|
|
28
|
+
protected optimizeItemArrangement: boolean;
|
|
29
|
+
|
|
30
|
+
/** Flag indicating if the layout requires repainting */
|
|
31
|
+
public requiresRepaint = false;
|
|
32
|
+
|
|
33
|
+
/** Optional callback to override default item layout */
|
|
34
|
+
private overrideItemLayout: (index: number, layout: SpanSizeInfo) => void;
|
|
35
|
+
/** Optional function to determine item type */
|
|
36
|
+
private getItemType: (index: number) => string;
|
|
37
|
+
/** Window for tracking average heights by item type */
|
|
38
|
+
private heightAverageWindow: MultiTypeAverageWindow;
|
|
39
|
+
/** Window for tracking average widths by item type */
|
|
40
|
+
private widthAverageWindow: MultiTypeAverageWindow;
|
|
41
|
+
/** Maximum number of items to process in a single layout pass */
|
|
42
|
+
private maxItemsToProcess = 250;
|
|
43
|
+
/** Information about item spans and sizes */
|
|
44
|
+
private spanSizeInfo: SpanSizeInfo = {};
|
|
45
|
+
/** Span tracker for each item */
|
|
46
|
+
private spanTracker: (number | undefined)[] = [];
|
|
47
|
+
|
|
48
|
+
/** Current max index with changed layout */
|
|
49
|
+
private currentMaxIndexWithChangedLayout = -1;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Last index that was skipped during layout computation.
|
|
53
|
+
* Used to determine if a layout needs to be recomputed.
|
|
54
|
+
*/
|
|
55
|
+
private lastSkippedLayoutIndex = Number.MAX_VALUE;
|
|
56
|
+
|
|
57
|
+
constructor(params: LayoutParams, previousLayoutManager?: RVLayoutManager) {
|
|
58
|
+
this.heightAverageWindow = new MultiTypeAverageWindow(5, 200);
|
|
59
|
+
this.widthAverageWindow = new MultiTypeAverageWindow(5, 200);
|
|
60
|
+
this.getItemType = params.getItemType;
|
|
61
|
+
this.overrideItemLayout = params.overrideItemLayout;
|
|
62
|
+
this.layouts = previousLayoutManager?.layouts ?? [];
|
|
63
|
+
if (previousLayoutManager) {
|
|
64
|
+
this.updateLayoutParams(params);
|
|
65
|
+
} else {
|
|
66
|
+
this.horizontal = Boolean(params.horizontal);
|
|
67
|
+
this.windowSize = params.windowSize;
|
|
68
|
+
this.maxColumns = params.maxColumns ?? 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets the estimated width for an item based on its type.
|
|
74
|
+
* @param index Index of the item
|
|
75
|
+
* @returns Estimated width
|
|
76
|
+
*/
|
|
77
|
+
protected getEstimatedWidth(index: number): number {
|
|
78
|
+
return this.widthAverageWindow.getCurrentValue(this.getItemType(index));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Gets the estimated height for an item based on its type.
|
|
83
|
+
* @param index Index of the item
|
|
84
|
+
* @returns Estimated height
|
|
85
|
+
*/
|
|
86
|
+
protected getEstimatedHeight(index: number): number {
|
|
87
|
+
return this.heightAverageWindow.getCurrentValue(this.getItemType(index));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Abstract method to process layout information for items.
|
|
92
|
+
* @param layoutInfo Array of layout information for items
|
|
93
|
+
* @param itemCount Total number of items in the list
|
|
94
|
+
* @returns Index of first modified layout or void
|
|
95
|
+
*/
|
|
96
|
+
protected abstract processLayoutInfo(
|
|
97
|
+
layoutInfo: RVLayoutInfo[],
|
|
98
|
+
itemCount: number
|
|
99
|
+
): number | void;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Checks if the layout is horizontal.
|
|
103
|
+
* @returns True if horizontal, false if vertical
|
|
104
|
+
*/
|
|
105
|
+
isHorizontal(): boolean {
|
|
106
|
+
return this.horizontal;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Gets the dimensions of the visible window.
|
|
111
|
+
* @returns Window dimensions
|
|
112
|
+
*/
|
|
113
|
+
getWindowsSize(): RVDimension {
|
|
114
|
+
return this.windowSize;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Gets indices of items currently visible in the viewport.
|
|
119
|
+
* Uses binary search for efficient lookup.
|
|
120
|
+
* @param unboundDimensionStart Start position of viewport (start X or start Y)
|
|
121
|
+
* @param unboundDimensionEnd End position of viewport (end X or end Y)
|
|
122
|
+
* @returns ConsecutiveNumbers containing visible indices
|
|
123
|
+
*/
|
|
124
|
+
getVisibleLayouts(
|
|
125
|
+
unboundDimensionStart: number,
|
|
126
|
+
unboundDimensionEnd: number
|
|
127
|
+
): ConsecutiveNumbers {
|
|
128
|
+
// Find the first visible index
|
|
129
|
+
const firstVisibleIndex = findFirstVisibleIndex(
|
|
130
|
+
this.layouts,
|
|
131
|
+
unboundDimensionStart,
|
|
132
|
+
this.horizontal
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// Find the last visible index
|
|
136
|
+
const lastVisibleIndex = findLastVisibleIndex(
|
|
137
|
+
this.layouts,
|
|
138
|
+
unboundDimensionEnd,
|
|
139
|
+
this.horizontal
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
// Collect the indices in the range
|
|
143
|
+
if (firstVisibleIndex !== -1 && lastVisibleIndex !== -1) {
|
|
144
|
+
return new ConsecutiveNumbers(firstVisibleIndex, lastVisibleIndex);
|
|
145
|
+
}
|
|
146
|
+
return ConsecutiveNumbers.EMPTY;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Removes layout information for specified indices and recomputes layout.
|
|
151
|
+
* @param indices Array of indices to remove
|
|
152
|
+
*/
|
|
153
|
+
deleteLayout(indices: number[]): void {
|
|
154
|
+
// Sort indices in descending order
|
|
155
|
+
indices.sort((num1, num2) => num2 - num1);
|
|
156
|
+
|
|
157
|
+
// Remove elements from the array
|
|
158
|
+
for (const index of indices) {
|
|
159
|
+
this.layouts.splice(index, 1);
|
|
160
|
+
}
|
|
161
|
+
const startIndex = Math.min(...indices);
|
|
162
|
+
// Recompute layouts starting from the smallest index in the original indices array
|
|
163
|
+
this._recomputeLayouts(
|
|
164
|
+
this.getMinRecomputeIndex(startIndex),
|
|
165
|
+
this.getMaxRecomputeIndex(startIndex)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Updates layout information for items and recomputes layout if necessary.
|
|
171
|
+
* @param layoutInfo Array of layout information for items (real measurements)
|
|
172
|
+
* @param totalItemCount Total number of items in the list
|
|
173
|
+
*/
|
|
174
|
+
modifyLayout(layoutInfo: RVLayoutInfo[], totalItemCount: number): void {
|
|
175
|
+
this.maxItemsToProcess = Math.max(
|
|
176
|
+
this.maxItemsToProcess,
|
|
177
|
+
layoutInfo.length * 10
|
|
178
|
+
);
|
|
179
|
+
let minRecomputeIndex = Number.MAX_VALUE;
|
|
180
|
+
|
|
181
|
+
if (this.layouts.length > totalItemCount) {
|
|
182
|
+
this.layouts.length = totalItemCount;
|
|
183
|
+
this.spanTracker.length = totalItemCount;
|
|
184
|
+
minRecomputeIndex = totalItemCount - 1; // <0 gets skipped so it's safe to set to totalItemCount - 1
|
|
185
|
+
}
|
|
186
|
+
// update average windows
|
|
187
|
+
minRecomputeIndex = Math.min(
|
|
188
|
+
minRecomputeIndex,
|
|
189
|
+
this.computeEstimatesAndMinMaxChangedLayout(layoutInfo)
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
if (this.layouts.length < totalItemCount && totalItemCount > 0) {
|
|
193
|
+
const startIndex = this.layouts.length;
|
|
194
|
+
this.layouts.length = totalItemCount;
|
|
195
|
+
this.spanTracker.length = totalItemCount;
|
|
196
|
+
for (let i = startIndex; i < totalItemCount; i++) {
|
|
197
|
+
this.getLayout(i);
|
|
198
|
+
this.getSpan(i);
|
|
199
|
+
}
|
|
200
|
+
this.recomputeLayouts(startIndex, totalItemCount - 1);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// compute minRecomputeIndex
|
|
204
|
+
|
|
205
|
+
minRecomputeIndex = Math.min(
|
|
206
|
+
minRecomputeIndex,
|
|
207
|
+
this.lastSkippedLayoutIndex,
|
|
208
|
+
this.computeMinIndexWithChangedSpan(layoutInfo),
|
|
209
|
+
this.processLayoutInfo(layoutInfo, totalItemCount) ?? minRecomputeIndex,
|
|
210
|
+
this.computeEstimatesAndMinMaxChangedLayout(layoutInfo)
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
if (minRecomputeIndex >= 0 && minRecomputeIndex < totalItemCount) {
|
|
214
|
+
const maxRecomputeIndex = this.getMaxRecomputeIndex(minRecomputeIndex);
|
|
215
|
+
this._recomputeLayouts(minRecomputeIndex, maxRecomputeIndex);
|
|
216
|
+
}
|
|
217
|
+
this.currentMaxIndexWithChangedLayout = -1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Gets layout information for an item at the given index.
|
|
222
|
+
* Creates and initializes a new layout if one doesn't exist.
|
|
223
|
+
* @param index Index of the item
|
|
224
|
+
* @returns Layout information for the item
|
|
225
|
+
*/
|
|
226
|
+
getLayout(index: number): RVLayout {
|
|
227
|
+
if (index >= this.layouts.length) {
|
|
228
|
+
throw new Error(ErrorMessages.indexOutOfBounds);
|
|
229
|
+
}
|
|
230
|
+
let layout = this.layouts[index];
|
|
231
|
+
if (!layout) {
|
|
232
|
+
// Create new layout with estimated dimensions
|
|
233
|
+
layout = {
|
|
234
|
+
x: 0,
|
|
235
|
+
y: 0,
|
|
236
|
+
width: 0,
|
|
237
|
+
height: 0,
|
|
238
|
+
};
|
|
239
|
+
this.layouts[index] = layout;
|
|
240
|
+
}
|
|
241
|
+
if (!layout.isWidthMeasured || !layout.isHeightMeasured) {
|
|
242
|
+
this.estimateLayout(index);
|
|
243
|
+
}
|
|
244
|
+
return layout;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Updates layout parameters and triggers recomputation if necessary.
|
|
249
|
+
* @param params New layout parameters
|
|
250
|
+
*/
|
|
251
|
+
updateLayoutParams(params: LayoutParams) {
|
|
252
|
+
this.windowSize = params.windowSize;
|
|
253
|
+
this.horizontal = params.horizontal ?? this.horizontal;
|
|
254
|
+
this.maxColumns = params.maxColumns ?? this.maxColumns;
|
|
255
|
+
this.optimizeItemArrangement =
|
|
256
|
+
params.optimizeItemArrangement ?? this.optimizeItemArrangement;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getLayoutCount(): number {
|
|
260
|
+
return this.layouts.length;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Abstract method to recompute layouts for items in the given range.
|
|
265
|
+
* @param startIndex Starting index of items to recompute
|
|
266
|
+
* @param endIndex Ending index of items to recompute
|
|
267
|
+
*/
|
|
268
|
+
abstract recomputeLayouts(startIndex: number, endIndex: number): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Abstract method to get the total size of the layout area.
|
|
272
|
+
* @returns RVDimension containing width and height of the layout
|
|
273
|
+
*/
|
|
274
|
+
abstract getLayoutSize(): RVDimension;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Abstract method to estimate layout dimensions for an item.
|
|
278
|
+
* @param index Index of the item to estimate layout for
|
|
279
|
+
*/
|
|
280
|
+
protected abstract estimateLayout(index: number): void;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Gets span for an item, applying any overrides.
|
|
284
|
+
* This is intended to be called during a relayout call. The value is tracked and used to determine if a span change has occurred.
|
|
285
|
+
* If skipTracking is true, the operation is not tracked. Can be useful if span is required outside of a relayout call.
|
|
286
|
+
* The tracker is used to call handleSpanChange if a span change has occurred before relayout call.
|
|
287
|
+
* // TODO: improve this contract.
|
|
288
|
+
* @param index Index of the item
|
|
289
|
+
* @returns Span for the item
|
|
290
|
+
*/
|
|
291
|
+
protected getSpan(index: number, skipTracking = false): number {
|
|
292
|
+
this.spanSizeInfo.span = undefined;
|
|
293
|
+
this.overrideItemLayout(index, this.spanSizeInfo);
|
|
294
|
+
const span = Math.min(this.spanSizeInfo.span ?? 1, this.maxColumns);
|
|
295
|
+
if (!skipTracking) {
|
|
296
|
+
this.spanTracker[index] = span;
|
|
297
|
+
}
|
|
298
|
+
return span;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Method to handle span change for an item. Can be overridden by subclasses.
|
|
303
|
+
* @param index Index of the item
|
|
304
|
+
*/
|
|
305
|
+
protected handleSpanChange(index: number) {}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Gets the maximum index to process in a single layout pass.
|
|
309
|
+
* @param startIndex Starting index
|
|
310
|
+
* @returns Maximum index to process
|
|
311
|
+
*/
|
|
312
|
+
private getMaxRecomputeIndex(startIndex: number): number {
|
|
313
|
+
return Math.min(
|
|
314
|
+
Math.max(startIndex, this.currentMaxIndexWithChangedLayout) +
|
|
315
|
+
this.maxItemsToProcess,
|
|
316
|
+
this.layouts.length - 1
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Gets the minimum index to process in a single layout pass.
|
|
322
|
+
* @param startIndex Starting index
|
|
323
|
+
* @returns Minimum index to process
|
|
324
|
+
*/
|
|
325
|
+
private getMinRecomputeIndex(startIndex: number): number {
|
|
326
|
+
return startIndex;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
private _recomputeLayouts(startIndex: number, endIndex: number): void {
|
|
330
|
+
this.recomputeLayouts(startIndex, endIndex);
|
|
331
|
+
if (
|
|
332
|
+
this.lastSkippedLayoutIndex >= startIndex &&
|
|
333
|
+
this.lastSkippedLayoutIndex <= endIndex
|
|
334
|
+
) {
|
|
335
|
+
this.lastSkippedLayoutIndex = Number.MAX_VALUE;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (endIndex + 1 < this.layouts.length) {
|
|
339
|
+
this.lastSkippedLayoutIndex = Math.min(
|
|
340
|
+
endIndex + 1,
|
|
341
|
+
this.lastSkippedLayoutIndex
|
|
342
|
+
);
|
|
343
|
+
const lastIndex = this.layouts.length - 1;
|
|
344
|
+
// Since layout managers derive height from last indices we need to make
|
|
345
|
+
// sure they're not too much out of sync.
|
|
346
|
+
if (this.layouts[lastIndex].y < this.layouts[endIndex].y) {
|
|
347
|
+
this.recomputeLayouts(this.lastSkippedLayoutIndex, lastIndex);
|
|
348
|
+
this.lastSkippedLayoutIndex = Number.MAX_VALUE;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Computes size estimates and finds the minimum recompute index.
|
|
355
|
+
* @param layoutInfo Array of layout information for items
|
|
356
|
+
* @returns Minimum index that needs recomputation
|
|
357
|
+
*/
|
|
358
|
+
private computeEstimatesAndMinMaxChangedLayout(
|
|
359
|
+
layoutInfo: RVLayoutInfo[]
|
|
360
|
+
): number {
|
|
361
|
+
let minRecomputeIndex = Number.MAX_VALUE;
|
|
362
|
+
for (const info of layoutInfo) {
|
|
363
|
+
const { index, dimensions } = info;
|
|
364
|
+
const storedLayout = this.layouts[index];
|
|
365
|
+
if (
|
|
366
|
+
index >= this.lastSkippedLayoutIndex ||
|
|
367
|
+
!storedLayout ||
|
|
368
|
+
!storedLayout.isHeightMeasured ||
|
|
369
|
+
!storedLayout.isWidthMeasured ||
|
|
370
|
+
areDimensionsNotEqual(storedLayout.height, dimensions.height) ||
|
|
371
|
+
areDimensionsNotEqual(storedLayout.width, dimensions.width)
|
|
372
|
+
) {
|
|
373
|
+
minRecomputeIndex = Math.min(minRecomputeIndex, index);
|
|
374
|
+
this.currentMaxIndexWithChangedLayout = Math.max(
|
|
375
|
+
this.currentMaxIndexWithChangedLayout,
|
|
376
|
+
index
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
this.heightAverageWindow.addValue(
|
|
380
|
+
dimensions.height,
|
|
381
|
+
this.getItemType(index)
|
|
382
|
+
);
|
|
383
|
+
this.widthAverageWindow.addValue(
|
|
384
|
+
dimensions.width,
|
|
385
|
+
this.getItemType(index)
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
return minRecomputeIndex;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
private computeMinIndexWithChangedSpan(layoutInfo: RVLayoutInfo[]): number {
|
|
392
|
+
let minIndexWithChangedSpan = Number.MAX_VALUE;
|
|
393
|
+
for (const info of layoutInfo) {
|
|
394
|
+
const { index } = info;
|
|
395
|
+
const span = this.getSpan(index, true);
|
|
396
|
+
const storedSpan = this.spanTracker[index];
|
|
397
|
+
if (span !== storedSpan) {
|
|
398
|
+
this.spanTracker[index] = span;
|
|
399
|
+
this.handleSpanChange(index);
|
|
400
|
+
minIndexWithChangedSpan = Math.min(minIndexWithChangedSpan, index);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return minIndexWithChangedSpan;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Configuration parameters for the layout manager
|
|
409
|
+
*/
|
|
410
|
+
export interface LayoutParams {
|
|
411
|
+
/**
|
|
412
|
+
* The dimensions of the visible window/viewport that displays list items
|
|
413
|
+
* Used to determine which items are visible and need to be rendered
|
|
414
|
+
*/
|
|
415
|
+
windowSize: RVDimension;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Determines if the list scrolls horizontally (true) or vertically (false)
|
|
419
|
+
* Affects how items are positioned and which dimension is used for scrolling
|
|
420
|
+
*/
|
|
421
|
+
horizontal: boolean;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Maximum number of columns in a grid layout
|
|
425
|
+
* Controls how many items can be placed side by side
|
|
426
|
+
*/
|
|
427
|
+
maxColumns: number;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* When true, attempts to optimize item placement for better space utilization
|
|
431
|
+
* May affect the ordering of items to minimize empty space
|
|
432
|
+
*/
|
|
433
|
+
optimizeItemArrangement: boolean;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Callback to manually override layout properties for specific items
|
|
437
|
+
* Allows custom control over span and size for individual items
|
|
438
|
+
*/
|
|
439
|
+
overrideItemLayout: (index: number, layout: SpanSizeInfo) => void;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Function to determine the type of an item at a specific index
|
|
443
|
+
* Used for size estimation and optimization based on item types
|
|
444
|
+
*/
|
|
445
|
+
getItemType: (index: number) => string;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Information about an item's layout including its index and dimensions
|
|
450
|
+
* Used when updating layout information for specific items
|
|
451
|
+
*/
|
|
452
|
+
export interface RVLayoutInfo {
|
|
453
|
+
/**
|
|
454
|
+
* The index of the item in the data array
|
|
455
|
+
* Used to identify which item this layout information belongs to
|
|
456
|
+
*/
|
|
457
|
+
index: number;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The width and height dimensions of the item
|
|
461
|
+
* Used to update the layout manager's knowledge of item sizes
|
|
462
|
+
*/
|
|
463
|
+
dimensions: RVDimension;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Information about an item's span and size in a grid layout
|
|
468
|
+
* Used when overriding default layout behavior for specific items
|
|
469
|
+
*/
|
|
470
|
+
export interface SpanSizeInfo {
|
|
471
|
+
/**
|
|
472
|
+
* Number of columns/cells this item should span horizontally
|
|
473
|
+
* Used in grid layouts to allow items to take up multiple columns
|
|
474
|
+
*/
|
|
475
|
+
span?: number;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Custom size value for the item
|
|
479
|
+
* Can be used to override the default size calculation
|
|
480
|
+
*/
|
|
481
|
+
size?: number;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Complete layout information for a list item
|
|
486
|
+
* Extends RVDimension with positioning and constraint properties
|
|
487
|
+
* Used to position and size ViewHolder components in the list
|
|
488
|
+
*/
|
|
489
|
+
export interface RVLayout extends RVDimension {
|
|
490
|
+
/**
|
|
491
|
+
* X-coordinate (horizontal position) in pixels
|
|
492
|
+
* Used to position the item horizontally with absolute positioning
|
|
493
|
+
*/
|
|
494
|
+
x: number;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Y-coordinate (vertical position) in pixels
|
|
498
|
+
* Used to position the item vertically with absolute positioning
|
|
499
|
+
*/
|
|
500
|
+
y: number;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Indicates if the width has been measured from the actual rendered item
|
|
504
|
+
* When false, width may be an estimated value
|
|
505
|
+
*/
|
|
506
|
+
isWidthMeasured?: boolean;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Indicates if the height has been measured from the actual rendered item
|
|
510
|
+
* When false, height may be an estimated value
|
|
511
|
+
*/
|
|
512
|
+
isHeightMeasured?: boolean;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Minimum height constraint in pixels
|
|
516
|
+
* Applied to the ViewHolder's style to ensure item doesn't shrink below this value
|
|
517
|
+
*/
|
|
518
|
+
minHeight?: number;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Minimum width constraint in pixels
|
|
522
|
+
* Applied to the ViewHolder's style to ensure item doesn't shrink below this value
|
|
523
|
+
*/
|
|
524
|
+
minWidth?: number;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Maximum height constraint in pixels
|
|
528
|
+
* Applied to the ViewHolder's style to limit item's vertical growth
|
|
529
|
+
*/
|
|
530
|
+
maxHeight?: number;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Maximum width constraint in pixels
|
|
534
|
+
* Applied to the ViewHolder's style to limit item's horizontal growth
|
|
535
|
+
*/
|
|
536
|
+
maxWidth?: number;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* When true, the width value is strictly enforced on the ViewHolder
|
|
540
|
+
* When false, the width is determined by content
|
|
541
|
+
*/
|
|
542
|
+
enforcedWidth?: boolean;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* When true, the height value is strictly enforced on the ViewHolder
|
|
546
|
+
* When false, the height is determined by content
|
|
547
|
+
*/
|
|
548
|
+
enforcedHeight?: boolean;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Basic dimension interface representing width and height
|
|
553
|
+
* Used throughout the recycler view system to track item sizes
|
|
554
|
+
* and viewport dimensions
|
|
555
|
+
*/
|
|
556
|
+
export interface RVDimension {
|
|
557
|
+
/**
|
|
558
|
+
* Width in pixels
|
|
559
|
+
* Used for horizontal measurement and positioning
|
|
560
|
+
*/
|
|
561
|
+
width: number;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Height in pixels
|
|
565
|
+
* Used for vertical measurement and positioning
|
|
566
|
+
*/
|
|
567
|
+
height: number;
|
|
568
|
+
}
|