Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism

Summary:
Previously, ViewPropsMapBuffer conversions were hardcoded deep in Android infrastructrue. I've generalized this into a different mechanism to allow any Props struct to support MapBuffer props.

There are still some things that need to be cleaned up and this should be treated as experimental. One thing we likely want to do is remove the hardcoded IDs (fine for codegen'd code; less so for handwritten) and use compile-time-hashed IDs instead with human-readable string names.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D38708719

fbshipit-source-id: 64603dee7f21828be31346c555d99862dab304ea
This commit is contained in:
Ruslan Shestopalyuk
2022-10-03 04:11:02 -07:00
committed by Facebook GitHub Bot
parent 2319f75c8e
commit 110b191b14
18 changed files with 870 additions and 351 deletions
@@ -62,6 +62,8 @@ object ReactMapBufferPropSetter {
private const val VP_POINTER_OUT_CAPTURE = 42
private const val VP_POINTER_OVER = 43
private const val VP_POINTER_OVER_CAPTURE = 44
private const val VP_BORDER_CURVES = 45 // iOS only
private const val VP_FG_COLOR = 46 // iOS only?
// Yoga values
private const val YG_BORDER_WIDTH = 100
@@ -141,6 +143,9 @@ object ReactMapBufferPropSetter {
// TODO: color for some reason can be object in Java but not in C++
viewManager.backgroundColor(view, entry.intValue)
}
VP_FG_COLOR -> {
// Prop not used on Android?
}
VP_BORDER_COLOR -> {
viewManager.borderColor(view, entry.mapBufferValue)
}
@@ -148,7 +153,10 @@ object ReactMapBufferPropSetter {
viewManager.borderRadius(view, entry.mapBufferValue)
}
VP_BORDER_STYLE -> {
viewManager.borderStyle(view, entry.intValue)
val styleBuffer = entry.mapBufferValue
if (styleBuffer.contains(CORNER_ALL)) {
viewManager.borderStyle(view, (styleBuffer.getDouble(CORNER_ALL)).toInt())
}
}
VP_ELEVATION -> {
viewManager.setElevation(view, entry.doubleValue.toFloat())