forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native-screens+3.34.0+003+fabric-flat-list-fix.patch
57 lines (56 loc) · 2.93 KB
/
react-native-screens+3.34.0+003+fabric-flat-list-fix.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
diff --git a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/Screen.kt b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/Screen.kt
index 9d08d39..146b9c2 100644
--- a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/Screen.kt
+++ b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/Screen.kt
@@ -18,6 +18,7 @@ import com.facebook.react.uimanager.PixelUtil
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.UIManagerModule
import com.swmansion.rnscreens.events.HeaderHeightChangeEvent
+import com.swmansion.rnscreens.ext.isInsideScrollViewWithRemoveClippedSubviews
@SuppressLint("ViewConstructor") // Only we construct this view, it is never inflated.
class Screen(
@@ -310,6 +311,16 @@ class Screen(
startTransitionRecursive(child.toolbar)
}
if (child is ViewGroup) {
+ // a combination of https://github.com/software-mansion/react-native-screens/pull/2307/files and https://github.com/software-mansion/react-native-screens/pull/2383/files
+ // The children are miscounted when there's a FlatList with
+ // removeClippedSubviews set to true (default).
+ // We add a simple view for each item in the list to make it work as expected.
+ // See https://github.com/software-mansion/react-native-screens/issues/2282
+ if (child.isInsideScrollViewWithRemoveClippedSubviews()) {
+ for (j in 0 until child.childCount) {
+ child.addView(View(context))
+ }
+ }
startTransitionRecursive(child)
}
}
diff --git a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt
new file mode 100644
index 0000000..9d9fbfd
--- /dev/null
+++ b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt
@@ -0,0 +1,21 @@
+package com.swmansion.rnscreens.ext
+
+import android.view.View
+import android.view.ViewGroup
+import com.facebook.react.views.scroll.ReactHorizontalScrollView
+import com.facebook.react.views.scroll.ReactScrollView
+import com.swmansion.rnscreens.ScreenStack
+
+internal fun View.isInsideScrollViewWithRemoveClippedSubviews(): Boolean {
+ if (this is ReactHorizontalScrollView || this is ReactScrollView) {
+ return false
+ }
+ var parentView = this.parent
+ while (parentView is ViewGroup && parentView !is ScreenStack) {
+ if (parentView is ReactScrollView) {
+ return parentView.removeClippedSubviews
+ }
+ parentView = parentView.parent
+ }
+ return false
+}
\ No newline at end of file