mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ReactViewGroup post-conversion cleanup (#46668)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46668 Small tweaks post-Kotlin-conversion: - Make `overflow` a var - Replace `+ -` with `-` - Clean up properties and move up init block - Iterate over entire allChildren array to clean up listeners Changelog: [Internal] Reviewed By: cortinico Differential Revision: D63343964 fbshipit-source-id: 2e9022e2d7e54ac338d1003419d8959771f7f270
This commit is contained in:
committed by
Facebook GitHub Bot
parent
be5e2b5827
commit
9cd83fa9ab
@@ -4742,6 +4742,7 @@ public final class com/facebook/react/uimanager/ReactInvalidPropertyException :
|
||||
|
||||
public abstract interface class com/facebook/react/uimanager/ReactOverflowView {
|
||||
public abstract fun getOverflow ()Ljava/lang/String;
|
||||
public abstract fun setOverflow (Ljava/lang/String;)V
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/uimanager/ReactOverflowViewWithInset : com/facebook/react/uimanager/ReactOverflowView {
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Interface that should be implemented by {@link View} subclasses that support {@code overflow}
|
||||
* style. This allows the overflow information to be used by {@link TouchTargetHelper} to determine
|
||||
* if a View is touchable.
|
||||
*/
|
||||
public interface ReactOverflowView {
|
||||
/**
|
||||
* Gets the overflow state of a view. If set, this should be one of {@link ViewProps#HIDDEN},
|
||||
* {@link ViewProps#VISIBLE} or {@link ViewProps#SCROLL}.
|
||||
*/
|
||||
@Nullable
|
||||
String getOverflow();
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.uimanager
|
||||
|
||||
/**
|
||||
* Interface that should be implemented by [View] subclasses that support `overflow` style. This
|
||||
* allows the overflow information to be used by [TouchTargetHelper] to determine if a View is
|
||||
* touchable.
|
||||
*/
|
||||
public interface ReactOverflowView {
|
||||
/**
|
||||
* The overflow state of a view. If set, this should be one of:
|
||||
* - [ViewProps.HIDDEN],
|
||||
* - [ViewProps.VISIBLE]
|
||||
* - [ViewProps.SCROLL].
|
||||
*/
|
||||
public var overflow: String?
|
||||
}
|
||||
+30
-40
@@ -127,9 +127,16 @@ public open class ReactViewGroup(context: Context) :
|
||||
private var childrenLayoutChangeListener: ChildrenLayoutChangeListener? = null
|
||||
private var onInterceptTouchEventListener: OnInterceptTouchEventListener? = null
|
||||
private var needsOffscreenAlphaCompositing = false
|
||||
private var _drawingOrderHelper: ViewGroupDrawingOrderHelper? = null
|
||||
private var backfaceOpacity = 1f
|
||||
private var backfaceVisibility: String? = "visible"
|
||||
private var _drawingOrderHelper: ViewGroupDrawingOrderHelper? = null
|
||||
private val drawingOrderHelper: ViewGroupDrawingOrderHelper
|
||||
get() =
|
||||
_drawingOrderHelper ?: ViewGroupDrawingOrderHelper(this).also { _drawingOrderHelper = it }
|
||||
|
||||
init {
|
||||
initView()
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all default values here as opposed to in the constructor or field defaults. It is important
|
||||
@@ -158,9 +165,7 @@ public open class ReactViewGroup(context: Context) :
|
||||
val children = allChildren
|
||||
val listener = childrenLayoutChangeListener
|
||||
if (children != null && listener != null) {
|
||||
for (i in 0 until allChildrenCount) {
|
||||
children[i]?.removeOnLayoutChangeListener(listener)
|
||||
}
|
||||
children.forEach { child -> child?.removeOnLayoutChangeListener(listener) }
|
||||
}
|
||||
|
||||
// Set default field values
|
||||
@@ -175,16 +180,6 @@ public open class ReactViewGroup(context: Context) :
|
||||
resetPointerEvents()
|
||||
}
|
||||
|
||||
private val drawingOrderHelper: ViewGroupDrawingOrderHelper
|
||||
get() {
|
||||
return _drawingOrderHelper
|
||||
?: ViewGroupDrawingOrderHelper(this).also { _drawingOrderHelper = it }
|
||||
}
|
||||
|
||||
init {
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
MeasureSpecAssertions.assertExplicitMeasureSpec(widthMeasureSpec, heightMeasureSpec)
|
||||
setMeasuredDimension(
|
||||
@@ -335,9 +330,7 @@ public open class ReactViewGroup(context: Context) :
|
||||
val clippingRect = checkNotNull(_clippingRect)
|
||||
val children = checkNotNull(allChildren)
|
||||
val listener = checkNotNull(childrenLayoutChangeListener)
|
||||
for (i in 0 until allChildrenCount) {
|
||||
children[i]?.removeOnLayoutChangeListener(listener)
|
||||
}
|
||||
children.forEach { child -> child?.removeOnLayoutChangeListener(listener) }
|
||||
getDrawingRect(clippingRect)
|
||||
updateClippingToRect(clippingRect)
|
||||
allChildren = null
|
||||
@@ -635,9 +628,7 @@ public open class ReactViewGroup(context: Context) :
|
||||
internal open fun removeAllViewsWithSubviewClippingEnabled(): Unit {
|
||||
Assertions.assertCondition(_removeClippedSubviews)
|
||||
val children = checkNotNull(allChildren)
|
||||
for (i in 0 until allChildrenCount) {
|
||||
children[i]?.removeOnLayoutChangeListener(childrenLayoutChangeListener)
|
||||
}
|
||||
children.forEach { child -> child?.removeOnLayoutChangeListener(childrenLayoutChangeListener) }
|
||||
removeAllViewsInLayout()
|
||||
allChildrenCount = 0
|
||||
}
|
||||
@@ -714,23 +705,22 @@ public open class ReactViewGroup(context: Context) :
|
||||
protected open fun getBackgroundColor(): Int =
|
||||
BackgroundStyleApplicator.getBackgroundColor(this) ?: DEFAULT_BACKGROUND_COLOR
|
||||
|
||||
// TODO: convert to val
|
||||
public open fun setOverflow(overflow: String?): Unit {
|
||||
_overflow =
|
||||
if (overflow == null) {
|
||||
Overflow.VISIBLE
|
||||
} else {
|
||||
Overflow.fromString(overflow) ?: Overflow.VISIBLE
|
||||
override var overflow: String?
|
||||
get() =
|
||||
when (_overflow) {
|
||||
Overflow.HIDDEN -> "hidden"
|
||||
Overflow.SCROLL -> "scroll"
|
||||
Overflow.VISIBLE -> "visible"
|
||||
}
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun getOverflow(): String? =
|
||||
when (_overflow) {
|
||||
Overflow.HIDDEN -> "hidden"
|
||||
Overflow.SCROLL -> "scroll"
|
||||
Overflow.VISIBLE -> "visible"
|
||||
}
|
||||
set(value) {
|
||||
_overflow =
|
||||
if (value == null) {
|
||||
Overflow.VISIBLE
|
||||
} else {
|
||||
Overflow.fromString(value) ?: Overflow.VISIBLE
|
||||
}
|
||||
invalidate()
|
||||
}
|
||||
|
||||
override fun setOverflowInset(left: Int, top: Int, right: Int, bottom: Int) {
|
||||
if (needsIsolatedLayer() &&
|
||||
@@ -768,8 +758,8 @@ public open class ReactViewGroup(context: Context) :
|
||||
canvas.saveLayer(
|
||||
overflowInset.left.toFloat(),
|
||||
overflowInset.top.toFloat(),
|
||||
(width + -overflowInset.right).toFloat(),
|
||||
(height + -overflowInset.bottom).toFloat(),
|
||||
(width - overflowInset.right).toFloat(),
|
||||
(height - overflowInset.bottom).toFloat(),
|
||||
null)
|
||||
super.draw(canvas)
|
||||
canvas.restore()
|
||||
@@ -800,8 +790,8 @@ public open class ReactViewGroup(context: Context) :
|
||||
canvas.saveLayer(
|
||||
overflowInset.left.toFloat(),
|
||||
overflowInset.top.toFloat(),
|
||||
(width + -overflowInset.right).toFloat(),
|
||||
(height + -overflowInset.bottom).toFloat(),
|
||||
(width - overflowInset.right).toFloat(),
|
||||
(height - overflowInset.bottom).toFloat(),
|
||||
p)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user