-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Custom Shadow Nodes #7380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Custom Shadow Nodes #7380
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6672494
iOS config
piaskowyk b242103
Android basic config
piaskowyk bb9c014
Setup Android
piaskowyk 0ebbe89
Reuse codegen output for Android
piaskowyk 9e6e542
Refactor codegen cmakelist
piaskowyk dbd5084
Update iOS implementation
piaskowyk 1cc2e9b
Setup common implementation
piaskowyk 4ce8efe
Cleanup
piaskowyk 0bc3cc5
Restore example
piaskowyk 840f564
Run format
piaskowyk 5362b4d
Cleanup comments
piaskowyk f06a051
update podspec
piaskowyk d7cdb73
Improvements after review
piaskowyk 394bb7c
.lock update
piaskowyk fa96af2
Format
piaskowyk 0b0f278
Tomek's review
piaskowyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/react-native-reanimated/Common/NativeView/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| cmake_minimum_required(VERSION 3.13) | ||
| set(CMAKE_VERBOSE_MAKEFILE on) | ||
|
|
||
| set(ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../android) | ||
| set(CODEGEN_JNI_DIR ${ANDROID_DIR}/build/generated/source/codegen/jni) | ||
| set(CODEGEN_COMPONENTS_DIR ${CODEGEN_JNI_DIR}/react/renderer/components/rnreanimated) | ||
| file( | ||
| GLOB CODEGEN_ORIGINAL_SRCS CONFIGURE_DEPENDS | ||
| ${CODEGEN_JNI_DIR}/*.cpp | ||
| ${CODEGEN_COMPONENTS_DIR}/*.cpp | ||
| ) | ||
|
|
||
| set(CODEGEN_OVERWRITTEN_JNI_DIR .) | ||
| set(CODEGEN_OVERWRITTEN_COMPONENTS_DIR ${CODEGEN_OVERWRITTEN_JNI_DIR}/react/renderer/components/rnreanimated) | ||
| file( | ||
| GLOB CODEGEN_OVERWRITTEN_SRCS CONFIGURE_DEPENDS | ||
| ${CODEGEN_OVERWRITTEN_JNI_DIR}/*.cpp | ||
| ${CODEGEN_OVERWRITTEN_COMPONENTS_DIR}/*.cpp | ||
| ) | ||
|
|
||
| add_library( | ||
| react_codegen_rnreanimated | ||
| OBJECT | ||
| ${CODEGEN_OVERWRITTEN_SRCS} | ||
| ${CODEGEN_ORIGINAL_SRCS} | ||
| ) | ||
|
|
||
| target_include_directories( | ||
| react_codegen_rnreanimated | ||
| PUBLIC | ||
| ${CODEGEN_OVERWRITTEN_JNI_DIR} | ||
| ${CODEGEN_OVERWRITTEN_COMPONENTS_DIR} | ||
| ${CODEGEN_JNI_DIR} | ||
| ${CODEGEN_COMPONENTS_DIR} | ||
| ) | ||
|
|
||
| target_link_libraries( | ||
| react_codegen_rnreanimated | ||
| fbjni | ||
| jsi | ||
| reactnative | ||
| ) | ||
|
|
||
| target_compile_options( | ||
| react_codegen_rnreanimated | ||
| PRIVATE | ||
| -DLOG_TAG=\"ReactNative\" | ||
| -fexceptions | ||
| -frtti | ||
| -std=c++20 | ||
| -Wall | ||
| ) |
15 changes: 15 additions & 0 deletions
15
...eanimated/Common/NativeView/react/renderer/components/rnreanimated/ComponentDescriptors.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #pragma once | ||
|
|
||
| #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h> | ||
| #include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
| #include <react/renderer/components/rnreanimated/ReanimatedShadowNode.h> | ||
|
|
||
| namespace facebook::react { | ||
|
|
||
| using ReanimatedViewComponentDescriptor = | ||
| ConcreteComponentDescriptor<ReanimatedShadowNode>; | ||
|
|
||
| void rnreanimated_registerComponentDescriptorsFromCodegen( | ||
| std::shared_ptr<const ComponentDescriptorProviderRegistry> registry); | ||
|
|
||
| } // namespace facebook::react | ||
11 changes: 11 additions & 0 deletions
11
...nimated/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedShadowNode.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #include <react/renderer/components/rnreanimated/ReanimatedShadowNode.h> | ||
|
|
||
| namespace facebook::react { | ||
|
|
||
| extern const char ReanimatedViewComponentName[] = "ReanimatedView"; | ||
|
|
||
| void ReanimatedShadowNode::layout(LayoutContext layoutContext) { | ||
| YogaLayoutableShadowNode::layout(layoutContext); | ||
| } | ||
|
|
||
| } // namespace facebook::react |
26 changes: 26 additions & 0 deletions
26
...eanimated/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedShadowNode.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #pragma once | ||
|
|
||
| #include <jsi/jsi.h> | ||
| #include <react/renderer/components/rnreanimated/EventEmitters.h> | ||
| #include <react/renderer/components/rnreanimated/Props.h> | ||
| #include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
| #include <react/renderer/core/LayoutContext.h> | ||
| #include <react/renderer/components/rnreanimated/ReanimatedViewState.h> | ||
|
|
||
| namespace facebook::react { | ||
|
|
||
| JSI_EXPORT extern const char ReanimatedViewComponentName[]; | ||
|
|
||
| using ReanimatedViewShadowNodeBase = ConcreteViewShadowNode< | ||
| ReanimatedViewComponentName, | ||
| ReanimatedViewProps, | ||
| ReanimatedViewEventEmitter, | ||
| ReanimatedViewState>; | ||
|
|
||
| class ReanimatedShadowNode final : public ReanimatedViewShadowNodeBase { | ||
| public: | ||
| using ConcreteViewShadowNode::ConcreteViewShadowNode; | ||
| void layout(LayoutContext layoutContext) override; | ||
| }; | ||
|
|
||
| } // namespace facebook::react |
23 changes: 23 additions & 0 deletions
23
...reanimated/Common/NativeView/react/renderer/components/rnreanimated/ReanimatedViewState.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #pragma once | ||
|
|
||
| #ifdef ANDROID | ||
| #include <folly/dynamic.h> | ||
| #endif | ||
|
|
||
| namespace facebook::react { | ||
|
|
||
| class ReanimatedViewState { | ||
| public: | ||
| ReanimatedViewState() = default; | ||
|
|
||
| #ifdef ANDROID | ||
| ReanimatedViewState( | ||
| ReanimatedViewState const &previousState, | ||
| folly::dynamic data) {}; | ||
| folly::dynamic getDynamic() const { | ||
| return {}; | ||
| }; | ||
| #endif | ||
| }; | ||
|
|
||
| } // namespace facebook::react |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/react-native-reanimated/apple/reanimated/apple/view/ReanimatedView.mm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module.exports = { | ||
| dependency: { | ||
| platforms: { | ||
| android: { | ||
| componentDescriptors: [ | ||
| "ReanimatedViewComponentDescriptor", | ||
| ], | ||
| cmakeListsPath: "../Common/NativeView/CMakeLists.txt", | ||
| }, | ||
| }, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.