From 2e73c1fd3a8c00724ded4010768e18ef28745457 Mon Sep 17 00:00:00 2001 From: alduzy Date: Wed, 13 Nov 2024 13:53:43 +0100 Subject: [PATCH] removed redundant logic --- .../main/java/com/swmansion/rnscreens/Screen.kt | 15 ++++++--------- .../java/com/swmansion/rnscreens/ext/ViewExt.kt | 4 ---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/Screen.kt b/android/src/main/java/com/swmansion/rnscreens/Screen.kt index 27c67ad9f7..292be99340 100644 --- a/android/src/main/java/com/swmansion/rnscreens/Screen.kt +++ b/android/src/main/java/com/swmansion/rnscreens/Screen.kt @@ -28,7 +28,6 @@ import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.shape.ShapeAppearanceModel import com.swmansion.rnscreens.events.HeaderHeightChangeEvent import com.swmansion.rnscreens.events.SheetDetentChangedEvent -import com.swmansion.rnscreens.ext.removeClippedSubviews import java.lang.ref.WeakReference @SuppressLint("ViewConstructor") // Only we construct this view, it is never inflated. @@ -380,10 +379,7 @@ class Screen( } } - private fun startTransitionRecursive( - parent: ViewGroup?, - isPossiblyRemovedClippedSubview: Boolean = true, - ) { + private fun startTransitionRecursive(parent: ViewGroup?) { parent?.let { for (i in 0 until it.childCount) { val child = it.getChildAt(i) @@ -401,19 +397,20 @@ class Screen( if (child is ScreenStackHeaderConfig) { // we want to start transition on children of the toolbar too, // which is not a child of ScreenStackHeaderConfig - startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.removeClippedSubviews) + startTransitionRecursive(child) } if (child is ViewGroup) { // The children are miscounted when there's removeClippedSubviews prop // set to true (which is the default for FlatLists). - // We add a simple view for each possibly clipped item to make it work as expected. + // Unless the child is a ScrollView it's safe to assume that it's true + // and add a simple view for each possibly clipped item to make it work as expected. // See https://github.com/software-mansion/react-native-screens/pull/2495 - if (isPossiblyRemovedClippedSubview && child !is ReactScrollView && child !is ReactHorizontalScrollView) { + if (child !is ReactScrollView && child !is ReactHorizontalScrollView) { for (j in 0 until child.childCount) { child.addView(View(context)) } } - startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.removeClippedSubviews) + startTransitionRecursive(child) } } } diff --git a/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt b/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt index 3da5b3e0d2..f9258e1ed1 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt @@ -3,7 +3,6 @@ package com.swmansion.rnscreens.ext import android.graphics.drawable.ColorDrawable import android.view.View import android.view.ViewGroup -import com.facebook.react.views.view.ReactViewGroup internal fun View.parentAsView() = this.parent as? View @@ -31,6 +30,3 @@ internal fun View.maybeBgColor(): Int? { } return null } - -internal val View.removeClippedSubviews: Boolean - get() = (this as? ReactViewGroup)?.removeClippedSubviews ?: false