Skip to content

Commit

Permalink
Implement prop diffing for nativeForegroundAndroid prop (#48834)
Browse files Browse the repository at this point in the history
Summary:

Implement prop diffing for nativeForegroundAndroid prop

changelog: [internal] internal

Reviewed By: rshest

Differential Revision: D60001410
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 22, 2025
1 parent 3563f71 commit dd5e40b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -571,6 +603,16 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
}
}

if (nativeBackground != oldProps->nativeBackground) {
updateNativeDrawableProp(
result, "nativeBackgroundAndroid", nativeBackground);
}

if (nativeForeground != oldProps->nativeForeground) {
updateNativeDrawableProp(
result, "nativeForegroundAndroid", nativeForeground);
}

// Events
if (events != oldProps->events) {
updateEventProp(
Expand Down

0 comments on commit dd5e40b

Please sign in to comment.