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
This commit is contained in:
Родитель
a950634424
Коммит
30887403ec
|
@ -7,11 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ParagraphShadowNode.h"
|
||||
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/ViewPropsInterpolation.h>
|
||||
#include <react/renderer/components/text/ParagraphShadowNode.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/renderer/textlayoutmanager/TextLayoutManager.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
@ -32,19 +29,6 @@ class ParagraphComponentDescriptor final
|
|||
textLayoutManager_ = std::make_shared<TextLayoutManager>(contextContainer_);
|
||||
}
|
||||
|
||||
virtual SharedProps interpolateProps(
|
||||
const PropsParserContext &context,
|
||||
float animationProgress,
|
||||
const SharedProps &props,
|
||||
const SharedProps &newProps) const override {
|
||||
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
|
||||
|
||||
interpolateViewProps(
|
||||
animationProgress, props, newProps, interpolatedPropsShared);
|
||||
|
||||
return interpolatedPropsShared;
|
||||
};
|
||||
|
||||
protected:
|
||||
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
||||
ConcreteComponentDescriptor::adopt(shadowNode);
|
||||
|
|
|
@ -11,7 +11,7 @@ LOCAL_MODULE := rrc_view
|
|||
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include <react/renderer/components/view/ViewShadowNode.h>
|
||||
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
||||
#include "ViewProps.h"
|
||||
#include "ViewPropsInterpolation.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
@ -20,27 +18,6 @@ class ViewComponentDescriptor
|
|||
public:
|
||||
ViewComponentDescriptor(ComponentDescriptorParameters const ¶meters)
|
||||
: ConcreteComponentDescriptor<ViewShadowNode>(parameters) {}
|
||||
|
||||
virtual SharedProps interpolateProps(
|
||||
const PropsParserContext &context,
|
||||
float animationProgress,
|
||||
const SharedProps &props,
|
||||
const SharedProps &newProps) const override {
|
||||
#ifdef ANDROID
|
||||
// On Android only, the merged props should have the same RawProps as the
|
||||
// final props struct
|
||||
SharedProps interpolatedPropsShared =
|
||||
(newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps)
|
||||
: cloneProps(context, newProps, {}));
|
||||
#else
|
||||
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
|
||||
#endif
|
||||
|
||||
interpolateViewProps(
|
||||
animationProgress, props, newProps, interpolatedPropsShared);
|
||||
|
||||
return interpolatedPropsShared;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "ViewProps.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/ViewProps.h>
|
||||
#include <react/renderer/graphics/Transform.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/renderer/components/view/ViewPropsInterpolation.h>
|
||||
#include <react/renderer/core/ComponentDescriptor.h>
|
||||
#include <react/renderer/core/EventDispatcher.h>
|
||||
#include <react/renderer/core/Props.h>
|
||||
|
@ -113,21 +114,28 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
return ShadowNodeT::Props(context, rawProps, props);
|
||||
};
|
||||
|
||||
virtual SharedProps interpolateProps(
|
||||
SharedProps interpolateProps(
|
||||
const PropsParserContext &context,
|
||||
float animationProgress,
|
||||
const SharedProps &props,
|
||||
const SharedProps &newProps) const override {
|
||||
// By default, this does nothing.
|
||||
#ifdef ANDROID
|
||||
// On Android only, the merged props should have the same RawProps as the
|
||||
// final props struct
|
||||
if (newProps != nullptr) {
|
||||
return cloneProps(context, newProps, newProps->rawProps);
|
||||
}
|
||||
SharedProps interpolatedPropsShared =
|
||||
(newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps)
|
||||
: cloneProps(context, newProps, {}));
|
||||
#else
|
||||
SharedProps interpolatedPropsShared = cloneProps(context, newProps, {});
|
||||
#endif
|
||||
|
||||
return cloneProps(context, newProps, {});
|
||||
if (ConcreteShadowNode::BaseTraits().check(
|
||||
ShadowNodeTraits::Trait::ViewKind)) {
|
||||
interpolateViewProps(
|
||||
animationProgress, props, newProps, interpolatedPropsShared);
|
||||
}
|
||||
|
||||
return interpolatedPropsShared;
|
||||
};
|
||||
|
||||
virtual State::Shared createInitialState(
|
||||
|
|
|
@ -15,7 +15,7 @@ LOCAL_SHARED_LIBRARIES := libfolly_json libreact_debug libfb libfbjni libfolly_j
|
|||
|
||||
LOCAL_STATIC_LIBRARIES :=
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../ $(LOCAL_PATH)/platform/cxx/
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ TransformOperation Transform::DefaultTransformOperation(
|
|||
}
|
||||
|
||||
Transform Transform::Interpolate(
|
||||
float animationProgress,
|
||||
Float animationProgress,
|
||||
Transform const &lhs,
|
||||
Transform const &rhs) {
|
||||
// Iterate through operations and reconstruct an interpolated resulting
|
||||
|
|
|
@ -117,7 +117,7 @@ struct Transform {
|
|||
* @return
|
||||
*/
|
||||
static Transform Interpolate(
|
||||
float animationProgress,
|
||||
Float animationProgress,
|
||||
Transform const &lhs,
|
||||
Transform const &rhs);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
|
|||
|
||||
LOCAL_STATIC_LIBRARIES :=
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
@ -36,4 +36,5 @@ $(call import-module,react/renderer/debug)
|
|||
$(call import-module,react/utils)
|
||||
$(call import-module,react/debug)
|
||||
$(call import-module,yogajni)
|
||||
$(call import-module,react/renderer/graphics)
|
||||
$(call import-module,react/renderer/telemetry)
|
||||
|
|
Загрузка…
Ссылка в новой задаче