react-native-nitro-list 0.1.1 → 0.1.2
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/ios/HybridNitroList.swift +10 -14
- package/lib/commonjs/cell/CellKeyGenerator.js +21 -0
- package/lib/commonjs/cell/CellKeyGenerator.js.map +1 -0
- package/lib/commonjs/cell/CellRecycler.js +48 -40
- package/lib/commonjs/cell/CellRecycler.js.map +1 -1
- package/lib/commonjs/cell/createCell.js +21 -0
- package/lib/commonjs/cell/createCell.js.map +1 -0
- package/lib/commonjs/cell/index.js +20 -0
- package/lib/commonjs/cell/index.js.map +1 -0
- package/lib/commonjs/getVisibleIndices.js.map +1 -1
- package/lib/commonjs/hooks/usePersistentCallback.js +36 -0
- package/lib/commonjs/hooks/usePersistentCallback.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/layout/MutableLinearLayout.js +78 -39
- package/lib/commonjs/layout/MutableLinearLayout.js.map +1 -1
- package/lib/commonjs/layout/constants/layoutDefaults.js +19 -0
- package/lib/commonjs/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/commonjs/layout/index.js +0 -18
- package/lib/commonjs/layout/index.js.map +1 -1
- package/lib/commonjs/recycler/CellPool.js +46 -0
- package/lib/commonjs/recycler/CellPool.js.map +1 -0
- package/lib/commonjs/recycler/RecyclerList.js +224 -0
- package/lib/commonjs/recycler/RecyclerList.js.map +1 -0
- package/lib/commonjs/types/Axis.js +2 -0
- package/lib/commonjs/{layout/LayoutProvider.js.map → types/Axis.js.map} +1 -1
- package/lib/commonjs/types/CellKey.js +2 -0
- package/lib/{module/layout/LayoutProvider.js.map → commonjs/types/CellKey.js.map} +1 -1
- package/lib/commonjs/types/CellType.js +2 -0
- package/lib/commonjs/{layout/LayoutRectangle.js.map → types/CellType.js.map} +1 -1
- package/lib/commonjs/types/VisibleRange.js +2 -0
- package/lib/{module/layout/LayoutRectangle.js.map → commonjs/types/VisibleRange.js.map} +1 -1
- package/lib/commonjs/{RecyclerList.types.js → types/VisibleRangeInput.js} +1 -1
- package/lib/commonjs/types/VisibleRangeInput.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/layout/LayoutRect.js +2 -0
- package/lib/commonjs/types/layout/LayoutRect.js.map +1 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js +6 -0
- package/lib/commonjs/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js +26 -0
- package/lib/commonjs/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/commonjs/types/layout/index.js +2 -0
- package/lib/commonjs/types/layout/index.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js +6 -0
- package/lib/commonjs/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/commonjs/types/recycler/index.js +2 -0
- package/lib/commonjs/types/recycler/index.js.map +1 -0
- package/lib/commonjs/{layout/LayoutProvider.js → types/scroll/ScrollMetrics.js} +1 -1
- package/lib/commonjs/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/commonjs/types/scroll/index.js +2 -0
- package/lib/commonjs/types/scroll/index.js.map +1 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js +71 -0
- package/lib/commonjs/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/commonjs/windowing/index.js +3 -3
- package/lib/commonjs/windowing/index.js.map +1 -1
- package/lib/module/cell/CellKeyGenerator.js +16 -0
- package/lib/module/cell/CellKeyGenerator.js.map +1 -0
- package/lib/module/cell/CellRecycler.js +48 -39
- package/lib/module/cell/CellRecycler.js.map +1 -1
- package/lib/module/cell/createCell.js +17 -0
- package/lib/module/cell/createCell.js.map +1 -0
- package/lib/module/cell/index.js +7 -0
- package/lib/module/cell/index.js.map +1 -0
- package/lib/module/getVisibleIndices.js.map +1 -1
- package/lib/module/hooks/usePersistentCallback.js +33 -0
- package/lib/module/hooks/usePersistentCallback.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layout/MutableLinearLayout.js +78 -38
- package/lib/module/layout/MutableLinearLayout.js.map +1 -1
- package/lib/module/layout/constants/layoutDefaults.js +15 -0
- package/lib/module/layout/constants/layoutDefaults.js.map +1 -0
- package/lib/module/layout/index.js +0 -3
- package/lib/module/layout/index.js.map +1 -1
- package/lib/module/recycler/CellPool.js +41 -0
- package/lib/module/recycler/CellPool.js.map +1 -0
- package/lib/module/recycler/RecyclerList.js +221 -0
- package/lib/module/recycler/RecyclerList.js.map +1 -0
- package/lib/module/types/Axis.js +2 -0
- package/lib/module/types/Axis.js.map +1 -0
- package/lib/module/types/CellKey.js +2 -0
- package/lib/module/types/CellKey.js.map +1 -0
- package/lib/module/types/CellType.js +2 -0
- package/lib/module/types/CellType.js.map +1 -0
- package/lib/module/types/VisibleRange.js +2 -0
- package/lib/module/types/VisibleRange.js.map +1 -0
- package/lib/module/types/VisibleRangeInput.js +4 -0
- package/lib/module/types/VisibleRangeInput.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/layout/LayoutRect.js +2 -0
- package/lib/module/types/layout/LayoutRect.js.map +1 -0
- package/lib/module/types/layout/LinearLayoutInput.js +4 -0
- package/lib/module/types/layout/LinearLayoutInput.js.map +1 -0
- package/lib/module/types/layout/MainAxisPadding.js +22 -0
- package/lib/module/types/layout/MainAxisPadding.js.map +1 -0
- package/lib/module/types/layout/index.js +2 -0
- package/lib/module/types/layout/index.js.map +1 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js +4 -0
- package/lib/module/types/recycler/RecyclerCellInstance.js.map +1 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js +4 -0
- package/lib/module/types/recycler/RecyclerItemRenderer.js.map +1 -0
- package/lib/module/types/recycler/RecyclerListProps.js +4 -0
- package/lib/module/types/recycler/RecyclerListProps.js.map +1 -0
- package/lib/module/types/recycler/index.js +2 -0
- package/lib/module/types/recycler/index.js.map +1 -0
- package/lib/module/types/scroll/ScrollMetrics.js +4 -0
- package/lib/module/types/scroll/ScrollMetrics.js.map +1 -0
- package/lib/module/types/scroll/index.js +2 -0
- package/lib/module/types/scroll/index.js.map +1 -0
- package/lib/module/windowing/computeVisibleItemRange.js +67 -0
- package/lib/module/windowing/computeVisibleItemRange.js.map +1 -0
- package/lib/module/windowing/index.js +1 -1
- package/lib/module/windowing/index.js.map +1 -1
- package/lib/typescript/src/cell/Cell.d.ts +13 -4
- package/lib/typescript/src/cell/Cell.d.ts.map +1 -1
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts +11 -0
- package/lib/typescript/src/cell/CellKeyGenerator.d.ts.map +1 -0
- package/lib/typescript/src/cell/CellRecycler.d.ts +19 -11
- package/lib/typescript/src/cell/CellRecycler.d.ts.map +1 -1
- package/lib/typescript/src/cell/createCell.d.ts +7 -0
- package/lib/typescript/src/cell/createCell.d.ts.map +1 -0
- package/lib/typescript/src/cell/index.d.ts +4 -0
- package/lib/typescript/src/cell/index.d.ts.map +1 -0
- package/lib/typescript/src/getVisibleIndices.d.ts +2 -2
- package/lib/typescript/src/getVisibleIndices.d.ts.map +1 -1
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts +16 -0
- package/lib/typescript/src/hooks/usePersistentCallback.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts +45 -13
- package/lib/typescript/src/layout/MutableLinearLayout.d.ts.map +1 -1
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts +13 -0
- package/lib/typescript/src/layout/constants/layoutDefaults.d.ts.map +1 -0
- package/lib/typescript/src/layout/index.d.ts +1 -4
- package/lib/typescript/src/layout/index.d.ts.map +1 -1
- package/lib/typescript/src/native/NitroList.types.d.ts +2 -2
- package/lib/typescript/src/native/NitroList.types.d.ts.map +1 -1
- package/lib/typescript/src/recycler/CellPool.d.ts +14 -0
- package/lib/typescript/src/recycler/CellPool.d.ts.map +1 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts +4 -0
- package/lib/typescript/src/recycler/RecyclerList.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts +2 -2
- package/lib/typescript/src/specs/nitro-layout-engine.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/Axis.d.ts +11 -0
- package/lib/typescript/src/types/Axis.d.ts.map +1 -0
- package/lib/typescript/src/types/CellKey.d.ts +10 -0
- package/lib/typescript/src/types/CellKey.d.ts.map +1 -0
- package/lib/typescript/src/types/CellType.d.ts +11 -0
- package/lib/typescript/src/types/CellType.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRange.d.ts +10 -0
- package/lib/typescript/src/types/VisibleRange.d.ts.map +1 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts +35 -0
- package/lib/typescript/src/types/VisibleRangeInput.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +8 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts +15 -0
- package/lib/typescript/src/types/layout/LayoutRect.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts +10 -0
- package/lib/typescript/src/types/layout/LinearLayoutInput.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts +20 -0
- package/lib/typescript/src/types/layout/MainAxisPadding.d.ts.map +1 -0
- package/lib/typescript/src/types/layout/index.d.ts +4 -0
- package/lib/typescript/src/types/layout/index.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts +37 -0
- package/lib/typescript/src/types/recycler/RecyclerCellInstance.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts +8 -0
- package/lib/typescript/src/types/recycler/RecyclerItemRenderer.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts +66 -0
- package/lib/typescript/src/types/recycler/RecyclerListProps.d.ts.map +1 -0
- package/lib/typescript/src/types/recycler/index.d.ts +4 -0
- package/lib/typescript/src/types/recycler/index.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts +15 -0
- package/lib/typescript/src/types/scroll/ScrollMetrics.d.ts.map +1 -0
- package/lib/typescript/src/types/scroll/index.d.ts +2 -0
- package/lib/typescript/src/types/scroll/index.d.ts.map +1 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts +15 -0
- package/lib/typescript/src/windowing/computeVisibleItemRange.d.ts.map +1 -0
- package/lib/typescript/src/windowing/index.d.ts +1 -1
- package/lib/typescript/src/windowing/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.cpp +7 -7
- package/nitrogen/generated/android/c++/JHybridNitroLayoutEngineSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/{JLayoutRectangle.hpp → JLayoutRect.hpp} +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/HybridNitroLayoutEngineSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/{LayoutRectangle.kt → LayoutRect.kt} +5 -5
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +14 -14
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +3 -3
- package/nitrogen/generated/ios/c++/HybridNitroLayoutEngineSpecSwift.hpp +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNitroLayoutEngineSpec_cxx.swift +5 -5
- package/nitrogen/generated/ios/swift/{LayoutRectangle.swift → LayoutRect.swift} +5 -5
- package/nitrogen/generated/shared/c++/HybridNitroLayoutEngineSpec.hpp +4 -4
- package/nitrogen/generated/shared/c++/{LayoutRectangle.hpp → LayoutRect.hpp} +11 -11
- package/package.json +1 -1
- package/src/cell/Cell.ts +13 -4
- package/src/cell/CellKeyGenerator.ts +17 -0
- package/src/cell/CellRecycler.ts +53 -43
- package/src/cell/createCell.ts +15 -0
- package/src/cell/index.ts +5 -0
- package/src/getVisibleIndices.ts +4 -2
- package/src/hooks/usePersistentCallback.ts +37 -0
- package/src/index.ts +1 -2
- package/src/layout/MutableLinearLayout.ts +91 -58
- package/src/layout/constants/layoutDefaults.ts +12 -0
- package/src/layout/index.ts +1 -4
- package/src/native/NitroList.types.ts +3 -2
- package/src/recycler/CellPool.ts +47 -0
- package/src/recycler/RecyclerList.tsx +304 -0
- package/src/specs/nitro-layout-engine.nitro.ts +2 -2
- package/src/types/Axis.ts +10 -0
- package/src/types/CellKey.ts +9 -0
- package/src/types/CellType.ts +10 -0
- package/src/types/VisibleRange.ts +9 -0
- package/src/types/VisibleRangeInput.ts +39 -0
- package/src/types/index.ts +15 -0
- package/src/types/layout/LayoutRect.ts +14 -0
- package/src/types/layout/LinearLayoutInput.ts +12 -0
- package/src/types/layout/MainAxisPadding.ts +23 -0
- package/src/types/layout/index.ts +3 -0
- package/src/types/recycler/RecyclerCellInstance.ts +40 -0
- package/src/types/recycler/RecyclerItemRenderer.ts +8 -0
- package/src/types/recycler/RecyclerListProps.ts +74 -0
- package/src/types/recycler/index.ts +3 -0
- package/src/types/scroll/ScrollMetrics.ts +18 -0
- package/src/types/scroll/index.ts +1 -0
- package/src/windowing/computeVisibleItemRange.ts +78 -0
- package/src/windowing/index.ts +1 -1
- package/lib/commonjs/RecyclerList.internal.js +0 -25
- package/lib/commonjs/RecyclerList.internal.js.map +0 -1
- package/lib/commonjs/RecyclerList.js +0 -171
- package/lib/commonjs/RecyclerList.js.map +0 -1
- package/lib/commonjs/RecyclerList.types.js.map +0 -1
- package/lib/commonjs/cell/StableKey.js +0 -10
- package/lib/commonjs/cell/StableKey.js.map +0 -1
- package/lib/commonjs/hooks/useCellRenderer.js +0 -62
- package/lib/commonjs/hooks/useCellRenderer.js.map +0 -1
- package/lib/commonjs/hooks/useStableCallback.js +0 -13
- package/lib/commonjs/hooks/useStableCallback.js.map +0 -1
- package/lib/commonjs/layout/EstimatedLayoutProvider.js +0 -30
- package/lib/commonjs/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/commonjs/layout/LayoutEngine.js +0 -21
- package/lib/commonjs/layout/LayoutEngine.js.map +0 -1
- package/lib/commonjs/layout/LayoutRectangle.js +0 -2
- package/lib/commonjs/viewability/ViewabilityHelper.js +0 -121
- package/lib/commonjs/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/commonjs/windowing/findVisibleIndexRange.js +0 -48
- package/lib/commonjs/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/module/RecyclerList.internal.js +0 -22
- package/lib/module/RecyclerList.internal.js.map +0 -1
- package/lib/module/RecyclerList.js +0 -166
- package/lib/module/RecyclerList.js.map +0 -1
- package/lib/module/RecyclerList.types.js +0 -4
- package/lib/module/RecyclerList.types.js.map +0 -1
- package/lib/module/cell/StableKey.js +0 -6
- package/lib/module/cell/StableKey.js.map +0 -1
- package/lib/module/hooks/useCellRenderer.js +0 -58
- package/lib/module/hooks/useCellRenderer.js.map +0 -1
- package/lib/module/hooks/useStableCallback.js +0 -9
- package/lib/module/hooks/useStableCallback.js.map +0 -1
- package/lib/module/layout/EstimatedLayoutProvider.js +0 -25
- package/lib/module/layout/EstimatedLayoutProvider.js.map +0 -1
- package/lib/module/layout/LayoutEngine.js +0 -17
- package/lib/module/layout/LayoutEngine.js.map +0 -1
- package/lib/module/layout/LayoutProvider.js +0 -4
- package/lib/module/layout/LayoutRectangle.js +0 -2
- package/lib/module/viewability/ViewabilityHelper.js +0 -116
- package/lib/module/viewability/ViewabilityHelper.js.map +0 -1
- package/lib/module/windowing/findVisibleIndexRange.js +0 -44
- package/lib/module/windowing/findVisibleIndexRange.js.map +0 -1
- package/lib/typescript/src/RecyclerList.d.ts +0 -26
- package/lib/typescript/src/RecyclerList.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.internal.d.ts +0 -9
- package/lib/typescript/src/RecyclerList.internal.d.ts.map +0 -1
- package/lib/typescript/src/RecyclerList.types.d.ts +0 -18
- package/lib/typescript/src/RecyclerList.types.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts +0 -2
- package/lib/typescript/src/__tests__/windowing/findVisibleIndexRange.test.d.ts.map +0 -1
- package/lib/typescript/src/cell/StableKey.d.ts +0 -2
- package/lib/typescript/src/cell/StableKey.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useCellRenderer.d.ts +0 -19
- package/lib/typescript/src/hooks/useCellRenderer.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useStableCallback.d.ts +0 -2
- package/lib/typescript/src/hooks/useStableCallback.d.ts.map +0 -1
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts +0 -15
- package/lib/typescript/src/layout/EstimatedLayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutEngine.d.ts +0 -10
- package/lib/typescript/src/layout/LayoutEngine.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutProvider.d.ts +0 -16
- package/lib/typescript/src/layout/LayoutProvider.d.ts.map +0 -1
- package/lib/typescript/src/layout/LayoutRectangle.d.ts +0 -11
- package/lib/typescript/src/layout/LayoutRectangle.d.ts.map +0 -1
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts +0 -50
- package/lib/typescript/src/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts +0 -11
- package/lib/typescript/src/windowing/findVisibleIndexRange.d.ts.map +0 -1
- package/src/RecyclerList.internal.ts +0 -38
- package/src/RecyclerList.tsx +0 -252
- package/src/RecyclerList.types.ts +0 -24
- package/src/__tests__/windowing/findVisibleIndexRange.test.ts +0 -55
- package/src/cell/StableKey.ts +0 -6
- package/src/hooks/useCellRenderer.ts +0 -86
- package/src/hooks/useStableCallback.ts +0 -13
- package/src/layout/EstimatedLayoutProvider.ts +0 -35
- package/src/layout/LayoutEngine.ts +0 -21
- package/src/layout/LayoutProvider.ts +0 -17
- package/src/layout/LayoutRectangle.ts +0 -10
- package/src/viewability/ViewabilityHelper.ts +0 -130
- package/src/windowing/findVisibleIndexRange.ts +0 -60
|
@@ -1,79 +1,112 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Axis } from '../types/Axis'
|
|
2
|
+
import type { LinearLayoutInput } from '../types/layout'
|
|
3
|
+
import type { LayoutRect } from '../types/layout/LayoutRect'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
* INTERNAL mutable layout record.
|
|
5
|
-
* This is intentionally mutable and never exposed publicly.
|
|
6
|
-
*/
|
|
7
|
-
type MutableLayoutRectangle = {
|
|
8
|
-
x: number
|
|
9
|
-
y: number
|
|
10
|
-
width: number
|
|
11
|
-
height: number
|
|
12
|
-
}
|
|
5
|
+
import { DEFAULT_ITEM_SPACING } from './constants/layoutDefaults'
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
|
-
* Mutable linear layout
|
|
16
|
-
*
|
|
8
|
+
* Mutable, deterministic linear layout engine.
|
|
9
|
+
*
|
|
10
|
+
* Responsibilities:
|
|
11
|
+
* - Compute absolute item geometry
|
|
12
|
+
* - Own layout truth (no React, no scroll state)
|
|
13
|
+
* - Guarantee monotonic ordering along the main axis
|
|
14
|
+
*
|
|
15
|
+
* Cross-platform equivalents:
|
|
16
|
+
* - Flutter: RenderSliver / SliverList
|
|
17
|
+
* - Android: LinearLayoutManager
|
|
18
|
+
* - iOS: UICollectionViewFlowLayout (linear)
|
|
17
19
|
*/
|
|
18
20
|
export class MutableLinearLayout {
|
|
19
|
-
private readonly
|
|
20
|
-
private totalHeight: number
|
|
21
|
+
private readonly isVertical: boolean
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
/** Absolute item layouts in index order */
|
|
24
|
+
private layouts: LayoutRect[] = []
|
|
25
|
+
|
|
26
|
+
/** Total scrollable size along main axis */
|
|
27
|
+
private contentSize = 0
|
|
28
|
+
|
|
29
|
+
constructor(axis: Axis) {
|
|
30
|
+
this.isVertical = axis === 'vertical'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Computes layout synchronously from input.
|
|
35
|
+
*
|
|
36
|
+
* This method is intentionally parameter-object based
|
|
37
|
+
* to allow future extension without breaking API.
|
|
38
|
+
*
|
|
39
|
+
* Invariants:
|
|
40
|
+
* - Layouts are monotonic along main axis
|
|
41
|
+
* - No gaps except explicit spacing
|
|
42
|
+
* - Deterministic for identical inputs
|
|
43
|
+
*/
|
|
44
|
+
compute(input: LinearLayoutInput): void {
|
|
45
|
+
const {
|
|
46
|
+
crossAxisSize,
|
|
47
|
+
itemMainAxisSizes,
|
|
48
|
+
padding,
|
|
49
|
+
itemSpacing = DEFAULT_ITEM_SPACING,
|
|
50
|
+
} = input
|
|
51
|
+
|
|
52
|
+
const itemCount = itemMainAxisSizes.length
|
|
53
|
+
const layouts: LayoutRect[] = new Array(itemCount)
|
|
54
|
+
|
|
55
|
+
let cursor = padding.start
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < itemCount; i++) {
|
|
58
|
+
const mainAxisSize = itemMainAxisSizes[i]!
|
|
59
|
+
|
|
60
|
+
layouts[i] = this.isVertical
|
|
61
|
+
? {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: cursor,
|
|
64
|
+
width: crossAxisSize,
|
|
65
|
+
height: mainAxisSize,
|
|
66
|
+
}
|
|
67
|
+
: {
|
|
68
|
+
x: cursor,
|
|
69
|
+
y: 0,
|
|
70
|
+
width: mainAxisSize,
|
|
71
|
+
height: crossAxisSize,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
cursor += mainAxisSize
|
|
75
|
+
|
|
76
|
+
// Space BETWEEN items, not after the last
|
|
77
|
+
if (i < itemCount - 1) {
|
|
78
|
+
cursor += itemSpacing
|
|
79
|
+
}
|
|
37
80
|
}
|
|
38
81
|
|
|
39
|
-
this.
|
|
82
|
+
this.layouts = layouts
|
|
83
|
+
this.contentSize = cursor + padding.end
|
|
40
84
|
}
|
|
41
85
|
|
|
42
86
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
87
|
+
* Returns computed item layouts.
|
|
88
|
+
*
|
|
89
|
+
* Order is guaranteed monotonic along the main axis,
|
|
90
|
+
* which is required for binary-search-based windowing.
|
|
45
91
|
*/
|
|
46
|
-
getLayouts(): readonly
|
|
92
|
+
getLayouts(): readonly LayoutRect[] {
|
|
47
93
|
return this.layouts
|
|
48
94
|
}
|
|
49
95
|
|
|
50
|
-
|
|
51
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Returns total scrollable size along the main axis,
|
|
98
|
+
* including padding and inter-item spacing.
|
|
99
|
+
*/
|
|
100
|
+
getContentSize(): number {
|
|
101
|
+
return this.contentSize
|
|
52
102
|
}
|
|
53
103
|
|
|
54
104
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
105
|
+
* Clears internal layout state.
|
|
106
|
+
* Call on severe invalidation or teardown.
|
|
57
107
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
): boolean {
|
|
62
|
-
const layout = this.layouts[index]
|
|
63
|
-
if (!layout) return false
|
|
64
|
-
|
|
65
|
-
const delta = newHeight - layout.height
|
|
66
|
-
if (delta === 0) return false
|
|
67
|
-
|
|
68
|
-
// Update this item
|
|
69
|
-
layout.height = newHeight
|
|
70
|
-
|
|
71
|
-
// Shift all items after this index
|
|
72
|
-
for (let i = index + 1; i < this.layouts.length; i++) {
|
|
73
|
-
this.layouts[i]!.y += delta
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.totalHeight += delta
|
|
77
|
-
return true
|
|
108
|
+
reset(): void {
|
|
109
|
+
this.layouts = []
|
|
110
|
+
this.contentSize = 0
|
|
78
111
|
}
|
|
79
112
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default spacing between items along the main axis.
|
|
3
|
+
*
|
|
4
|
+
* This value is used by layout engines when no explicit
|
|
5
|
+
* itemSpacing is provided.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors:
|
|
8
|
+
* - Android RecyclerView ItemDecoration (typical 8–16dp)
|
|
9
|
+
* - iOS UICollectionViewFlowLayout minimumLineSpacing
|
|
10
|
+
* - Flutter SliverList spacing conventions
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_ITEM_SPACING = 12
|
package/src/layout/index.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type { LayoutProvider } from './LayoutProvider'
|
|
3
|
-
export { EstimatedLayoutProvider } from './EstimatedLayoutProvider'
|
|
4
|
-
export { computeLayouts } from './LayoutEngine'
|
|
1
|
+
export type { MutableLinearLayout } from './MutableLinearLayout'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LayoutRect } from "../types/layout";
|
|
2
|
+
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* JS runtime interface backed by Nitro (JSI).
|
|
@@ -8,5 +9,5 @@ export interface NitroList {
|
|
|
8
9
|
computeLayout(
|
|
9
10
|
containerWidth: number,
|
|
10
11
|
itemHeights: readonly number[]
|
|
11
|
-
): readonly
|
|
12
|
+
): readonly LayoutRect[]
|
|
12
13
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CellType } from '../types/CellType'
|
|
2
|
+
import type { RecyclerCellInstance } from '../types/recycler'
|
|
3
|
+
|
|
4
|
+
export class CellPool {
|
|
5
|
+
private readonly pools = new Map<CellType, RecyclerCellInstance[]>()
|
|
6
|
+
private readonly maxPerType = new Map<CellType, number>()
|
|
7
|
+
|
|
8
|
+
/** ✅ NEW: check if a type is registered */
|
|
9
|
+
hasType(type: CellType): boolean {
|
|
10
|
+
return this.pools.has(type)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
registerType(type: CellType, maxCount: number): void {
|
|
14
|
+
if (this.maxPerType.has(type)) return
|
|
15
|
+
this.maxPerType.set(type, maxCount)
|
|
16
|
+
this.pools.set(type, [])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
acquire(type: CellType): RecyclerCellInstance | null {
|
|
20
|
+
const bucket = this.pools.get(type)
|
|
21
|
+
if (!bucket || bucket.length === 0) return null
|
|
22
|
+
return bucket.pop()!
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
release(cell: RecyclerCellInstance): void {
|
|
26
|
+
const { type } = cell
|
|
27
|
+
const bucket = this.pools.get(type)
|
|
28
|
+
const max = this.maxPerType.get(type)
|
|
29
|
+
|
|
30
|
+
if (!bucket || max === undefined) return
|
|
31
|
+
|
|
32
|
+
cell.index = -1
|
|
33
|
+
|
|
34
|
+
if (bucket.length >= max) return
|
|
35
|
+
bucket.push(cell)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
clear(): void {
|
|
39
|
+
for (const bucket of this.pools.values()) {
|
|
40
|
+
bucket.length = 0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getPoolSize(type: CellType): number {
|
|
45
|
+
return this.pools.get(type)?.length ?? 0
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
ScrollView,
|
|
4
|
+
View,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type NativeSyntheticEvent,
|
|
7
|
+
type NativeScrollEvent,
|
|
8
|
+
} from 'react-native'
|
|
9
|
+
|
|
10
|
+
import type { LayoutRect, VisibleRange } from '../types'
|
|
11
|
+
import type {
|
|
12
|
+
RecyclerCellInstance,
|
|
13
|
+
RecyclerListProps,
|
|
14
|
+
} from '../types/recycler'
|
|
15
|
+
import type { CellType } from '../types/CellType'
|
|
16
|
+
|
|
17
|
+
import { MutableLinearLayout } from '../layout/MutableLinearLayout'
|
|
18
|
+
import { computeVisibleItemRange } from '../windowing'
|
|
19
|
+
import { CellPool } from './CellPool'
|
|
20
|
+
|
|
21
|
+
/* =========================================================
|
|
22
|
+
* Constants
|
|
23
|
+
* =======================================================*/
|
|
24
|
+
|
|
25
|
+
const DEFAULT_VIEWPORT_SIZE = 800
|
|
26
|
+
const DEFAULT_ITEM_SIZE = 60
|
|
27
|
+
const SCROLL_EVENT_THROTTLE = 16
|
|
28
|
+
|
|
29
|
+
/* =========================================================
|
|
30
|
+
* RecyclerList
|
|
31
|
+
* =======================================================*/
|
|
32
|
+
|
|
33
|
+
export function RecyclerList<T>(
|
|
34
|
+
props: RecyclerListProps<T>
|
|
35
|
+
): React.ReactElement {
|
|
36
|
+
const {
|
|
37
|
+
scrollDirection = 'vertical',
|
|
38
|
+
containerCrossAxisSize,
|
|
39
|
+
data,
|
|
40
|
+
itemMainAxisSizes,
|
|
41
|
+
padding = { start: 0, end: 0 },
|
|
42
|
+
itemSpacing,
|
|
43
|
+
bufferRatio = 1.3,
|
|
44
|
+
getCellType,
|
|
45
|
+
renderItem,
|
|
46
|
+
} = props
|
|
47
|
+
|
|
48
|
+
const isVertical = scrollDirection === 'vertical'
|
|
49
|
+
const itemCount = data.length
|
|
50
|
+
|
|
51
|
+
/* -------------------------------------------------------
|
|
52
|
+
* Controlled render
|
|
53
|
+
* -----------------------------------------------------*/
|
|
54
|
+
|
|
55
|
+
const [, forceRender] = useState(0)
|
|
56
|
+
|
|
57
|
+
/* -------------------------------------------------------
|
|
58
|
+
* Layout engine
|
|
59
|
+
* -----------------------------------------------------*/
|
|
60
|
+
|
|
61
|
+
const layoutEngineRef = useRef<MutableLinearLayout | null>(null)
|
|
62
|
+
const layoutSignatureRef = useRef('')
|
|
63
|
+
|
|
64
|
+
const layoutSignature = [
|
|
65
|
+
scrollDirection,
|
|
66
|
+
containerCrossAxisSize,
|
|
67
|
+
itemCount,
|
|
68
|
+
itemMainAxisSizes,
|
|
69
|
+
padding.start,
|
|
70
|
+
padding.end,
|
|
71
|
+
itemSpacing ?? 'default',
|
|
72
|
+
].join('|')
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
!layoutEngineRef.current ||
|
|
76
|
+
layoutSignatureRef.current !== layoutSignature
|
|
77
|
+
) {
|
|
78
|
+
const engine = new MutableLinearLayout(scrollDirection)
|
|
79
|
+
engine.compute({
|
|
80
|
+
crossAxisSize: containerCrossAxisSize,
|
|
81
|
+
itemMainAxisSizes,
|
|
82
|
+
padding,
|
|
83
|
+
itemSpacing,
|
|
84
|
+
})
|
|
85
|
+
layoutEngineRef.current = engine
|
|
86
|
+
layoutSignatureRef.current = layoutSignature
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const layouts: readonly LayoutRect[] =
|
|
90
|
+
layoutEngineRef.current.getLayouts()
|
|
91
|
+
|
|
92
|
+
const contentSize =
|
|
93
|
+
layoutEngineRef.current.getContentSize()
|
|
94
|
+
|
|
95
|
+
/* -------------------------------------------------------
|
|
96
|
+
* Scroll metrics
|
|
97
|
+
* -----------------------------------------------------*/
|
|
98
|
+
|
|
99
|
+
const scrollOffsetRef = useRef(0)
|
|
100
|
+
const viewportSizeRef = useRef(DEFAULT_VIEWPORT_SIZE)
|
|
101
|
+
|
|
102
|
+
/* -------------------------------------------------------
|
|
103
|
+
* Cell pool + physical cells
|
|
104
|
+
* -----------------------------------------------------*/
|
|
105
|
+
|
|
106
|
+
const cellPoolRef = useRef(new CellPool())
|
|
107
|
+
const activeCellsRef = useRef<RecyclerCellInstance[]>([])
|
|
108
|
+
const nextCellKeyRef = useRef(0)
|
|
109
|
+
|
|
110
|
+
const createCell = (type: CellType): RecyclerCellInstance => ({
|
|
111
|
+
key: nextCellKeyRef.current++,
|
|
112
|
+
index: -1,
|
|
113
|
+
type,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const MAX_CELLS = Math.ceil(
|
|
117
|
+
(viewportSizeRef.current / DEFAULT_ITEM_SIZE) *
|
|
118
|
+
bufferRatio
|
|
119
|
+
) + 2
|
|
120
|
+
|
|
121
|
+
/* -------------------------------------------------------
|
|
122
|
+
* Visible cell coordinator
|
|
123
|
+
* -----------------------------------------------------*/
|
|
124
|
+
|
|
125
|
+
const updateVisibleCells = (): void => {
|
|
126
|
+
const offset = scrollOffsetRef.current
|
|
127
|
+
const viewportSize = viewportSizeRef.current
|
|
128
|
+
const buffer = viewportSize * bufferRatio
|
|
129
|
+
|
|
130
|
+
const range: VisibleRange | null =
|
|
131
|
+
computeVisibleItemRange({
|
|
132
|
+
layouts,
|
|
133
|
+
offset,
|
|
134
|
+
viewportSize,
|
|
135
|
+
buffer,
|
|
136
|
+
isVertical,
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
if (!range) return
|
|
140
|
+
|
|
141
|
+
const nextCells: RecyclerCellInstance[] = []
|
|
142
|
+
const used = new Set<RecyclerCellInstance>()
|
|
143
|
+
|
|
144
|
+
for (
|
|
145
|
+
let index = range.startIndex;
|
|
146
|
+
index <= range.endIndex;
|
|
147
|
+
index++
|
|
148
|
+
) {
|
|
149
|
+
const item = data[index]
|
|
150
|
+
if (item === undefined) continue
|
|
151
|
+
|
|
152
|
+
const type = getCellType(item, index)
|
|
153
|
+
|
|
154
|
+
// Register type once, with hard cap
|
|
155
|
+
if (!cellPoolRef.current.hasType(type)) {
|
|
156
|
+
cellPoolRef.current.registerType(type, MAX_CELLS)
|
|
157
|
+
for (let i = 0; i < MAX_CELLS; i++) {
|
|
158
|
+
cellPoolRef.current.release(createCell(type))
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let cell = cellPoolRef.current.acquire(type)
|
|
163
|
+
|
|
164
|
+
if (!cell) {
|
|
165
|
+
const reuseIndex =
|
|
166
|
+
activeCellsRef.current.findIndex(
|
|
167
|
+
c => c.type === type
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if (reuseIndex === -1) continue
|
|
171
|
+
|
|
172
|
+
cell =
|
|
173
|
+
activeCellsRef.current.splice(
|
|
174
|
+
reuseIndex,
|
|
175
|
+
1
|
|
176
|
+
)[0]!
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
cell.index = index
|
|
180
|
+
nextCells.push(cell)
|
|
181
|
+
used.add(cell)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (const cell of activeCellsRef.current) {
|
|
185
|
+
if (!used.has(cell)) {
|
|
186
|
+
cellPoolRef.current.release(cell)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let changed =
|
|
191
|
+
nextCells.length !== activeCellsRef.current.length
|
|
192
|
+
|
|
193
|
+
if (!changed) {
|
|
194
|
+
for (let i = 0; i < nextCells.length; i++) {
|
|
195
|
+
if (nextCells[i] !== activeCellsRef.current[i]) {
|
|
196
|
+
changed = true
|
|
197
|
+
break
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (changed) {
|
|
203
|
+
activeCellsRef.current = nextCells
|
|
204
|
+
forceRender(v => v + 1)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* -------------------------------------------------------
|
|
209
|
+
* Scroll handlers
|
|
210
|
+
* -----------------------------------------------------*/
|
|
211
|
+
|
|
212
|
+
const frameScheduledRef = useRef(false)
|
|
213
|
+
|
|
214
|
+
const onScroll = (
|
|
215
|
+
e: NativeSyntheticEvent<NativeScrollEvent>
|
|
216
|
+
): void => {
|
|
217
|
+
scrollOffsetRef.current = isVertical
|
|
218
|
+
? e.nativeEvent.contentOffset.y
|
|
219
|
+
: e.nativeEvent.contentOffset.x
|
|
220
|
+
|
|
221
|
+
if (frameScheduledRef.current) return
|
|
222
|
+
frameScheduledRef.current = true
|
|
223
|
+
|
|
224
|
+
requestAnimationFrame(() => {
|
|
225
|
+
frameScheduledRef.current = false
|
|
226
|
+
updateVisibleCells()
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const onLayout = (e: any): void => {
|
|
231
|
+
viewportSizeRef.current = isVertical
|
|
232
|
+
? e.nativeEvent.layout.height
|
|
233
|
+
: e.nativeEvent.layout.width
|
|
234
|
+
|
|
235
|
+
updateVisibleCells()
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
updateVisibleCells()
|
|
240
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
241
|
+
}, [])
|
|
242
|
+
|
|
243
|
+
/* -------------------------------------------------------
|
|
244
|
+
* Render
|
|
245
|
+
* -----------------------------------------------------*/
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<ScrollView
|
|
249
|
+
onScroll={onScroll}
|
|
250
|
+
onLayout={onLayout}
|
|
251
|
+
horizontal={!isVertical}
|
|
252
|
+
scrollEventThrottle={SCROLL_EVENT_THROTTLE}
|
|
253
|
+
removeClippedSubviews
|
|
254
|
+
>
|
|
255
|
+
<View
|
|
256
|
+
style={
|
|
257
|
+
isVertical
|
|
258
|
+
? { height: contentSize }
|
|
259
|
+
: { width: contentSize }
|
|
260
|
+
}
|
|
261
|
+
>
|
|
262
|
+
{activeCellsRef.current.map(cell => {
|
|
263
|
+
const index = cell.index
|
|
264
|
+
const layout = layouts[index]
|
|
265
|
+
const item = data[index]
|
|
266
|
+
|
|
267
|
+
if (!layout || item === undefined) return null
|
|
268
|
+
|
|
269
|
+
return (
|
|
270
|
+
<View
|
|
271
|
+
key={cell.key}
|
|
272
|
+
style={[
|
|
273
|
+
styles.cell,
|
|
274
|
+
isVertical
|
|
275
|
+
? {
|
|
276
|
+
top: layout.y,
|
|
277
|
+
height: layout.height,
|
|
278
|
+
width: layout.width,
|
|
279
|
+
}
|
|
280
|
+
: {
|
|
281
|
+
left: layout.x,
|
|
282
|
+
width: layout.width,
|
|
283
|
+
height: layout.height,
|
|
284
|
+
},
|
|
285
|
+
]}
|
|
286
|
+
>
|
|
287
|
+
{renderItem({ item, index, cell })}
|
|
288
|
+
</View>
|
|
289
|
+
)
|
|
290
|
+
})}
|
|
291
|
+
</View>
|
|
292
|
+
</ScrollView>
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* =========================================================
|
|
297
|
+
* Styles
|
|
298
|
+
* =======================================================*/
|
|
299
|
+
|
|
300
|
+
const styles = StyleSheet.create({
|
|
301
|
+
cell: {
|
|
302
|
+
position: 'absolute',
|
|
303
|
+
},
|
|
304
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface LayoutRect {
|
|
4
4
|
readonly x: number
|
|
5
5
|
readonly y: number
|
|
6
6
|
readonly width: number
|
|
@@ -13,5 +13,5 @@ export interface NitroLayoutEngine
|
|
|
13
13
|
computeLayout(
|
|
14
14
|
containerWidth: number,
|
|
15
15
|
itemHeights: readonly number[]
|
|
16
|
-
): readonly
|
|
16
|
+
): readonly LayoutRect[]
|
|
17
17
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { LayoutRect } from './layout/LayoutRect'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Input required to compute the visible item range.
|
|
5
|
+
*
|
|
6
|
+
* Pure contract:
|
|
7
|
+
* - No logic
|
|
8
|
+
* - No platform assumptions
|
|
9
|
+
* - Safe to share with native / tests
|
|
10
|
+
*/
|
|
11
|
+
export interface VisibleRangeInput {
|
|
12
|
+
/**
|
|
13
|
+
* Ordered, monotonic layouts along the main axis.
|
|
14
|
+
* Required for binary search correctness.
|
|
15
|
+
*/
|
|
16
|
+
readonly layouts: readonly LayoutRect[]
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Scroll offset along the main axis.
|
|
20
|
+
*/
|
|
21
|
+
readonly offset: number
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Viewport size along the main axis.
|
|
25
|
+
*/
|
|
26
|
+
readonly viewportSize: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extra buffer before and after the viewport.
|
|
30
|
+
*/
|
|
31
|
+
readonly buffer: number
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Axis selector.
|
|
35
|
+
* true → vertical
|
|
36
|
+
* false → horizontal
|
|
37
|
+
*/
|
|
38
|
+
readonly isVertical: boolean
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { Axis } from './Axis'
|
|
2
|
+
|
|
3
|
+
export type {
|
|
4
|
+
MainAxisPadding,
|
|
5
|
+
} from './layout/MainAxisPadding'
|
|
6
|
+
export {
|
|
7
|
+
ZERO_MAIN_AXIS_PADDING,
|
|
8
|
+
} from './layout/MainAxisPadding'
|
|
9
|
+
|
|
10
|
+
export type { LayoutRect } from './layout/LayoutRect'
|
|
11
|
+
export type { VisibleRange } from './VisibleRange'
|
|
12
|
+
export type { CellKey } from './CellKey'
|
|
13
|
+
export type { CellType } from './CellType'
|
|
14
|
+
|
|
15
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Absolute layout rectangle.
|
|
3
|
+
*
|
|
4
|
+
* Cross-platform equivalent of:
|
|
5
|
+
* - Flutter: Rect
|
|
6
|
+
* - Android: Rect
|
|
7
|
+
* - iOS: CGRect
|
|
8
|
+
*/
|
|
9
|
+
export interface LayoutRect {
|
|
10
|
+
readonly x: number
|
|
11
|
+
readonly y: number
|
|
12
|
+
readonly width: number
|
|
13
|
+
readonly height: number
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MainAxisPadding } from './MainAxisPadding'
|
|
2
|
+
|
|
3
|
+
export interface LinearLayoutInput {
|
|
4
|
+
readonly crossAxisSize: number
|
|
5
|
+
readonly itemMainAxisSizes: readonly number[]
|
|
6
|
+
|
|
7
|
+
/** Padding before/after content (main axis) */
|
|
8
|
+
readonly padding: MainAxisPadding
|
|
9
|
+
|
|
10
|
+
/** Space BETWEEN items (main axis) */
|
|
11
|
+
readonly itemSpacing?: number
|
|
12
|
+
}
|