Skip to content

Commit 3088740

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Add LayoutAnimation support to all ViewKind nodes
Summary: changelog: [internal] LayoutAnimations only animates changes inside View and Paragraph nodes. This diff extends it to any node that's ViewKind. Reviewed By: JoshuaGross Differential Revision: D30603138 fbshipit-source-id: 63ca1e5df420149c4ba66151e97fea419fdfe631
1 parent a950634 commit 3088740

File tree

9 files changed

+23
-54
lines changed

9 files changed

+23
-54
lines changed

ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77

88
#pragma once
99

10-
#include "ParagraphShadowNode.h"
11-
12-
#include <react/config/ReactNativeConfig.h>
1310
#include <react/debug/react_native_assert.h>
14-
#include <react/renderer/components/view/ViewPropsInterpolation.h>
11+
#include <react/renderer/components/text/ParagraphShadowNode.h>
1512
#include <react/renderer/core/ConcreteComponentDescriptor.h>
1613
#include <react/renderer/textlayoutmanager/TextLayoutManager.h>
1714
#include <react/utils/ContextContainer.h>
@@ -32,19 +29,6 @@ class ParagraphComponentDescriptor final
3229
textLayoutManager_ = std::make_shared<TextLayoutManager>(contextContainer_);
3330
}
3431

35-
virtual SharedProps interpolateProps(
36-
const PropsParserContext &context,
37-
float animationProgress,
38-
const SharedProps &props,
39-
const SharedProps &newProps) const override {
40-
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
41-
42-
interpolateViewProps(
43-
animationProgress, props, newProps, interpolatedPropsShared);
44-
45-
return interpolatedPropsShared;
46-
};
47-
4832
protected:
4933
void adopt(ShadowNode::Unshared const &shadowNode) const override {
5034
ConcreteComponentDescriptor::adopt(shadowNode);

ReactCommon/react/renderer/components/view/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LOCAL_MODULE := rrc_view
1111

1212
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
1313

14-
LOCAL_C_INCLUDES := $(LOCAL_PATH)/
14+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../
1515
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../
1616

1717
LOCAL_CFLAGS := \

ReactCommon/react/renderer/components/view/ViewComponentDescriptor.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include <react/renderer/components/view/ViewShadowNode.h>
1111
#include <react/renderer/core/ConcreteComponentDescriptor.h>
12-
#include "ViewProps.h"
13-
#include "ViewPropsInterpolation.h"
1412

1513
namespace facebook {
1614
namespace react {
@@ -20,27 +18,6 @@ class ViewComponentDescriptor
2018
public:
2119
ViewComponentDescriptor(ComponentDescriptorParameters const &parameters)
2220
: ConcreteComponentDescriptor<ViewShadowNode>(parameters) {}
23-
24-
virtual SharedProps interpolateProps(
25-
const PropsParserContext &context,
26-
float animationProgress,
27-
const SharedProps &props,
28-
const SharedProps &newProps) const override {
29-
#ifdef ANDROID
30-
// On Android only, the merged props should have the same RawProps as the
31-
// final props struct
32-
SharedProps interpolatedPropsShared =
33-
(newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps)
34-
: cloneProps(context, newProps, {}));
35-
#else
36-
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
37-
#endif
38-
39-
interpolateViewProps(
40-
animationProgress, props, newProps, interpolatedPropsShared);
41-
42-
return interpolatedPropsShared;
43-
};
4421
};
4522

4623
} // namespace react

ReactCommon/react/renderer/components/view/ViewPropsInterpolation.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
#pragma once
99

10-
#include "ViewProps.h"
11-
12-
#include <react/debug/react_native_assert.h>
10+
#include <react/renderer/components/view/ViewProps.h>
11+
#include <react/renderer/graphics/Transform.h>
1312

1413
namespace facebook {
1514
namespace react {

ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <memory>
1212

1313
#include <react/debug/react_native_assert.h>
14+
#include <react/renderer/components/view/ViewPropsInterpolation.h>
1415
#include <react/renderer/core/ComponentDescriptor.h>
1516
#include <react/renderer/core/EventDispatcher.h>
1617
#include <react/renderer/core/Props.h>
@@ -113,21 +114,28 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
113114
return ShadowNodeT::Props(context, rawProps, props);
114115
};
115116

116-
virtual SharedProps interpolateProps(
117+
SharedProps interpolateProps(
117118
const PropsParserContext &context,
118119
float animationProgress,
119120
const SharedProps &props,
120121
const SharedProps &newProps) const override {
121-
// By default, this does nothing.
122122
#ifdef ANDROID
123123
// On Android only, the merged props should have the same RawProps as the
124124
// final props struct
125-
if (newProps != nullptr) {
126-
return cloneProps(context, newProps, newProps->rawProps);
127-
}
125+
SharedProps interpolatedPropsShared =
126+
(newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps)
127+
: cloneProps(context, newProps, {}));
128+
#else
129+
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
128130
#endif
129131

130-
return cloneProps(context, newProps, {});
132+
if (ConcreteShadowNode::BaseTraits().check(
133+
ShadowNodeTraits::Trait::ViewKind)) {
134+
interpolateViewProps(
135+
animationProgress, props, newProps, interpolatedPropsShared);
136+
}
137+
138+
return interpolatedPropsShared;
131139
};
132140

133141
virtual State::Shared createInitialState(

ReactCommon/react/renderer/graphics/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LOCAL_SHARED_LIBRARIES := libfolly_json libreact_debug libfb libfbjni libfolly_j
1515

1616
LOCAL_STATIC_LIBRARIES :=
1717

18-
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
18+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
1919

2020
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
2121

ReactCommon/react/renderer/graphics/Transform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ TransformOperation Transform::DefaultTransformOperation(
183183
}
184184

185185
Transform Transform::Interpolate(
186-
float animationProgress,
186+
Float animationProgress,
187187
Transform const &lhs,
188188
Transform const &rhs) {
189189
// Iterate through operations and reconstruct an interpolated resulting

ReactCommon/react/renderer/graphics/Transform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct Transform {
117117
* @return
118118
*/
119119
static Transform Interpolate(
120-
float animationProgress,
120+
Float animationProgress,
121121
Transform const &lhs,
122122
Transform const &rhs);
123123

ReactCommon/react/renderer/mounting/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
2121

2222
LOCAL_STATIC_LIBRARIES :=
2323

24-
LOCAL_SHARED_LIBRARIES := libjsi libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug libreact_render_telemetry
24+
LOCAL_SHARED_LIBRARIES := libjsi libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug libreact_render_graphics libreact_render_telemetry
2525

2626
include $(BUILD_SHARED_LIBRARY)
2727

@@ -36,4 +36,5 @@ $(call import-module,react/renderer/debug)
3636
$(call import-module,react/utils)
3737
$(call import-module,react/debug)
3838
$(call import-module,yogajni)
39+
$(call import-module,react/renderer/graphics)
3940
$(call import-module,react/renderer/telemetry)

0 commit comments

Comments
 (0)