From 95afdd8bb3acad670f0b5e947dae98e0ace0f02c Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 9 Oct 2018 16:30:07 -0700 Subject: [PATCH] Introducing "collapsable" prop as part of ViewProps Summary: This diff introduces the collapsable props in the viewProps. This prop is used in product code to prevent specific Views to be removed from the view hierarchy Reviewed By: shergin Differential Revision: D10254679 fbshipit-source-id: 637665b8998a86e29e839eb6d405a0fac354c8d3 --- .../com/facebook/react/uimanager/TouchTargetHelper.java | 4 ++-- ReactCommon/fabric/components/view/ViewProps.cpp | 7 ++++++- ReactCommon/fabric/components/view/ViewProps.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java index 3298ca953..cee8c4ad7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java @@ -177,7 +177,7 @@ public class TouchTargetHelper { if (child instanceof ReactHitSlopView && ((ReactHitSlopView) child).getHitSlopRect() != null) { Rect hitSlopRect = ((ReactHitSlopView) child).getHitSlopRect(); if ((localX >= -hitSlopRect.left && localX < (child.getRight() - child.getLeft()) + hitSlopRect.right) - && (localY >= -hitSlopRect.top && localY < (child.getBottom() - child.getTop()) + hitSlopRect.bottom)) { + && (localY >= -hitSlopRect.top && localY < (child.getBottom() - child.getTop()) + hitSlopRect.bottom)) { outLocalPoint.set(localX, localY); return true; } @@ -185,7 +185,7 @@ public class TouchTargetHelper { return false; } else { if ((localX >= 0 && localX < (child.getRight() - child.getLeft())) - && (localY >= 0 && localY < (child.getBottom() - child.getTop()))) { + && (localY >= 0 && localY < (child.getBottom() - child.getTop()))) { outLocalPoint.set(localX, localY); return true; } diff --git a/ReactCommon/fabric/components/view/ViewProps.cpp b/ReactCommon/fabric/components/view/ViewProps.cpp index df4dd58a2..db6b334a2 100644 --- a/ReactCommon/fabric/components/view/ViewProps.cpp +++ b/ReactCommon/fabric/components/view/ViewProps.cpp @@ -67,7 +67,12 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps) pointerEvents( convertRawProp(rawProps, "pointerEvents", sourceProps.pointerEvents)), hitSlop(convertRawProp(rawProps, "hitSlop", sourceProps.hitSlop)), - onLayout(convertRawProp(rawProps, "onLayout", sourceProps.onLayout)){}; + onLayout(convertRawProp(rawProps, "onLayout", sourceProps.onLayout)), + collapsable(convertRawProp( + rawProps, + "collapsable", + sourceProps.collapsable, + true)){}; #pragma mark - Convenience Methods diff --git a/ReactCommon/fabric/components/view/ViewProps.h b/ReactCommon/fabric/components/view/ViewProps.h index cfb28bc98..69d355e8e 100644 --- a/ReactCommon/fabric/components/view/ViewProps.h +++ b/ReactCommon/fabric/components/view/ViewProps.h @@ -58,6 +58,8 @@ class ViewProps : public Props, const EdgeInsets hitSlop{}; const bool onLayout{}; + const bool collapsable{true}; + #pragma mark - Convenience Methods BorderMetrics resolveBorderMetrics(bool isRTL) const;