From 2054ee4a54278fe83fc5ff1807c04990e5afe2e9 Mon Sep 17 00:00:00 2001 From: alduzy Date: Wed, 13 Nov 2024 12:58:39 +0100 Subject: [PATCH] simplified property --- .../src/main/java/com/swmansion/rnscreens/Screen.kt | 6 +++--- .../main/java/com/swmansion/rnscreens/ext/ViewExt.kt | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/android/src/main/java/com/swmansion/rnscreens/Screen.kt b/android/src/main/java/com/swmansion/rnscreens/Screen.kt index f7a7ff32df..27c67ad9f7 100644 --- a/android/src/main/java/com/swmansion/rnscreens/Screen.kt +++ b/android/src/main/java/com/swmansion/rnscreens/Screen.kt @@ -28,7 +28,7 @@ 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.isRemovingClippedSubviews +import com.swmansion.rnscreens.ext.removeClippedSubviews import java.lang.ref.WeakReference @SuppressLint("ViewConstructor") // Only we construct this view, it is never inflated. @@ -401,7 +401,7 @@ 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.isRemovingClippedSubviews) + startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.removeClippedSubviews) } if (child is ViewGroup) { // The children are miscounted when there's removeClippedSubviews prop @@ -413,7 +413,7 @@ class Screen( child.addView(View(context)) } } - startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.isRemovingClippedSubviews) + startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.removeClippedSubviews) } } } 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 36cc738827..3da5b3e0d2 100644 --- a/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt +++ b/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt @@ -3,8 +3,7 @@ package com.swmansion.rnscreens.ext import android.graphics.drawable.ColorDrawable import android.view.View import android.view.ViewGroup -import com.facebook.react.views.scroll.ReactHorizontalScrollView -import com.facebook.react.views.scroll.ReactScrollView +import com.facebook.react.views.view.ReactViewGroup internal fun View.parentAsView() = this.parent as? View @@ -33,10 +32,5 @@ internal fun View.maybeBgColor(): Int? { return null } -internal val View.isRemovingClippedSubviews: Boolean - get() = - when (this) { - is ReactHorizontalScrollView -> removeClippedSubviews - is ReactScrollView -> removeClippedSubviews - else -> false - } +internal val View.removeClippedSubviews: Boolean + get() = (this as? ReactViewGroup)?.removeClippedSubviews ?: false