-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Remove view flattening error for Text
component
#3338
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
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
353f41a
Add check for text on android
m-bert c2c0f58
Change variable name
m-bert 9426805
Check for text on iOS
m-bert e8cdbe5
Merge branch 'main' into @mbert/remove-flattening-warning-with-text
m-bert 72e78cf
Update android/src/main/jni/cpp-adapter.cpp
m-bert 393b377
Simplify iOS
m-bert b6b6765
Remove unused imports
m-bert 411ad67
Merge branch 'main' into @mbert/remove-flattening-warning-with-text
m-bert 39cf55b
Bring back Paragraph check on iOS
m-bert a16dfd4
Merge branch 'main' into @mbert/remove-flattening-warning-with-text
m-bert 6e11e51
Merge branch 'main' into @mbert/remove-flattening-warning-with-text
m-bert 4a210cc
Change function name
m-bert 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
#include <jni.h> | ||
#include <jsi/jsi.h> | ||
|
||
#include <react/renderer/components/text/ParagraphShadowNode.h> | ||
#include <react/renderer/components/text/TextShadowNode.h> | ||
#include <react/renderer/uimanager/primitives.h> | ||
|
||
using namespace facebook; | ||
using namespace react; | ||
|
||
void decorateRuntime(jsi::Runtime &runtime) { | ||
auto isFormsStackingContext = jsi::Function::createFromHostFunction( | ||
auto isViewFlatteningDisabled = jsi::Function::createFromHostFunction( | ||
runtime, | ||
jsi::PropNameID::forAscii(runtime, "isFormsStackingContext"), | ||
jsi::PropNameID::forAscii(runtime, "isViewFlatteningDisabled"), | ||
1, | ||
[](jsi::Runtime &runtime, | ||
const jsi::Value &thisValue, | ||
|
@@ -20,21 +22,28 @@ void decorateRuntime(jsi::Runtime &runtime) { | |
} | ||
|
||
auto shadowNode = shadowNodeFromValue(runtime, arguments[0]); | ||
bool isFormsStackingContext = shadowNode->getTraits().check(ShadowNodeTraits::FormsStackingContext); | ||
bool isViewFlatteningDisabled = shadowNode->getTraits().check( | ||
ShadowNodeTraits::FormsStackingContext); | ||
|
||
return jsi::Value(isFormsStackingContext); | ||
// This is done using component names instead of type checking because | ||
// of duplicate symbols for RN types, which prevent RTTI from working. | ||
const char *componentName = shadowNode->getComponentName(); | ||
bool isTextComponent = strcmp(componentName, "Paragraph") == 0 || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, does this happen in both cases or only for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Answered here |
||
strcmp(componentName, "Text") == 0; | ||
|
||
return jsi::Value(isViewFlatteningDisabled || isTextComponent); | ||
}); | ||
runtime.global().setProperty( | ||
runtime, "isFormsStackingContext", std::move(isFormsStackingContext)); | ||
runtime, "isViewFlatteningDisabled", std::move(isViewFlatteningDisabled)); | ||
} | ||
|
||
extern "C" JNIEXPORT void JNICALL | ||
Java_com_swmansion_gesturehandler_react_RNGestureHandlerModule_decorateRuntime( | ||
JNIEnv *env, | ||
jobject clazz, | ||
jlong jsiPtr) { | ||
jsi::Runtime *runtime = reinterpret_cast<jsi::Runtime *>(jsiPtr); | ||
if (runtime) { | ||
decorateRuntime(*runtime); | ||
} | ||
JNIEnv *env, | ||
jobject clazz, | ||
jlong jsiPtr) { | ||
jsi::Runtime *runtime = reinterpret_cast<jsi::Runtime *>(jsiPtr); | ||
if (runtime) { | ||
decorateRuntime(*runtime); | ||
} | ||
} |
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
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.