Implement prop diffing for nativeForegroundAndroid prop (#48834)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48834

Implement prop diffing for nativeForegroundAndroid prop

changelog: [internal] internal

Reviewed By: rshest

Differential Revision: D60001410

fbshipit-source-id: c6b5b71ddb66136f9cf61e2cca5aeb6e1274841e
This commit is contained in:
David Vacca
2025-01-22 12:07:06 -08:00
committed by Facebook GitHub Bot
parent 48fad21759
commit 2c50e7043b
2 changed files with 44 additions and 2 deletions
@@ -114,7 +114,7 @@ public object ReactScrollViewHelper {
return
}
val contentView = scrollView.getChildAt(0) ?: return
for (scrollListener in scrollListeners) {
for (scrollListener in scrollListeners.toList()) {
scrollListener.get()?.onScroll(scrollView, scrollEventType, xVelocity, yVelocity)
}
val reactContext = scrollView.context as ReactContext
@@ -336,6 +336,38 @@ static void updateBorderColorsProps(
oldBorderColor.blockStart);
}
inline static void updateNativeDrawableProp(
folly::dynamic& result,
const std::string& propName,
const std::optional<NativeDrawable>& nativeDrawable) {
folly::dynamic nativeDrawableResult;
if (nativeDrawable.has_value()) {
nativeDrawableResult = folly::dynamic::object();
const auto& nativeDrawableValue = nativeDrawable.value();
nativeDrawableResult["attribute"] = nativeDrawableValue.themeAttr;
switch (nativeDrawableValue.kind) {
case NativeDrawable::Kind::Ripple:
nativeDrawableResult["type"] = "RippleAndroid";
break;
case NativeDrawable::Kind::ThemeAttr:
nativeDrawableResult["type"] = "ThemeAttrAndroid";
break;
}
if (nativeDrawableValue.ripple.rippleRadius.has_value()) {
nativeDrawableResult["rippleRadius"] =
nativeDrawableValue.ripple.rippleRadius.value();
}
if (nativeDrawableValue.ripple.color.has_value()) {
nativeDrawableResult["color"] = nativeDrawableValue.ripple.color.value();
}
nativeDrawableResult["borderless"] = nativeDrawableValue.ripple.borderless;
} else {
nativeDrawableResult = folly::dynamic(nullptr);
}
result[propName] = nativeDrawableResult;
}
inline static void updateTransformOperationValue(
const std::string& operationName,
const ValueUnit& valueUnit,
@@ -571,8 +603,18 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
}
}
// TODO T212662692: pass events as std::bitset<64> to java
if (nativeBackground != oldProps->nativeBackground) {
updateNativeDrawableProp(
result, "nativeBackgroundAndroid", nativeBackground);
}
if (nativeForeground != oldProps->nativeForeground) {
updateNativeDrawableProp(
result, "nativeForegroundAndroid", nativeForeground);
}
// Events
// TODO T212662692: pass events as std::bitset<64> to java
if (events != oldProps->events) {
updateEventProp(
result,