Skip to content

Commit

Permalink
[skip ci] Implement prop diffing for basic props in <View> (facebook#…
Browse files Browse the repository at this point in the history
…48829)

Summary:

This diff implements the diffing for basic props of <View>


changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D59972040
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 22, 2025
1 parent 93bc2f3 commit 5ed8237
Showing 1 changed file with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,116 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
? &defaultProps
: static_cast<const HostPlatformViewProps*>(prevProps);

if (this == oldProps) {
return result;
}
if (focusable != oldProps->focusable) {
result["focusable"] = focusable;
}

if (hasTVPreferredFocus != oldProps->hasTVPreferredFocus) {
result["hasTVPreferredFocus"] = hasTVPreferredFocus;
}

if (needsOffscreenAlphaCompositing !=
oldProps->needsOffscreenAlphaCompositing) {
result["needsOffscreenAlphaCompositing"] = needsOffscreenAlphaCompositing;
}

if (renderToHardwareTextureAndroid !=
oldProps->renderToHardwareTextureAndroid) {
result["renderToHardwareTextureAndroid"] = renderToHardwareTextureAndroid;
}

if (opacity != oldProps->opacity) {
result["opacity"] = opacity;
}

if (backgroundColor != oldProps->backgroundColor) {
result["backgroundColor"] = *backgroundColor;
}

if (shadowColor != oldProps->shadowColor) {
result["shadowColor"] = *shadowColor;
}

if (shadowOpacity != oldProps->shadowOpacity) {
result["shadowOpacity"] = shadowOpacity;
}

if (shadowRadius != oldProps->shadowRadius) {
result["shadowRadius"] = shadowRadius;
}

if (shouldRasterize != oldProps->shouldRasterize) {
result["shouldRasterize"] = shouldRasterize;
}

if (collapsable != oldProps->collapsable) {
result["collapsable"] = collapsable;
}

if (removeClippedSubviews != oldProps->removeClippedSubviews) {
result["removeClippedSubviews"] = removeClippedSubviews;
}

if (onLayout != oldProps->onLayout) {
result["onLayout"] = onLayout;
}

if (zIndex != oldProps->zIndex) {
result["zIndex"] = zIndex.value();
}

if (pointerEvents != oldProps->pointerEvents) {
std::string value;
switch (pointerEvents) {
case PointerEventsMode::BoxOnly:
result["pointerEvents"] = "box-only";
break;
case PointerEventsMode::BoxNone:
result["pointerEvents"] = "box-none";
break;
case PointerEventsMode::None:
result["pointerEvents"] = "none";
break;
default:
result["pointerEvents"] = "auto";
break;
}

if (nativeId != oldProps->nativeId) {
result["nativeId"] = nativeId;
}

if (testId != oldProps->testId) {
result["testId"] = testId;
}

if (accessible != oldProps->accessible) {
result["accessible"] = accessible;
}

if (getClipsContentToBounds() != oldProps->getClipsContentToBounds()) {
result["overflow"] = getClipsContentToBounds() ? "hidden" : "visible";
result["scroll"] = result["overflow"];
}

if (backfaceVisibility != oldProps->backfaceVisibility) {
switch (backfaceVisibility) {
case BackfaceVisibility::Auto:
result["backfaceVisibility"] = "auto";
break;
case BackfaceVisibility::Visible:
result["backfaceVisibility"] = "visible";
break;
case BackfaceVisibility::Hidden:
result["backfaceVisibility"] = "hidden";
break;
}
}
}

return result;
}

Expand Down

0 comments on commit 5ed8237

Please sign in to comment.