Skip to content
Closed
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
4 changes: 2 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6125,12 +6125,12 @@ public final class com/facebook/react/uimanager/style/BoxShadow {
public final fun getOffsetY ()F
public final fun getSpreadDistance ()Ljava/lang/Float;
public fun hashCode ()I
public static final fun parse (Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/uimanager/style/BoxShadow;
public static final fun parse (Lcom/facebook/react/bridge/ReadableMap;Landroid/content/Context;)Lcom/facebook/react/uimanager/style/BoxShadow;
public fun toString ()Ljava/lang/String;
}

public final class com/facebook/react/uimanager/style/BoxShadow$Companion {
public final fun parse (Lcom/facebook/react/bridge/ReadableMap;)Lcom/facebook/react/uimanager/style/BoxShadow;
public final fun parse (Lcom/facebook/react/bridge/ReadableMap;Landroid/content/Context;)Lcom/facebook/react/uimanager/style/BoxShadow;
}

public final class com/facebook/react/uimanager/style/ComputedBorderRadius {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public object BackgroundStyleApplicator {

val shadowStyles = mutableListOf<BoxShadow>()
for (i in 0..<shadows.size()) {
shadowStyles.add(checkNotNull(BoxShadow.parse(shadows.getMap(i))))
shadowStyles.add(checkNotNull(BoxShadow.parse(shadows.getMap(i), view.context)))
}
BackgroundStyleApplicator.setBoxShadow(view, shadowStyles)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

package com.facebook.react.uimanager.style

import android.content.Context
import androidx.annotation.ColorInt
import com.facebook.react.bridge.ColorPropConverter
import com.facebook.react.bridge.JSApplicationCausedNativeException
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.ReadableType

/** Represents all logical properties and shorthands for border radius. */
public data class BoxShadow(
Expand All @@ -21,15 +25,22 @@ public data class BoxShadow(
) {
public companion object {
@JvmStatic
public fun parse(boxShadow: ReadableMap): BoxShadow? {
public fun parse(boxShadow: ReadableMap, context: Context): BoxShadow? {
if (!(boxShadow.hasKey("offsetX") && boxShadow.hasKey("offsetY"))) {
return null
}

val offsetX = boxShadow.getDouble("offsetX").toFloat()
val offsetY = boxShadow.getDouble("offsetY").toFloat()

val color = if (boxShadow.hasKey("color")) boxShadow.getInt("color") else null
val color =
if (boxShadow.hasKey("color")) {
when (val type = boxShadow.getType("color")) {
ReadableType.Number -> boxShadow.getInt("color")
ReadableType.Map -> ColorPropConverter.getColor(boxShadow.getMap("color"), context)
else -> throw JSApplicationCausedNativeException("Unsupported color type ${type}")
}
} else null
val blurRadius =
if (boxShadow.hasKey("blurRadius")) boxShadow.getDouble("blurRadius").toFloat() else null
val spreadDistance =
Expand Down