Skip to content
Open
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 @@ -30,6 +30,7 @@ public object ColorPropConverter {
private const val ATTR = "attr"
private const val ATTR_SEGMENT = "attr/"

@Throws(JSApplicationCausedNativeException::class)
private fun getColorInteger(value: Any?, context: Context): Int? {
if (value == null) {
return null
Expand Down Expand Up @@ -64,6 +65,12 @@ public object ColorPropConverter {
}
}

val attemptedPaths = (0 until resourcePaths.size()).map { resourcePaths.getString(it) }
FLog.w(
ReactConstants.TAG,
"ColorValue: Failed to resolve resource paths: ${attemptedPaths.joinToString(", ")}",
)

throw JSApplicationCausedNativeException(
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource."
)
Expand All @@ -73,6 +80,7 @@ public object ColorPropConverter {
}

@JvmStatic
@Throws(JSApplicationCausedNativeException::class)
public fun getColorInstance(value: Any?, context: Context): Color? {
if (value == null) {
return null
Expand Down Expand Up @@ -113,6 +121,12 @@ public object ColorPropConverter {
}
}

val attemptedPaths = (0 until resourcePaths.size()).map { resourcePaths.getString(it) }
FLog.w(
ReactConstants.TAG,
"ColorValue: Failed to resolve resource paths: ${attemptedPaths.joinToString(", ")}",
)

throw JSApplicationCausedNativeException(
"ColorValue: None of the paths in the `$JSON_KEY` array resolved to a color resource."
)
Expand All @@ -122,6 +136,7 @@ public object ColorPropConverter {
}

@JvmStatic
@Throws(JSApplicationCausedNativeException::class)
public fun getColor(value: Any?, context: Context): Int? {
try {
if (supportWideGamut()) {
Expand Down Expand Up @@ -188,6 +203,7 @@ public object ColorPropConverter {
return ResourcesCompat.getColor(context.resources, resourceId, context.theme)
}

@Throws(Resources.NotFoundException::class)
private fun resolveThemeAttribute(context: Context, resourcePath: String): Int {
val path = resourcePath.replace(ATTR_SEGMENT, "")
val pathTokens = path.split(PACKAGE_DELIMITER)
Expand Down
Loading