@shopify/flash-list 2.0.0 → 2.0.2-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/README.md +97 -27
- package/RNFlashList.podspec +37 -0
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +105 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +158 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutViewManager.kt +70 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/BlankAreaEvent.kt +29 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainer.java +16 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerImpl.kt +16 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/CellContainerManager.kt +34 -0
- package/android/src/main/kotlin/com/shopify/reactnative/flash_list/FlashListPackage.kt +19 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java +47 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java +21 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java +32 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java +16 -0
- package/android/src/test/java/com/shopify/reactnative/flash_list/AutoLayoutShadowTest.kt +147 -0
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/Rect.kt +61 -0
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestCollection.kt +6 -0
- package/android/src/test/java/com/shopify/reactnative/flash_list/models/TestDataModel.kt +8 -0
- package/android/src/test/resources/LayoutTestData.json +788 -0
- package/dist/AnimatedFlashList.js +2 -2
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +167 -1
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +595 -3
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +63 -2
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js.map +1 -1
- package/dist/GridLayoutProviderWithProps.d.ts +42 -0
- package/dist/GridLayoutProviderWithProps.d.ts.map +1 -0
- package/dist/GridLayoutProviderWithProps.js +114 -0
- package/dist/GridLayoutProviderWithProps.js.map +1 -0
- package/dist/MasonryFlashList.d.ts +51 -0
- package/dist/MasonryFlashList.d.ts.map +1 -0
- package/dist/MasonryFlashList.js +252 -0
- package/dist/MasonryFlashList.js.map +1 -0
- package/dist/PureComponentWrapper.d.ts +22 -0
- package/dist/PureComponentWrapper.d.ts.map +1 -0
- package/dist/PureComponentWrapper.js +37 -0
- package/dist/PureComponentWrapper.js.map +1 -0
- package/dist/__tests__/ContentContainerUtils.test.d.ts +2 -0
- package/dist/__tests__/ContentContainerUtils.test.d.ts.map +1 -0
- package/dist/__tests__/ContentContainerUtils.test.js +85 -0
- package/dist/__tests__/ContentContainerUtils.test.js.map +1 -0
- package/dist/__tests__/FlashList.test.d.ts +2 -0
- package/dist/__tests__/FlashList.test.d.ts.map +1 -0
- package/dist/__tests__/FlashList.test.js +902 -0
- package/dist/__tests__/FlashList.test.js.map +1 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts +2 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.d.ts.map +1 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.js +143 -0
- package/dist/__tests__/GridLayoutProviderWithProps.test.js.map +1 -0
- package/dist/__tests__/MasonryFlashList.test.d.ts +2 -0
- package/dist/__tests__/MasonryFlashList.test.d.ts.map +1 -0
- package/dist/__tests__/MasonryFlashList.test.js +254 -0
- package/dist/__tests__/MasonryFlashList.test.js.map +1 -0
- package/dist/__tests__/PlatformHelper.web.test.d.ts +2 -0
- package/dist/__tests__/PlatformHelper.web.test.d.ts.map +1 -0
- package/dist/__tests__/PlatformHelper.web.test.js +33 -0
- package/dist/__tests__/PlatformHelper.web.test.js.map +1 -0
- package/dist/__tests__/ViewabilityHelper.test.js +4 -3
- package/dist/__tests__/ViewabilityHelper.test.js.map +1 -1
- package/dist/__tests__/helpers/mountFlashList.d.ts +19 -0
- package/dist/__tests__/helpers/mountFlashList.d.ts.map +1 -0
- package/dist/__tests__/helpers/mountFlashList.js +44 -0
- package/dist/__tests__/helpers/mountFlashList.js.map +1 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts +18 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.d.ts.map +1 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.js +49 -0
- package/dist/__tests__/helpers/mountMasonryFlashList.js.map +1 -0
- package/dist/__tests__/useBlankAreaTracker.test.d.ts +2 -0
- package/dist/__tests__/useBlankAreaTracker.test.d.ts.map +1 -0
- package/dist/__tests__/useBlankAreaTracker.test.js +179 -0
- package/dist/__tests__/useBlankAreaTracker.test.js.map +1 -0
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +1 -2
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +4 -2
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +24 -12
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +34 -0
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +1 -0
- package/dist/benchmark/useBlankAreaTracker.js +66 -0
- package/dist/benchmark/useBlankAreaTracker.js.map +1 -0
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +1 -2
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/enableNewCore.d.ts +3 -0
- package/dist/enableNewCore.d.ts.map +1 -0
- package/dist/enableNewCore.js +25 -0
- package/dist/enableNewCore.js.map +1 -0
- package/dist/errors/CustomError.d.ts +8 -0
- package/dist/errors/CustomError.d.ts.map +1 -0
- package/dist/errors/CustomError.js +14 -0
- package/dist/errors/CustomError.js.map +1 -0
- package/dist/errors/ExceptionList.d.ts +24 -0
- package/dist/errors/ExceptionList.d.ts.map +1 -0
- package/dist/errors/ExceptionList.js +26 -0
- package/dist/errors/ExceptionList.js.map +1 -0
- package/dist/errors/Warnings.d.ts +9 -0
- package/dist/errors/Warnings.d.ts.map +1 -0
- package/dist/errors/Warnings.js +13 -0
- package/dist/errors/Warnings.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +22 -0
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutView.js +48 -0
- package/dist/native/auto-layout/AutoLayoutView.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +4 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +5 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +4 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +6 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +16 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +3 -0
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +1 -0
- package/dist/native/cell-container/CellContainer.android.d.ts +6 -0
- package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.android.js +9 -0
- package/dist/native/cell-container/CellContainer.android.js.map +1 -0
- package/dist/native/cell-container/CellContainer.d.ts +8 -0
- package/dist/native/cell-container/CellContainer.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts +6 -0
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.ios.js +9 -0
- package/dist/native/cell-container/CellContainer.ios.js.map +1 -0
- package/dist/native/cell-container/CellContainer.js +11 -0
- package/dist/native/cell-container/CellContainer.js.map +1 -0
- package/dist/native/cell-container/CellContainer.web.d.ts +7 -0
- package/dist/native/cell-container/CellContainer.web.d.ts.map +1 -0
- package/dist/native/cell-container/CellContainer.web.js +13 -0
- package/dist/native/cell-container/CellContainer.web.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +22 -1
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +16 -1
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +22 -1
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +22 -1
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +15 -1
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +16 -1
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +23 -1
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +18 -1
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +6 -6
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +8 -9
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts +8 -1
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -1
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +3 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -1
- package/dist/recyclerview/helpers/RenderTimeTracker.js +7 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +0 -4
- 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 +1 -2
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -1
- package/dist/specs/AutoLayoutNativeComponent.d.ts +18 -0
- package/dist/specs/AutoLayoutNativeComponent.d.ts.map +1 -0
- package/dist/specs/AutoLayoutNativeComponent.js +6 -0
- package/dist/specs/AutoLayoutNativeComponent.js.map +1 -0
- package/dist/specs/CellContainerNativeComponent.d.ts +8 -0
- package/dist/specs/CellContainerNativeComponent.d.ts.map +1 -0
- package/dist/specs/CellContainerNativeComponent.js +6 -0
- package/dist/specs/CellContainerNativeComponent.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/ContentContainerUtils.d.ts +27 -0
- package/dist/utils/ContentContainerUtils.d.ts.map +1 -0
- package/dist/utils/ContentContainerUtils.js +48 -0
- package/dist/utils/ContentContainerUtils.js.map +1 -0
- package/dist/viewability/ViewToken.d.ts.map +1 -0
- package/dist/viewability/ViewToken.js.map +1 -0
- package/dist/{recyclerview/viewability → viewability}/ViewabilityHelper.d.ts +2 -2
- package/dist/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/{recyclerview/viewability → viewability}/ViewabilityHelper.js +4 -2
- package/dist/{recyclerview/viewability → viewability}/ViewabilityHelper.js.map +1 -1
- package/dist/{recyclerview/viewability → viewability}/ViewabilityManager.d.ts +3 -3
- package/dist/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/{recyclerview/viewability → viewability}/ViewabilityManager.js +16 -16
- package/dist/viewability/ViewabilityManager.js.map +1 -0
- package/ios/RNFlashList.xcodeproj/project.pbxproj +3 -0
- package/ios/RNFlashList.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/Sources/AutoLayoutView.swift +294 -0
- package/ios/Sources/AutoLayoutViewComponentView.h +16 -0
- package/ios/Sources/AutoLayoutViewComponentView.mm +90 -0
- package/ios/Sources/AutoLayoutViewManager.mm +14 -0
- package/ios/Sources/AutoLayoutViewManager.swift +12 -0
- package/ios/Sources/CellContainerComponentView.h +18 -0
- package/ios/Sources/CellContainerComponentView.mm +62 -0
- package/ios/Sources/CellContainerManager.mm +8 -0
- package/ios/Sources/CellContainerManager.swift +12 -0
- package/ios/Sources/FlatListPro-Bridging-Header.h +11 -0
- package/ios/Tests/AutoLayoutViewTests.swift +113 -0
- package/package.json +14 -3
- package/src/AnimatedFlashList.ts +2 -2
- package/src/FlashList.tsx +953 -0
- package/src/FlashListProps.ts +79 -3
- package/src/GridLayoutProviderWithProps.ts +180 -0
- package/src/MasonryFlashList.tsx +476 -0
- package/src/PureComponentWrapper.tsx +42 -0
- package/src/__tests__/ContentContainerUtils.test.ts +130 -0
- package/src/__tests__/FlashList.test.tsx +1001 -0
- package/src/__tests__/GridLayoutProviderWithProps.test.ts +179 -0
- package/src/__tests__/MasonryFlashList.test.ts +292 -0
- package/src/__tests__/PlatformHelper.web.test.ts +45 -0
- package/src/__tests__/ViewabilityHelper.test.ts +14 -13
- package/src/__tests__/helpers/mountFlashList.tsx +62 -0
- package/src/__tests__/helpers/mountMasonryFlashList.tsx +70 -0
- package/src/__tests__/useBlankAreaTracker.test.tsx +206 -0
- package/src/benchmark/JSFPSMonitor.ts +3 -3
- package/src/benchmark/useBenchmark.ts +40 -12
- package/src/benchmark/useBlankAreaTracker.ts +117 -0
- package/src/benchmark/useFlatListBenchmark.ts +1 -3
- package/src/enableNewCore.ts +24 -0
- package/src/errors/CustomError.ts +10 -0
- package/src/errors/ExceptionList.ts +28 -0
- package/src/errors/Warnings.ts +15 -0
- package/src/index.ts +43 -7
- package/src/native/auto-layout/AutoLayoutView.tsx +73 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +7 -0
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +17 -0
- package/src/native/cell-container/CellContainer.android.ts +7 -0
- package/src/native/cell-container/CellContainer.ios.ts +7 -0
- package/src/native/cell-container/CellContainer.tsx +14 -0
- package/src/native/cell-container/CellContainer.web.tsx +9 -0
- package/src/native/config/PlatformHelper.android.ts +25 -1
- package/src/native/config/PlatformHelper.ios.ts +24 -1
- package/src/native/config/PlatformHelper.ts +25 -1
- package/src/native/config/PlatformHelper.web.ts +30 -1
- package/src/recyclerview/RecyclerView.tsx +11 -6
- package/src/recyclerview/RecyclerViewManager.ts +18 -9
- package/src/recyclerview/RecyclerViewProps.ts +11 -1
- package/src/recyclerview/helpers/RenderTimeTracker.ts +8 -0
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +0 -4
- package/src/recyclerview/layout-managers/LayoutManager.ts +1 -2
- package/src/specs/AutoLayoutNativeComponent.ts +24 -0
- package/src/specs/CellContainerNativeComponent.ts +9 -0
- package/src/utils/ContentContainerUtils.ts +92 -0
- package/src/{recyclerview/viewability → viewability}/ViewabilityHelper.ts +9 -8
- package/src/{recyclerview/viewability → viewability}/ViewabilityManager.ts +20 -18
- package/dist/errors/ErrorMessages.d.ts +0 -16
- package/dist/errors/ErrorMessages.d.ts.map +0 -1
- package/dist/errors/ErrorMessages.js +0 -19
- package/dist/errors/ErrorMessages.js.map +0 -1
- package/dist/errors/WarningMessages.d.ts +0 -4
- package/dist/errors/WarningMessages.d.ts.map +0 -1
- package/dist/errors/WarningMessages.js +0 -7
- package/dist/errors/WarningMessages.js.map +0 -1
- package/dist/isNewArch.d.ts +0 -2
- package/dist/isNewArch.d.ts.map +0 -1
- package/dist/isNewArch.js +0 -25
- package/dist/isNewArch.js.map +0 -1
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +0 -1
- package/dist/recyclerview/viewability/ViewToken.js.map +0 -1
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +0 -1
- package/src/FlashList.ts +0 -1
- package/src/errors/ErrorMessages.ts +0 -26
- package/src/errors/WarningMessages.ts +0 -4
- package/src/isNewArch.ts +0 -25
- /package/dist/{recyclerview/viewability → viewability}/ViewToken.d.ts +0 -0
- /package/dist/{recyclerview/viewability → viewability}/ViewToken.js +0 -0
- /package/src/{recyclerview/viewability → viewability}/ViewToken.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.shopify.reactnative.flash_list
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
5
|
+
|
|
6
|
+
class CellContainerImpl(context: Context) : ReactViewGroup(context), CellContainer {
|
|
7
|
+
private var index = -1
|
|
8
|
+
override fun setIndex(value: Int) {
|
|
9
|
+
index = value
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
override fun getIndex(): Int {
|
|
13
|
+
return index
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
package com.shopify.reactnative.flash_list
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
6
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
7
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
+
import com.facebook.react.viewmanagers.CellContainerManagerDelegate
|
|
9
|
+
import com.facebook.react.viewmanagers.CellContainerManagerInterface
|
|
10
|
+
|
|
11
|
+
@ReactModule(name = AutoLayoutViewManager.REACT_CLASS)
|
|
12
|
+
class CellContainerManager: ViewGroupManager<CellContainerImpl>(), CellContainerManagerInterface<CellContainerImpl> {
|
|
13
|
+
private val mDelegate: CellContainerManagerDelegate<CellContainerImpl, CellContainerManager>
|
|
14
|
+
= CellContainerManagerDelegate(this)
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
const val REACT_CLASS = "CellContainer"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getName(): String {
|
|
21
|
+
return REACT_CLASS
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun getDelegate(): ViewManagerDelegate<CellContainerImpl> = mDelegate
|
|
25
|
+
|
|
26
|
+
override fun createViewInstance(context: ThemedReactContext): CellContainerImpl {
|
|
27
|
+
return CellContainerImpl(context)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactProp(name = "index")
|
|
31
|
+
override fun setIndex(view: CellContainerImpl, index: Int) {
|
|
32
|
+
view.index = index
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.shopify.reactnative.flash_list
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class ReactNativeFlashListPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return listOf(
|
|
15
|
+
AutoLayoutViewManager(),
|
|
16
|
+
CellContainerManager()
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerDelegate.java
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
15
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
|
+
|
|
18
|
+
public class AutoLayoutViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & AutoLayoutViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
+
public AutoLayoutViewManagerDelegate(U viewManager) {
|
|
20
|
+
super(viewManager);
|
|
21
|
+
}
|
|
22
|
+
@Override
|
|
23
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
+
switch (propName) {
|
|
25
|
+
case "horizontal":
|
|
26
|
+
mViewManager.setHorizontal(view, value == null ? false : (boolean) value);
|
|
27
|
+
break;
|
|
28
|
+
case "scrollOffset":
|
|
29
|
+
mViewManager.setScrollOffset(view, value == null ? 0f : ((Double) value).doubleValue());
|
|
30
|
+
break;
|
|
31
|
+
case "windowSize":
|
|
32
|
+
mViewManager.setWindowSize(view, value == null ? 0f : ((Double) value).doubleValue());
|
|
33
|
+
break;
|
|
34
|
+
case "renderAheadOffset":
|
|
35
|
+
mViewManager.setRenderAheadOffset(view, value == null ? 0f : ((Double) value).doubleValue());
|
|
36
|
+
break;
|
|
37
|
+
case "enableInstrumentation":
|
|
38
|
+
mViewManager.setEnableInstrumentation(view, value == null ? false : (boolean) value);
|
|
39
|
+
break;
|
|
40
|
+
case "disableAutoLayout":
|
|
41
|
+
mViewManager.setDisableAutoLayout(view, value == null ? false : (boolean) value);
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
super.setProperty(view, propName, value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/AutoLayoutViewManagerInterface.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
|
|
14
|
+
public interface AutoLayoutViewManagerInterface<T extends View> {
|
|
15
|
+
void setHorizontal(T view, boolean value);
|
|
16
|
+
void setScrollOffset(T view, double value);
|
|
17
|
+
void setWindowSize(T view, double value);
|
|
18
|
+
void setRenderAheadOffset(T view, double value);
|
|
19
|
+
void setEnableInstrumentation(T view, boolean value);
|
|
20
|
+
void setDisableAutoLayout(T view, boolean value);
|
|
21
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerDelegate.java
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import androidx.annotation.Nullable;
|
|
14
|
+
import com.facebook.react.uimanager.BaseViewManager;
|
|
15
|
+
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
+
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
|
+
|
|
18
|
+
public class CellContainerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CellContainerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
+
public CellContainerManagerDelegate(U viewManager) {
|
|
20
|
+
super(viewManager);
|
|
21
|
+
}
|
|
22
|
+
@Override
|
|
23
|
+
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
+
switch (propName) {
|
|
25
|
+
case "index":
|
|
26
|
+
mViewManager.setIndex(view, value == null ? 0 : ((Double) value).intValue());
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
super.setProperty(view, propName, value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/android/src/paper/java/com/facebook/react/viewmanagers/CellContainerManagerInterface.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
package com.facebook.react.viewmanagers;
|
|
11
|
+
|
|
12
|
+
import android.view.View;
|
|
13
|
+
|
|
14
|
+
public interface CellContainerManagerInterface<T extends View> {
|
|
15
|
+
void setIndex(T view, int value);
|
|
16
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
package com.shopify.reactnative.flash_list
|
|
2
|
+
|
|
3
|
+
import com.google.gson.Gson
|
|
4
|
+
import com.shopify.reactnative.flash_list.models.Rect
|
|
5
|
+
import com.shopify.reactnative.flash_list.models.TestDataModel
|
|
6
|
+
import org.junit.Assert.assertEquals
|
|
7
|
+
import org.junit.Test
|
|
8
|
+
|
|
9
|
+
internal class AutoLayoutShadowTest {
|
|
10
|
+
private val gson = Gson()
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Test against expected output from stored JSON */
|
|
14
|
+
@Test
|
|
15
|
+
fun clearGapsAndOverlapsVerticalList() {
|
|
16
|
+
val alShadow = getAutolayoutShadow(0)
|
|
17
|
+
val testModel = getTestModel()
|
|
18
|
+
testModel.vertical.forEachIndexed { index, it ->
|
|
19
|
+
alShadow.clearGapsAndOverlaps(it.input as Array<CellContainer>)
|
|
20
|
+
assertEquals("Index: $index", gson.toJson(it.expectedOutput), gson.toJson(it.input))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Test against expected output from stored JSON */
|
|
26
|
+
@Test
|
|
27
|
+
fun clearGapsAndOverlapsHorizontalList() {
|
|
28
|
+
val alShadow = getAutolayoutShadow(0)
|
|
29
|
+
alShadow.horizontal = true
|
|
30
|
+
val testModel = getTestModel()
|
|
31
|
+
testModel.horizontal.forEachIndexed { index, it ->
|
|
32
|
+
alShadow.clearGapsAndOverlaps(it.input as Array<CellContainer>)
|
|
33
|
+
assertEquals("Index: $index", gson.toJson(it.expectedOutput), gson.toJson(it.input))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Test against expected output from stored JSON */
|
|
39
|
+
@Test
|
|
40
|
+
fun clearGapsAndOverlapsWindowSize() {
|
|
41
|
+
val alShadow = getAutolayoutShadow(0)
|
|
42
|
+
alShadow.horizontal = true
|
|
43
|
+
alShadow.windowSize = 90
|
|
44
|
+
val testModel = getTestModel()
|
|
45
|
+
testModel.window.forEachIndexed { index, it ->
|
|
46
|
+
alShadow.clearGapsAndOverlaps(it.input as Array<CellContainer>)
|
|
47
|
+
assertEquals("Index: $index", gson.toJson(it.expectedOutput), gson.toJson(it.input))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Should only correct items in the visible window*/
|
|
53
|
+
@Test
|
|
54
|
+
fun clearGapsAndOverlapsBoundaryTest() {
|
|
55
|
+
val alShadow = getAutolayoutShadow(300)
|
|
56
|
+
alShadow.renderOffset = 100
|
|
57
|
+
|
|
58
|
+
//--------- Vertical -----------
|
|
59
|
+
//Item above visible window
|
|
60
|
+
arrayOf<CellContainer>(getRect(0, 0, 100, 100, 0), getRect(120, 0, 100, 100, 1)).let {
|
|
61
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
62
|
+
assertEquals(120, it[1].left)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//Item below visible window
|
|
66
|
+
arrayOf<CellContainer>(getRect(0, 0, 100, 100, 0), getRect(120, 850, 100, 950, 1)).let {
|
|
67
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
68
|
+
assertEquals(850, it[1].top)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//Item within visible window
|
|
72
|
+
arrayOf<CellContainer>(getRect(0, 250, 100, 100, 0), getRect(120, 250, 100, 100, 1)).let {
|
|
73
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
74
|
+
assertEquals(100, it[1].left)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//At the top edge
|
|
78
|
+
arrayOf<CellContainer>(getRect(0, 200, 100, 100, 0), getRect(120, 200, 100, 100, 1)).let {
|
|
79
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
80
|
+
assertEquals(100, it[1].left)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//--------- Horizontal -----------
|
|
84
|
+
|
|
85
|
+
alShadow.horizontal = true
|
|
86
|
+
|
|
87
|
+
//Item left of visible window
|
|
88
|
+
arrayOf<CellContainer>(getRect(0, 0, 100, 100, 0), getRect(0, 120, 100, 100, 1)).let {
|
|
89
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
90
|
+
assertEquals(120, it[1].top)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//Item right of visible window
|
|
94
|
+
arrayOf<CellContainer>(getRect(0, 0, 100, 100, 0), getRect(850, 120, 950, 220, 1)).let {
|
|
95
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
96
|
+
assertEquals(120, it[1].top)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//Item within visible window
|
|
100
|
+
arrayOf<CellContainer>(getRect(250, 0, 100, 100, 0), getRect(250, 120, 100, 100, 1)).let {
|
|
101
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
102
|
+
assertEquals(100, it[1].top)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//At the left edge
|
|
106
|
+
arrayOf<CellContainer>(getRect(200, 0, 100, 100, 0), getRect(250, 150, 100, 100, 1)).let {
|
|
107
|
+
alShadow.clearGapsAndOverlaps(it)
|
|
108
|
+
assertEquals(100, it[1].top)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Test
|
|
113
|
+
fun checkBlankForLastItem() {
|
|
114
|
+
val alShadow = getAutolayoutShadow(0)
|
|
115
|
+
val testModel = getTestModel()
|
|
116
|
+
testModel.vertical.forEachIndexed { index, it ->
|
|
117
|
+
alShadow.clearGapsAndOverlaps(it.input as Array<CellContainer>)
|
|
118
|
+
it.expectedOutput.map { value -> value.bottom }.maxOrNull()?.let { max ->
|
|
119
|
+
alShadow.computeBlankFromGivenOffset(0, 0, 0)
|
|
120
|
+
assertEquals("Index: $index", alShadow.windowSize - max, alShadow.blankOffsetAtEnd)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private fun getTestModel(): TestDataModel {
|
|
126
|
+
var str = this.javaClass.classLoader.getResource("LayoutTestData.json").readText()
|
|
127
|
+
return gson.fromJson<TestDataModel>(str, TestDataModel::class.java)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private fun getRect(l: Int, t: Int, r: Int, b: Int, index: Int): Rect {
|
|
131
|
+
var rect = Rect(b - t, r - l)
|
|
132
|
+
rect.left = l
|
|
133
|
+
rect.right = r
|
|
134
|
+
rect.bottom = b
|
|
135
|
+
rect.top = t
|
|
136
|
+
rect.index = index
|
|
137
|
+
return rect
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private fun getAutolayoutShadow(offset: Int): AutoLayoutShadow {
|
|
141
|
+
val alShadow = AutoLayoutShadow()
|
|
142
|
+
alShadow.windowSize = 500
|
|
143
|
+
alShadow.renderOffset = 0
|
|
144
|
+
alShadow.scrollOffset = offset
|
|
145
|
+
return alShadow
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
package com.shopify.reactnative.flash_list.models
|
|
2
|
+
|
|
3
|
+
import com.shopify.reactnative.flash_list.CellContainer
|
|
4
|
+
|
|
5
|
+
class Rect (h: Int? = 0, w: Int? = 0): CellContainer {
|
|
6
|
+
private var left = 0
|
|
7
|
+
private var right = 0
|
|
8
|
+
private var top = 0
|
|
9
|
+
private var bottom = 0
|
|
10
|
+
private var height = 0
|
|
11
|
+
private var width = 0
|
|
12
|
+
private var index = 0
|
|
13
|
+
|
|
14
|
+
override fun setIndex(value: Int) {
|
|
15
|
+
index = value
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun getIndex(): Int {
|
|
19
|
+
return index
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun setLeft(value: Int) {
|
|
23
|
+
left = value
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getLeft(): Int {
|
|
27
|
+
return left
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun setTop(value: Int) {
|
|
31
|
+
top = value
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun getTop(): Int {
|
|
35
|
+
return top
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
override fun setRight(value: Int) {
|
|
39
|
+
right = value
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun getRight(): Int {
|
|
43
|
+
return right
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun setBottom(value: Int) {
|
|
47
|
+
bottom = value
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun getBottom(): Int {
|
|
51
|
+
return bottom
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun getHeight(): Int {
|
|
55
|
+
return height
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun getWidth(): Int {
|
|
59
|
+
return width
|
|
60
|
+
}
|
|
61
|
+
}
|