Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal class ShadowNodeWrapper(
}

private fun resolveShadowNode(reflectionUtils: ReflectionUtils, uiManagerModule: UIManagerModule, tag: Int): ReactShadowNode<out ReactShadowNode<*>>? {
val uiManagerImplementation = reflectionUtils.getDeclaredField(uiManagerModule, UI_IMPLEMENTATION_FIELD_NAME) as UIImplementation?
val uiManagerImplementation = reflectionUtils.getDeclaredField(uiManagerModule, UI_IMPLEMENTATION_FIELD_NAME) as? UIImplementation
return uiManagerImplementation?.resolveShadowNode(tag)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal class LegacyTextViewUtils(
}
val resolvedColor =
shadowNodeWrapper
.getDeclaredShadowNodeField(COLOR_FIELD_NAME) as Int?
.getDeclaredShadowNodeField(COLOR_FIELD_NAME) as? Int
if (resolvedColor != null) {
return formatAsRgba(resolvedColor)
}
Expand Down Expand Up @@ -115,4 +115,3 @@ internal class LegacyTextViewUtils(
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,21 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
}

override fun getReactBackgroundFromDrawable(drawable: Drawable?): Drawable? {
if (drawable is ReactViewBackgroundDrawable) {
return drawable
}

if (drawable is InsetDrawable) {
return getReactBackgroundFromDrawable(drawable.drawable)
return when (drawable) {
is ReactViewBackgroundDrawable -> drawable
is InsetDrawable -> getReactBackgroundFromDrawable(drawable.drawable)
is LayerDrawable -> getDrawableFromLayerDrawable(drawable)
else -> null
}
}

if (drawable is LayerDrawable) {
for (layerNumber in 0 until drawable.numberOfLayers) {
val layer = drawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
private fun getDrawableFromLayerDrawable(layerDrawable: LayerDrawable): Drawable? {
for (layerNumber in 0 until layerDrawable.numberOfLayers) {
val layer = layerDrawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
}

return null
}

Expand All @@ -79,7 +77,7 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
return reflectionUtils.getDeclaredField(
backgroundDrawable,
COLOR_FIELD_NAME
) as Int?
) as? Int
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,22 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {

@OptIn(UnstableReactNativeAPI::class)
override fun getReactBackgroundFromDrawable(drawable: Drawable?): Drawable? {
if (drawable is CSSBackgroundDrawable) {
return drawable
}

if (drawable is InsetDrawable) {
return getReactBackgroundFromDrawable(drawable.drawable)
return when(drawable) {
is ReactViewBackgroundDrawable -> drawable
is InsetDrawable -> getReactBackgroundFromDrawable(drawable.drawable)
is LayerDrawable -> getDrawableFromLayerDrawable(drawable)
else -> null
}
}

if (drawable is LayerDrawable) {
for (layerNumber in 0 until drawable.numberOfLayers) {
val layer = drawable.getDrawable(layerNumber)
if (layer is CSSBackgroundDrawable) {
return layer
}
@OptIn(UnstableReactNativeAPI::class)
private fun getDrawableFromLayerDrawable(layerDrawable: LayerDrawable): Drawable? {
for (layerNumber in 0 until layerDrawable.numberOfLayers) {
val layer = layerDrawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
}

return null
}

Expand All @@ -76,7 +75,7 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {
return reflectionUtils.getDeclaredField(
backgroundDrawable,
COLOR_FIELD_NAME
) as Int?
) as? Int
}

@OptIn(UnstableReactNativeAPI::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,22 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {

@OptIn(UnstableReactNativeAPI::class)
override fun getReactBackgroundFromDrawable(drawable: Drawable?): Drawable? {
if (drawable is CSSBackgroundDrawable) {
return drawable
}

if (drawable is InsetDrawable) {
return getReactBackgroundFromDrawable(drawable.drawable)
return when(drawable) {
is ReactViewBackgroundDrawable -> drawable
is InsetDrawable -> getReactBackgroundFromDrawable(drawable.drawable)
is LayerDrawable -> getDrawableFromLayerDrawable(drawable)
else -> null
}
}

if (drawable is LayerDrawable) {
for (layerNumber in 0 until drawable.numberOfLayers) {
val layer = drawable.getDrawable(layerNumber)
if (layer is CSSBackgroundDrawable) {
return layer
}
@OptIn(UnstableReactNativeAPI::class)
private fun getDrawableFromLayerDrawable(layerDrawable: LayerDrawable): Drawable? {
for (layerNumber in 0 until layerDrawable.numberOfLayers) {
val layer = layerDrawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
}

return null
}

Expand All @@ -76,7 +75,7 @@ internal class ReactViewBackgroundDrawableUtils : DrawableUtils() {
return reflectionUtils.getDeclaredField(
backgroundDrawable,
COLOR_FIELD_NAME
) as Int?
) as? Int
}

@OptIn(UnstableReactNativeAPI::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,21 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
}

override fun getReactBackgroundFromDrawable(drawable: Drawable?): Drawable? {
if (drawable is ReactViewBackgroundDrawable) {
return drawable
}

if (drawable is InsetDrawable) {
return getReactBackgroundFromDrawable(drawable.drawable)
return when(drawable) {
is ReactViewBackgroundDrawable -> drawable
is InsetDrawable -> getReactBackgroundFromDrawable(drawable.drawable)
is LayerDrawable -> getDrawableFromLayerDrawable(drawable)
else -> null
}
}

if (drawable is LayerDrawable) {
for (layerNumber in 0 until drawable.numberOfLayers) {
val layer = drawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
private fun getDrawableFromLayerDrawable(layerDrawable: LayerDrawable): Drawable? {
for (layerNumber in 0 until layerDrawable.numberOfLayers) {
val layer = layerDrawable.getDrawable(layerNumber)
if (layer is ReactViewBackgroundDrawable) {
return layer
}
}

return null
}

Expand All @@ -73,12 +71,12 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
val borderRgb = reflectionUtils.getDeclaredField(
backgroundDrawable,
BORDER_RGB_FIELD_NAME
) as Spacing?
) as? Spacing

val borderAlpha = reflectionUtils.getDeclaredField(
backgroundDrawable,
BORDER_ALPHA_FIELD_NAME
) as Spacing?
) as? Spacing

val rgb = borderRgb?.get(Spacing.ALL) ?: DEFAULT_BORDER_RGB
val alpha = borderAlpha?.get(Spacing.ALL) ?: DEFAULT_BORDER_ALPHA
Expand All @@ -95,7 +93,7 @@ internal class ReactViewBackgroundDrawableUtils() : DrawableUtils() {
return reflectionUtils.getDeclaredField(
backgroundDrawable,
COLOR_FIELD_NAME
) as Int?
) as? Int
}

private companion object {
Expand Down