Skip to content

Commit

Permalink
simplified property
Browse files Browse the repository at this point in the history
  • Loading branch information
alduzy committed Nov 13, 2024
1 parent 41a6562 commit 2054ee4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 3 additions & 3 deletions android/src/main/java/com/swmansion/rnscreens/Screen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -413,7 +413,7 @@ class Screen(
child.addView(View(context))
}
}
startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.isRemovingClippedSubviews)
startTransitionRecursive(child, isPossiblyRemovedClippedSubview || it.removeClippedSubviews)
}
}
}
Expand Down
12 changes: 3 additions & 9 deletions android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 2054ee4

Please sign in to comment.