@shopify/flash-list 2.0.0-alpha.21 → 2.0.0-alpha.22
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/dist/AnimatedFlashList.js +2 -2
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -167
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +3 -595
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +2 -63
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js.map +1 -1
- package/dist/__tests__/ViewabilityHelper.test.js +3 -4
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +2 -1
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +2 -4
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +12 -24
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +2 -1
- 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 +19 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +4 -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 +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -29
- 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 +25 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +1 -22
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +1 -16
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +1 -22
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +1 -22
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +1 -15
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +1 -16
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +1 -23
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +1 -18
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +5 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +9 -8
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts +1 -8
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +4 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js +2 -1
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.d.ts +2 -2
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js +2 -4
- package/dist/{viewability → recyclerview/viewability}/ViewabilityHelper.js.map +1 -1
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.d.ts +3 -3
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/{viewability → recyclerview/viewability}/ViewabilityManager.js +16 -16
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -14
- package/src/AnimatedFlashList.ts +2 -2
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +3 -79
- package/src/__tests__/ViewabilityHelper.test.ts +13 -14
- package/src/benchmark/JSFPSMonitor.ts +3 -3
- package/src/benchmark/useBenchmark.ts +12 -40
- package/src/benchmark/useFlatListBenchmark.ts +3 -1
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +4 -0
- package/src/index.ts +7 -43
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +1 -25
- package/src/native/config/PlatformHelper.ios.ts +1 -24
- package/src/native/config/PlatformHelper.ts +1 -25
- package/src/native/config/PlatformHelper.web.ts +1 -30
- package/src/recyclerview/RecyclerView.tsx +5 -0
- package/src/recyclerview/RecyclerViewManager.ts +9 -18
- package/src/recyclerview/RecyclerViewProps.ts +1 -11
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +4 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +2 -1
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -9
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +18 -20
- package/RNFlashList.podspec +0 -37
- package/android/build.gradle +0 -89
- package/android/src/main/AndroidManifest.xml +0 -3
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +0 -105
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +0 -158
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutViewManager.kt +0 -70
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +0 -29
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainer.java +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerImpl.kt +0 -16
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerManager.kt +0 -34
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/FlashListPackage.kt +0 -19
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java +0 -47
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java +0 -21
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java +0 -32
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java +0 -16
- package/android/src/test/java/com/shopify/reactnative/flash_list/AutoLayoutShadowTest.kt +0 -147
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/Rect.kt +0 -61
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestCollection.kt +0 -6
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestDataModel.kt +0 -8
- package/android/src/test/resources/LayoutTestData.json +0 -788
- package/dist/GridLayoutProviderWithProps.d.ts +0 -42
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -114
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -51
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -252
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -22
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -37
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.d.ts +0 -2
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +0 -1
- package/dist/__tests__/ContentContainerUtils.test.js +0 -85
- package/dist/__tests__/ContentContainerUtils.test.js.map +0 -1
- package/dist/__tests__/FlashList.test.d.ts +0 -2
- package/dist/__tests__/FlashList.test.d.ts.map +0 -1
- package/dist/__tests__/FlashList.test.js +0 -902
- package/dist/__tests__/FlashList.test.js.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +0 -2
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +0 -1
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +0 -143
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.d.ts +0 -2
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +0 -1
- package/dist/__tests__/MasonryFlashList.test.js +0 -254
- package/dist/__tests__/MasonryFlashList.test.js.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.d.ts +0 -2
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +0 -1
- package/dist/__tests__/PlatformHelper.web.test.js +0 -33
- package/dist/__tests__/PlatformHelper.web.test.js.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.d.ts +0 -19
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountFlashList.js +0 -44
- package/dist/__tests__/helpers/mountFlashList.js.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +0 -18
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +0 -1
- package/dist/__tests__/helpers/mountMasonryFlashList.js +0 -49
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +0 -2
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +0 -1
- package/dist/__tests__/useBlankAreaTracker.test.js +0 -179
- package/dist/__tests__/useBlankAreaTracker.test.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -34
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -66
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/enableNewCore.d.ts +0 -3
- package/dist/enableNewCore.d.ts.map +0 -1
- package/dist/enableNewCore.js +0 -25
- package/dist/enableNewCore.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -8
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -14
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -24
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -26
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -9
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -13
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -22
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -48
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -5
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -4
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -6
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -16
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -3
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -9
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -8
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -6
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -9
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -11
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -7
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -13
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.d.ts +0 -18
- package/dist/specs/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/specs/AutoLayoutNativeComponent.js +0 -6
- package/dist/specs/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/specs/CellContainerNativeComponent.d.ts +0 -8
- package/dist/specs/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/specs/CellContainerNativeComponent.js +0 -6
- package/dist/specs/CellContainerNativeComponent.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -27
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -48
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/ios/RNFlashList.xcodeproj/project.pbxproj +0 -3
- package/ios/RNFlashList.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Sources/AutoLayoutView.swift +0 -294
- package/ios/Sources/AutoLayoutViewComponentView.h +0 -16
- package/ios/Sources/AutoLayoutViewComponentView.mm +0 -90
- package/ios/Sources/AutoLayoutViewManager.mm +0 -14
- package/ios/Sources/AutoLayoutViewManager.swift +0 -12
- package/ios/Sources/CellContainerComponentView.h +0 -18
- package/ios/Sources/CellContainerComponentView.mm +0 -62
- package/ios/Sources/CellContainerManager.mm +0 -8
- package/ios/Sources/CellContainerManager.swift +0 -12
- package/ios/Sources/FlatListPro-Bridging-Header.h +0 -11
- package/ios/Tests/AutoLayoutViewTests.swift +0 -113
- package/src/FlashList.tsx +0 -953
- package/src/GridLayoutProviderWithProps.ts +0 -180
- package/src/MasonryFlashList.tsx +0 -476
- package/src/PureComponentWrapper.tsx +0 -42
- package/src/__tests__/ContentContainerUtils.test.ts +0 -130
- package/src/__tests__/FlashList.test.tsx +0 -1001
- package/src/__tests__/GridLayoutProviderWithProps.test.ts +0 -179
- package/src/__tests__/MasonryFlashList.test.ts +0 -292
- package/src/__tests__/PlatformHelper.web.test.ts +0 -45
- package/src/__tests__/helpers/mountFlashList.tsx +0 -62
- package/src/__tests__/helpers/mountMasonryFlashList.tsx +0 -70
- package/src/__tests__/useBlankAreaTracker.test.tsx +0 -206
- package/src/benchmark/useBlankAreaTracker.ts +0 -117
- package/src/enableNewCore.ts +0 -24
- package/src/errors/CustomError.ts +0 -10
- package/src/errors/ExceptionList.ts +0 -28
- package/src/errors/Warnings.ts +0 -15
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -73
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -7
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -17
- package/src/native/cell-container/CellContainer.android.ts +0 -7
- package/src/native/cell-container/CellContainer.ios.ts +0 -7
- package/src/native/cell-container/CellContainer.tsx +0 -14
- package/src/native/cell-container/CellContainer.web.tsx +0 -9
- package/src/specs/AutoLayoutNativeComponent.ts +0 -24
- package/src/specs/CellContainerNativeComponent.ts +0 -9
- package/src/utils/ContentContainerUtils.ts +0 -92
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.d.ts +0 -0
- /package/dist/{viewability → recyclerview/viewability}/ViewToken.js +0 -0
- /package/src/{viewability → recyclerview/viewability}/ViewToken.ts +0 -0
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/// Container for all RecyclerListView children. This will automatically remove all gaps and overlaps for GridLayouts with flexible spans.
|
|
6
|
-
/// Note: This cannot work for masonry layouts i.e, pinterest like layout
|
|
7
|
-
@objc public class AutoLayoutView: UIView {
|
|
8
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
9
|
-
@objc public var onBlankAreaEventHandler: ((CGFloat, CGFloat) -> Void)?
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
@objc(onBlankAreaEvent)
|
|
13
|
-
var onBlankAreaEvent: RCTDirectEventBlock?
|
|
14
|
-
|
|
15
|
-
@objc public func setHorizontal(_ horizontal: Bool) {
|
|
16
|
-
self.horizontal = horizontal
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@objc public func setScrollOffset(_ scrollOffset: Int) {
|
|
20
|
-
self.scrollOffset = CGFloat(scrollOffset)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@objc public func setWindowSize(_ windowSize: Int) {
|
|
24
|
-
self.windowSize = CGFloat(windowSize)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@objc public func setRenderAheadOffset(_ renderAheadOffset: Int) {
|
|
28
|
-
self.renderAheadOffset = CGFloat(renderAheadOffset)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@objc public func setEnableInstrumentation(_ enableInstrumentation: Bool) {
|
|
32
|
-
self.enableInstrumentation = enableInstrumentation
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@objc public func setDisableAutoLayout(_ disableAutoLayout: Bool) {
|
|
36
|
-
self.disableAutoLayout = disableAutoLayout
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private var horizontal = false
|
|
40
|
-
private var scrollOffset: CGFloat = 0
|
|
41
|
-
private var windowSize: CGFloat = 0
|
|
42
|
-
private var renderAheadOffset: CGFloat = 0
|
|
43
|
-
private var enableInstrumentation = false
|
|
44
|
-
private var disableAutoLayout = false
|
|
45
|
-
|
|
46
|
-
/// Tracks where the last pixel is drawn in the overall
|
|
47
|
-
private var lastMaxBoundOverall: CGFloat = 0
|
|
48
|
-
/// Tracks where the last pixel is drawn in the visible window
|
|
49
|
-
private var lastMaxBound: CGFloat = 0
|
|
50
|
-
/// Tracks where first pixel is drawn in the visible window
|
|
51
|
-
private var lastMinBound: CGFloat = 0
|
|
52
|
-
|
|
53
|
-
override public func layoutSubviews() {
|
|
54
|
-
fixLayout()
|
|
55
|
-
super.layoutSubviews()
|
|
56
|
-
|
|
57
|
-
guard enableInstrumentation, let scrollView = getScrollView() else { return }
|
|
58
|
-
|
|
59
|
-
let scrollContainerSize = horizontal ? scrollView.frame.width : scrollView.frame.height
|
|
60
|
-
let currentScrollOffset = horizontal ? scrollView.contentOffset.x : scrollView.contentOffset.y
|
|
61
|
-
let startOffset = horizontal ? frame.minX : frame.minY
|
|
62
|
-
let endOffset = horizontal ? frame.maxX : frame.maxY
|
|
63
|
-
let distanceFromWindowStart = max(startOffset - currentScrollOffset, 0)
|
|
64
|
-
let distanceFromWindowEnd = max(currentScrollOffset + scrollContainerSize - endOffset, 0)
|
|
65
|
-
|
|
66
|
-
let (blankOffsetStart, blankOffsetEnd) = computeBlankFromGivenOffset(
|
|
67
|
-
currentScrollOffset - startOffset,
|
|
68
|
-
filledBoundMin: lastMinBound,
|
|
69
|
-
filledBoundMax: lastMaxBound,
|
|
70
|
-
renderAheadOffset: renderAheadOffset,
|
|
71
|
-
windowSize: windowSize,
|
|
72
|
-
distanceFromWindowStart: distanceFromWindowStart,
|
|
73
|
-
distanceFromWindowEnd: distanceFromWindowEnd
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
77
|
-
onBlankAreaEventHandler?(blankOffsetStart, blankOffsetEnd)
|
|
78
|
-
#else
|
|
79
|
-
onBlankAreaEvent?(
|
|
80
|
-
[
|
|
81
|
-
"offsetStart": blankOffsetStart,
|
|
82
|
-
"offsetEnd": blankOffsetEnd,
|
|
83
|
-
]
|
|
84
|
-
)
|
|
85
|
-
#endif
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
func getScrollView() -> UIScrollView? {
|
|
89
|
-
return sequence(first: self, next: { $0.superview }).first(where: { $0 is UIScrollView }) as? UIScrollView
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/// Sorts views by index and then invokes clearGaps which does the correction.
|
|
93
|
-
/// Performance: Sort is needed. Given relatively low number of views in RecyclerListView render tree this should be a non issue.
|
|
94
|
-
private func fixLayout() {
|
|
95
|
-
guard
|
|
96
|
-
subviews.count > 1,
|
|
97
|
-
// Fixing layout during animation can interfere with it.
|
|
98
|
-
layer.animationKeys()?.isEmpty ?? true,
|
|
99
|
-
!disableAutoLayout
|
|
100
|
-
else { return }
|
|
101
|
-
let cellContainers = subviews
|
|
102
|
-
.compactMap { subview -> CellContainerComponentView? in
|
|
103
|
-
if let cellContainer = subview as? CellContainerComponentView {
|
|
104
|
-
return cellContainer
|
|
105
|
-
} else {
|
|
106
|
-
assertionFailure("CellRendererComponent outer view should always be CellContainer. Learn more here: https://shopify.github.io/flash-list/docs/usage#cellrenderercomponent.")
|
|
107
|
-
return nil
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
.sorted(by: { $0.index < $1.index })
|
|
111
|
-
clearGaps(for: cellContainers)
|
|
112
|
-
fixFooter()
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/// Checks for overlaps or gaps between adjacent items and then applies a correction.
|
|
116
|
-
/// Performance: RecyclerListView renders very small number of views and this is not going to trigger multiple layouts on the iOS side.
|
|
117
|
-
private func clearGaps(for cellContainers: [CellContainerComponentView]) {
|
|
118
|
-
var maxBound: CGFloat = 0
|
|
119
|
-
var minBound: CGFloat = CGFloat(Int.max)
|
|
120
|
-
var maxBoundNextCell: CGFloat = 0
|
|
121
|
-
let correctedScrollOffset = scrollOffset - (horizontal ? frame.minX : frame.minY)
|
|
122
|
-
lastMaxBoundOverall = 0
|
|
123
|
-
cellContainers.indices.dropLast().forEach { index in
|
|
124
|
-
let cellContainer = cellContainers[index]
|
|
125
|
-
let cellTop = cellContainer.frame.minY
|
|
126
|
-
let cellBottom = cellContainer.frame.maxY
|
|
127
|
-
let cellLeft = cellContainer.frame.minX
|
|
128
|
-
let cellRight = cellContainer.frame.maxX
|
|
129
|
-
|
|
130
|
-
let nextCell = cellContainers[index + 1]
|
|
131
|
-
let nextCellTop = nextCell.frame.minY
|
|
132
|
-
let nextCellLeft = nextCell.frame.minX
|
|
133
|
-
|
|
134
|
-
// Only apply correction if the next cell is consecutive.
|
|
135
|
-
let isNextCellConsecutive = nextCell.index == cellContainer.index + 1
|
|
136
|
-
|
|
137
|
-
let isCellVisible = isWithinBounds(
|
|
138
|
-
cellContainer,
|
|
139
|
-
scrollOffset: correctedScrollOffset,
|
|
140
|
-
renderAheadOffset: renderAheadOffset,
|
|
141
|
-
windowSize: windowSize,
|
|
142
|
-
isHorizontal: horizontal
|
|
143
|
-
)
|
|
144
|
-
let isNextCellVisible = isWithinBounds(
|
|
145
|
-
nextCell,
|
|
146
|
-
scrollOffset: correctedScrollOffset,
|
|
147
|
-
renderAheadOffset: renderAheadOffset,
|
|
148
|
-
windowSize: windowSize,
|
|
149
|
-
isHorizontal: horizontal
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
guard
|
|
153
|
-
isCellVisible || isNextCellVisible
|
|
154
|
-
else {
|
|
155
|
-
updateLastMaxBoundOverall(currentCell: cellContainer, nextCell: nextCell)
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if horizontal {
|
|
161
|
-
maxBound = max(maxBound, cellRight)
|
|
162
|
-
minBound = min(minBound, cellLeft)
|
|
163
|
-
maxBoundNextCell = maxBound
|
|
164
|
-
if isNextCellConsecutive {
|
|
165
|
-
if cellTop < nextCellTop {
|
|
166
|
-
if cellBottom != nextCellTop {
|
|
167
|
-
nextCell.frame.origin.y = cellBottom
|
|
168
|
-
}
|
|
169
|
-
if cellLeft != nextCellLeft {
|
|
170
|
-
nextCell.frame.origin.x = cellLeft
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
nextCell.frame.origin.x = maxBound
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if isNextCellVisible {
|
|
177
|
-
maxBoundNextCell = max(maxBound, nextCell.frame.maxX)
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
maxBound = max(maxBound, cellBottom)
|
|
181
|
-
minBound = min(minBound, cellTop)
|
|
182
|
-
maxBoundNextCell = maxBound
|
|
183
|
-
if isNextCellConsecutive {
|
|
184
|
-
if cellLeft < nextCellLeft {
|
|
185
|
-
if cellRight != nextCellLeft {
|
|
186
|
-
nextCell.frame.origin.x = cellRight
|
|
187
|
-
}
|
|
188
|
-
if cellTop != nextCellTop {
|
|
189
|
-
nextCell.frame.origin.y = cellTop
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
nextCell.frame.origin.y = maxBound
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if isNextCellVisible {
|
|
196
|
-
maxBoundNextCell = max(maxBound, nextCell.frame.maxY)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
updateLastMaxBoundOverall(currentCell: cellContainer, nextCell: nextCell)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
lastMaxBound = maxBoundNextCell
|
|
203
|
-
lastMinBound = minBound
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
private func updateLastMaxBoundOverall(currentCell: CellContainerComponentView, nextCell: CellContainerComponentView) {
|
|
207
|
-
lastMaxBoundOverall = max(lastMaxBoundOverall, horizontal ? currentCell.frame.maxX : currentCell.frame.maxY, horizontal ? nextCell.frame.maxX : nextCell.frame.maxY)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
func computeBlankFromGivenOffset(
|
|
211
|
-
_ actualScrollOffset: CGFloat,
|
|
212
|
-
filledBoundMin: CGFloat,
|
|
213
|
-
filledBoundMax: CGFloat,
|
|
214
|
-
renderAheadOffset: CGFloat,
|
|
215
|
-
windowSize: CGFloat,
|
|
216
|
-
distanceFromWindowStart: CGFloat,
|
|
217
|
-
distanceFromWindowEnd: CGFloat
|
|
218
|
-
) -> (
|
|
219
|
-
offsetStart: CGFloat,
|
|
220
|
-
offsetEnd: CGFloat
|
|
221
|
-
) {
|
|
222
|
-
let blankOffsetStart = filledBoundMin - actualScrollOffset - distanceFromWindowStart
|
|
223
|
-
|
|
224
|
-
let blankOffsetEnd = actualScrollOffset + windowSize - renderAheadOffset - filledBoundMax - distanceFromWindowEnd
|
|
225
|
-
|
|
226
|
-
return (blankOffsetStart, blankOffsetEnd)
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/// It's important to avoid correcting views outside the render window. An item that isn't being recycled might still remain in the view tree. If views outside get considered then gaps between unused items will cause algorithm to fail.
|
|
230
|
-
func isWithinBounds(
|
|
231
|
-
_ cellContainer: CellContainerComponentView,
|
|
232
|
-
scrollOffset: CGFloat,
|
|
233
|
-
renderAheadOffset: CGFloat,
|
|
234
|
-
windowSize: CGFloat,
|
|
235
|
-
isHorizontal: Bool
|
|
236
|
-
) -> Bool {
|
|
237
|
-
let boundsStart = scrollOffset - renderAheadOffset
|
|
238
|
-
let boundsEnd = scrollOffset + windowSize
|
|
239
|
-
let cellFrame = cellContainer.frame
|
|
240
|
-
|
|
241
|
-
if isHorizontal {
|
|
242
|
-
return (cellFrame.minX >= boundsStart || cellFrame.maxX >= boundsStart) && (cellFrame.minX <= boundsEnd || cellFrame.maxX <= boundsEnd)
|
|
243
|
-
} else {
|
|
244
|
-
return (cellFrame.minY >= boundsStart || cellFrame.maxY >= boundsStart) && (cellFrame.minY <= boundsEnd || cellFrame.maxY <= boundsEnd)
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/// Fixes footer position along with rest of the items
|
|
249
|
-
private func fixFooter() {
|
|
250
|
-
guard !disableAutoLayout, let parentScrollView = getScrollView() else {
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
let isAutoLayoutEndVisible = horizontal ? frame.maxX <= parentScrollView.frame.width : frame.maxY <= parentScrollView.frame.height
|
|
255
|
-
guard isAutoLayoutEndVisible, let footer = footer() else {
|
|
256
|
-
return
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
let diff = footerDiff()
|
|
260
|
-
guard diff != 0 else { return }
|
|
261
|
-
|
|
262
|
-
if horizontal {
|
|
263
|
-
footer.frame.origin.x += diff
|
|
264
|
-
frame.size.width += diff
|
|
265
|
-
superview?.frame.size.width += diff
|
|
266
|
-
} else {
|
|
267
|
-
footer.frame.origin.y += diff
|
|
268
|
-
frame.size.height += diff
|
|
269
|
-
superview?.frame.size.height += diff
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
private func footerDiff() -> CGFloat {
|
|
274
|
-
if subviews.count == 0 {
|
|
275
|
-
lastMaxBoundOverall = 0
|
|
276
|
-
} else if subviews.count == 1 {
|
|
277
|
-
let firstChild = subviews[0]
|
|
278
|
-
lastMaxBoundOverall = horizontal ? firstChild.frame.maxX : firstChild.frame.maxY
|
|
279
|
-
}
|
|
280
|
-
let autoLayoutEnd = horizontal ? frame.width : frame.height
|
|
281
|
-
return lastMaxBoundOverall - autoLayoutEnd
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
private func footer() -> UIView? {
|
|
285
|
-
// On the new arch, AutoLayoutView is wrapped with AutoLayoutViewComponentView, so we need to go up one more level
|
|
286
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
287
|
-
let parentSubviews = superview?.superview?.subviews
|
|
288
|
-
#else
|
|
289
|
-
let parentSubviews = superview?.subviews
|
|
290
|
-
#endif
|
|
291
|
-
|
|
292
|
-
return parentSubviews?.first(where:{($0 as? CellContainerComponentView)?.index == -1})
|
|
293
|
-
}
|
|
294
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef AutoLayoutViewComponentView_h
|
|
2
|
-
#define AutoLayoutViewComponentView_h
|
|
3
|
-
|
|
4
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
|
-
|
|
6
|
-
#import <UIKit/UIKit.h>
|
|
7
|
-
#import <React/RCTViewComponentView.h>
|
|
8
|
-
|
|
9
|
-
@interface AutoLayoutViewComponentView : RCTViewComponentView
|
|
10
|
-
|
|
11
|
-
@end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
15
|
-
|
|
16
|
-
#endif /* AutoLayoutViewComponentView_h */
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
-
#import "AutoLayoutViewComponentView.h"
|
|
3
|
-
#import <React/RCTConversions.h>
|
|
4
|
-
#import <React/RCTViewManager.h>
|
|
5
|
-
|
|
6
|
-
#import <react/renderer/components/rnflashlist/ComponentDescriptors.h>
|
|
7
|
-
#import <react/renderer/components/rnflashlist/EventEmitters.h>
|
|
8
|
-
#import <react/renderer/components/rnflashlist/Props.h>
|
|
9
|
-
#import <react/renderer/components/rnflashlist/RCTComponentViewHelpers.h>
|
|
10
|
-
|
|
11
|
-
#import "RCTFabricComponentsPlugins.h"
|
|
12
|
-
|
|
13
|
-
#if __has_include(<RNFlashList/RNFlashList-Swift.h>)
|
|
14
|
-
#import <RNFlashList/RNFlashList-Swift.h>
|
|
15
|
-
#else
|
|
16
|
-
#import "RNFlashList-Swift.h"
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
using namespace facebook::react;
|
|
20
|
-
|
|
21
|
-
@interface AutoLayoutViewComponentView () <RCTAutoLayoutViewViewProtocol>
|
|
22
|
-
@end
|
|
23
|
-
|
|
24
|
-
@implementation AutoLayoutViewComponentView
|
|
25
|
-
{
|
|
26
|
-
AutoLayoutView *_autoLayoutView;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
30
|
-
{
|
|
31
|
-
if (self = [super initWithFrame:frame]) {
|
|
32
|
-
static const auto defaultProps = std::make_shared<const AutoLayoutViewProps>();
|
|
33
|
-
_props = defaultProps;
|
|
34
|
-
_autoLayoutView = [[AutoLayoutView alloc] initWithFrame:self.bounds];
|
|
35
|
-
self.contentView = _autoLayoutView;
|
|
36
|
-
|
|
37
|
-
__weak AutoLayoutViewComponentView* weakSelf = self;
|
|
38
|
-
_autoLayoutView.onBlankAreaEventHandler = ^(CGFloat start, CGFloat end) {
|
|
39
|
-
AutoLayoutViewComponentView *strongSelf = weakSelf;
|
|
40
|
-
if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
|
|
41
|
-
std::dynamic_pointer_cast<const facebook::react::AutoLayoutViewEventEmitter>(strongSelf->_eventEmitter)
|
|
42
|
-
->onBlankAreaEvent(facebook::react::AutoLayoutViewEventEmitter::OnBlankAreaEvent{
|
|
43
|
-
.offsetStart = (int) floor(start),
|
|
44
|
-
.offsetEnd = (int) floor(end),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return self;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
54
|
-
{
|
|
55
|
-
[_autoLayoutView mountChildComponentView:childComponentView index:index];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
59
|
-
{
|
|
60
|
-
[_autoLayoutView unmountChildComponentView:childComponentView index:index];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
#pragma mark - RCTComponentViewProtocol
|
|
64
|
-
|
|
65
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
66
|
-
{
|
|
67
|
-
return concreteComponentDescriptorProvider<AutoLayoutViewComponentDescriptor>();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
71
|
-
{
|
|
72
|
-
const auto &newProps = *std::static_pointer_cast<const AutoLayoutViewProps>(props);
|
|
73
|
-
|
|
74
|
-
[_autoLayoutView setHorizontal:newProps.horizontal];
|
|
75
|
-
[_autoLayoutView setScrollOffset:newProps.scrollOffset];
|
|
76
|
-
[_autoLayoutView setWindowSize:newProps.windowSize];
|
|
77
|
-
[_autoLayoutView setRenderAheadOffset:newProps.renderAheadOffset];
|
|
78
|
-
[_autoLayoutView setEnableInstrumentation:newProps.enableInstrumentation];
|
|
79
|
-
[_autoLayoutView setDisableAutoLayout:newProps.disableAutoLayout];
|
|
80
|
-
|
|
81
|
-
[super updateProps:props oldProps:oldProps];
|
|
82
|
-
}
|
|
83
|
-
@end
|
|
84
|
-
|
|
85
|
-
Class<RCTComponentViewProtocol> AutoLayoutViewCls(void)
|
|
86
|
-
{
|
|
87
|
-
return AutoLayoutViewComponentView.class;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
|
-
#import <React/RCTViewManager.h>
|
|
3
|
-
|
|
4
|
-
@interface RCT_EXTERN_MODULE(AutoLayoutViewManager, RCTViewManager)
|
|
5
|
-
|
|
6
|
-
RCT_EXPORT_VIEW_PROPERTY(horizontal, BOOL)
|
|
7
|
-
RCT_EXPORT_VIEW_PROPERTY(scrollOffset, NSInteger)
|
|
8
|
-
RCT_EXPORT_VIEW_PROPERTY(windowSize, NSInteger)
|
|
9
|
-
RCT_EXPORT_VIEW_PROPERTY(renderAheadOffset, NSInteger)
|
|
10
|
-
RCT_EXPORT_VIEW_PROPERTY(enableInstrumentation, BOOL)
|
|
11
|
-
RCT_EXPORT_VIEW_PROPERTY(disableAutoLayout, BOOL)
|
|
12
|
-
RCT_EXPORT_VIEW_PROPERTY(onBlankAreaEvent, RCTDirectEventBlock)
|
|
13
|
-
|
|
14
|
-
@end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#ifndef CellContainer_h
|
|
2
|
-
#define CellContainer_h
|
|
3
|
-
|
|
4
|
-
#import <UIKit/UIKit.h>
|
|
5
|
-
|
|
6
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
7
|
-
#import <React/RCTViewComponentView.h>
|
|
8
|
-
|
|
9
|
-
@interface CellContainerComponentView : RCTViewComponentView
|
|
10
|
-
#else
|
|
11
|
-
@interface CellContainerComponentView : UIView
|
|
12
|
-
#endif // RCT_NEW_ARCH_ENABLED
|
|
13
|
-
|
|
14
|
-
@property int64_t index;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
#endif /* CellContainer_h */
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#import "CellContainerComponentView.h"
|
|
2
|
-
|
|
3
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
-
#import <React/RCTConversions.h>
|
|
5
|
-
|
|
6
|
-
#import <react/renderer/components/rnflashlist/ComponentDescriptors.h>
|
|
7
|
-
#import <react/renderer/components/rnflashlist/EventEmitters.h>
|
|
8
|
-
#import <react/renderer/components/rnflashlist/Props.h>
|
|
9
|
-
#import <react/renderer/components/rnflashlist/RCTComponentViewHelpers.h>
|
|
10
|
-
|
|
11
|
-
#import "RCTFabricComponentsPlugins.h"
|
|
12
|
-
|
|
13
|
-
#if __has_include(<RNFlashList/RNFlashList-Swift.h>)
|
|
14
|
-
#import <RNFlashList/RNFlashList-Swift.h>
|
|
15
|
-
#else
|
|
16
|
-
#import "RNFlashList-Swift.h"
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
using namespace facebook::react;
|
|
20
|
-
|
|
21
|
-
@interface CellContainerComponentView () <RCTCellContainerViewProtocol>
|
|
22
|
-
@end
|
|
23
|
-
|
|
24
|
-
@implementation CellContainerComponentView
|
|
25
|
-
|
|
26
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
27
|
-
{
|
|
28
|
-
if (self = [super initWithFrame:frame]) {
|
|
29
|
-
static const auto defaultProps = std::make_shared<const CellContainerProps>();
|
|
30
|
-
_props = defaultProps;
|
|
31
|
-
|
|
32
|
-
self.userInteractionEnabled = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return self;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#pragma mark - RCTComponentViewProtocol
|
|
39
|
-
|
|
40
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
41
|
-
{
|
|
42
|
-
return concreteComponentDescriptorProvider<CellContainerComponentDescriptor>();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
46
|
-
{
|
|
47
|
-
const auto &newProps = *std::static_pointer_cast<const CellContainerProps>(props);
|
|
48
|
-
|
|
49
|
-
self.index = newProps.index;
|
|
50
|
-
|
|
51
|
-
[super updateProps:props oldProps:oldProps];
|
|
52
|
-
}
|
|
53
|
-
@end
|
|
54
|
-
|
|
55
|
-
Class<RCTComponentViewProtocol> CellContainerCls(void)
|
|
56
|
-
{
|
|
57
|
-
return CellContainerComponentView.class;
|
|
58
|
-
}
|
|
59
|
-
#else
|
|
60
|
-
@implementation CellContainerComponentView
|
|
61
|
-
@end
|
|
62
|
-
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
@objc(CellContainerManager)
|
|
4
|
-
class CellContainerManager: RCTViewManager {
|
|
5
|
-
override func view() -> UIView! {
|
|
6
|
-
return CellContainerComponentView()
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
override static func requiresMainQueueSetup() -> Bool {
|
|
10
|
-
return true
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#ifndef FlatListPro_Bridging_Header_h
|
|
2
|
-
#define FlatListPro_Bridging_Header_h
|
|
3
|
-
|
|
4
|
-
#import <React/RCTBridgeModule.h>
|
|
5
|
-
#import <React/RCTEventEmitter.h>
|
|
6
|
-
#import <React/RCTViewManager.h>
|
|
7
|
-
#import <React/RCTComponent.h>
|
|
8
|
-
|
|
9
|
-
#import "CellContainerComponentView.h"
|
|
10
|
-
|
|
11
|
-
#endif /* FlatListPro_Bridging_Header_h */
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import XCTest
|
|
2
|
-
@testable import RNFlashList
|
|
3
|
-
|
|
4
|
-
class AutoLayoutViewTests: XCTestCase {
|
|
5
|
-
var autoLayoutView: AutoLayoutView!
|
|
6
|
-
var testCell: CellContainer!
|
|
7
|
-
let cellHeight: CGFloat = 50
|
|
8
|
-
let windowSize: CGFloat = 500
|
|
9
|
-
|
|
10
|
-
override func setUp() {
|
|
11
|
-
super.setUp()
|
|
12
|
-
autoLayoutView = AutoLayoutView()
|
|
13
|
-
testCell = CellContainer()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
func testIsWithinBoundsVerticalListScrollToBottom() {
|
|
17
|
-
testCell.frame = CGRect(x: 0, y: 0, width: cellHeight, height: cellHeight)
|
|
18
|
-
// Top left corner of the screen
|
|
19
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
20
|
-
scrollOffset: 0,
|
|
21
|
-
renderAheadOffset: 0,
|
|
22
|
-
windowSize: windowSize,
|
|
23
|
-
isHorizontal: false))
|
|
24
|
-
|
|
25
|
-
// Partly visible
|
|
26
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
27
|
-
scrollOffset: 25,
|
|
28
|
-
renderAheadOffset: 0,
|
|
29
|
-
windowSize: windowSize,
|
|
30
|
-
isHorizontal: false))
|
|
31
|
-
|
|
32
|
-
// Above visible
|
|
33
|
-
XCTAssertFalse(autoLayoutView.isWithinBounds(testCell,
|
|
34
|
-
scrollOffset: 100,
|
|
35
|
-
renderAheadOffset: 0,
|
|
36
|
-
windowSize: windowSize,
|
|
37
|
-
isHorizontal: false))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
func testIsWithinBoundsVerticalListScrollToTop() {
|
|
41
|
-
testCell.frame = CGRect(x: 0, y: windowSize - cellHeight, width: cellHeight, height: cellHeight)
|
|
42
|
-
// Bottom left corner of the screen
|
|
43
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
44
|
-
scrollOffset: 0,
|
|
45
|
-
renderAheadOffset: 0,
|
|
46
|
-
windowSize: windowSize,
|
|
47
|
-
isHorizontal: false))
|
|
48
|
-
|
|
49
|
-
// Partly visible
|
|
50
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
51
|
-
scrollOffset: -25,
|
|
52
|
-
renderAheadOffset: 0,
|
|
53
|
-
windowSize: windowSize,
|
|
54
|
-
isHorizontal: false))
|
|
55
|
-
|
|
56
|
-
// Below visible
|
|
57
|
-
XCTAssertFalse(autoLayoutView.isWithinBounds(testCell,
|
|
58
|
-
scrollOffset: -100,
|
|
59
|
-
renderAheadOffset: 0,
|
|
60
|
-
windowSize: windowSize,
|
|
61
|
-
isHorizontal: false))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
func testIsWithinBoundsHorizontalListScrollToLeft() {
|
|
65
|
-
testCell.frame = CGRect(x: 0, y: 0, width: cellHeight, height: cellHeight)
|
|
66
|
-
// Top left corner of the screen
|
|
67
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
68
|
-
scrollOffset: 0,
|
|
69
|
-
renderAheadOffset: 0,
|
|
70
|
-
windowSize: windowSize,
|
|
71
|
-
isHorizontal: true))
|
|
72
|
-
|
|
73
|
-
// Partly visible
|
|
74
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
75
|
-
scrollOffset: 25,
|
|
76
|
-
renderAheadOffset: 0,
|
|
77
|
-
windowSize: windowSize,
|
|
78
|
-
isHorizontal: true))
|
|
79
|
-
|
|
80
|
-
// Hidden
|
|
81
|
-
XCTAssertFalse(autoLayoutView.isWithinBounds(testCell,
|
|
82
|
-
scrollOffset: 100,
|
|
83
|
-
renderAheadOffset: 0,
|
|
84
|
-
windowSize: windowSize,
|
|
85
|
-
isHorizontal: true))
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
func testIsWithinBoundsHorizontalListScrollToRight() {
|
|
89
|
-
testCell.frame = CGRect(x: windowSize - cellHeight, y: 0, width: cellHeight, height: cellHeight)
|
|
90
|
-
// Bottom left corner of the screen
|
|
91
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
92
|
-
scrollOffset: 0,
|
|
93
|
-
renderAheadOffset: 0,
|
|
94
|
-
windowSize: windowSize,
|
|
95
|
-
isHorizontal: true))
|
|
96
|
-
|
|
97
|
-
// Partly visible
|
|
98
|
-
XCTAssertTrue(autoLayoutView.isWithinBounds(testCell,
|
|
99
|
-
scrollOffset: -25,
|
|
100
|
-
renderAheadOffset: 0,
|
|
101
|
-
windowSize: windowSize,
|
|
102
|
-
isHorizontal: true))
|
|
103
|
-
|
|
104
|
-
testCell.frame = CGRect(x: windowSize + cellHeight, y: 0, width: cellHeight, height: cellHeight)
|
|
105
|
-
// Hidden
|
|
106
|
-
XCTAssertFalse(autoLayoutView.isWithinBounds(testCell,
|
|
107
|
-
scrollOffset: 0,
|
|
108
|
-
renderAheadOffset: 0,
|
|
109
|
-
windowSize: windowSize,
|
|
110
|
-
isHorizontal: true))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
}
|