mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Pass isRTL flag from FabricUIManager Fabric core
Summary: Changelog: [Internal] Send `isRTL` flag and `doLeftAndRightSwapInRTL` flags from Java to Fabric Core. Reviewed By: JoshuaGross, mdvacca Differential Revision: D20776005 fbshipit-source-id: 946c239d9a11ebea958b0a6d04f2316b7cd77311
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c5a54ec1b1
commit
e653cb06f8
@@ -51,7 +51,9 @@ public class Binding {
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight);
|
||||
float maxHeight,
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
public native void renderTemplateToSurface(int surfaceId, String uiTemplate);
|
||||
|
||||
@@ -60,7 +62,13 @@ public class Binding {
|
||||
public native void setPixelDensity(float pointScaleFactor);
|
||||
|
||||
public native void setConstraints(
|
||||
int surfaceId, float minWidth, float maxWidth, float minHeight, float maxHeight);
|
||||
int surfaceId,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight,
|
||||
boolean isRTL,
|
||||
boolean doLeftAndRightSwapInRTL);
|
||||
|
||||
public void register(
|
||||
@NonNull JavaScriptContextHolder jsContext,
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.facebook.react.fabric.mounting.mountitems.UpdatePaddingMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.UpdatePropsMountItem;
|
||||
import com.facebook.react.fabric.mounting.mountitems.UpdateStateMountItem;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
import com.facebook.react.modules.i18nmanager.I18nUtil;
|
||||
import com.facebook.react.uimanager.ReactRoot;
|
||||
import com.facebook.react.uimanager.ReactRootViewTagGenerator;
|
||||
import com.facebook.react.uimanager.StateWrapper;
|
||||
@@ -217,7 +218,9 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
getMinSize(widthMeasureSpec),
|
||||
getMaxSize(widthMeasureSpec),
|
||||
getMinSize(heightMeasureSpec),
|
||||
getMaxSize(heightMeasureSpec));
|
||||
getMaxSize(heightMeasureSpec),
|
||||
I18nUtil.getInstance().isRTL(rootView.getContext()),
|
||||
I18nUtil.getInstance().doLeftAndRightSwapInRTL(rootView.getContext()));
|
||||
return rootTag;
|
||||
}
|
||||
|
||||
@@ -813,13 +816,14 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
if (ENABLE_FABRIC_LOGS) {
|
||||
FLog.d(TAG, "Updating Root Layout Specs");
|
||||
}
|
||||
|
||||
mBinding.setConstraints(
|
||||
rootTag,
|
||||
getMinSize(widthMeasureSpec),
|
||||
getMaxSize(widthMeasureSpec),
|
||||
getMinSize(heightMeasureSpec),
|
||||
getMaxSize(heightMeasureSpec));
|
||||
getMaxSize(heightMeasureSpec),
|
||||
I18nUtil.getInstance().isRTL(mReactContextForRootTag.get(rootTag)),
|
||||
I18nUtil.getInstance().doLeftAndRightSwapInRTL(mReactContextForRootTag.get(rootTag)));
|
||||
}
|
||||
|
||||
public void receiveEvent(int reactTag, String eventName, @Nullable WritableMap params) {
|
||||
|
||||
@@ -101,7 +101,9 @@ void Binding::startSurfaceWithConstraints(
|
||||
jfloat minWidth,
|
||||
jfloat maxWidth,
|
||||
jfloat minHeight,
|
||||
jfloat maxHeight) {
|
||||
jfloat maxHeight,
|
||||
jboolean isRTL,
|
||||
jboolean doLeftAndRightSwapInRTL) {
|
||||
SystraceSection s("FabricUIManagerBinding::startSurfaceWithConstraints");
|
||||
|
||||
LOG(WARNING) << "Binding::startSurfaceWithConstraints() was called (address: "
|
||||
@@ -120,9 +122,12 @@ void Binding::startSurfaceWithConstraints(
|
||||
|
||||
LayoutContext context;
|
||||
context.pointScaleFactor = {pointScaleFactor_};
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL;
|
||||
LayoutConstraints constraints = {};
|
||||
constraints.minimumSize = minimumSize;
|
||||
constraints.maximumSize = maximumSize;
|
||||
constraints.layoutDirection =
|
||||
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
|
||||
scheduler->startSurface(
|
||||
surfaceId,
|
||||
@@ -167,7 +172,9 @@ void Binding::setConstraints(
|
||||
jfloat minWidth,
|
||||
jfloat maxWidth,
|
||||
jfloat minHeight,
|
||||
jfloat maxHeight) {
|
||||
jfloat maxHeight,
|
||||
jboolean isRTL,
|
||||
jboolean doLeftAndRightSwapInRTL) {
|
||||
SystraceSection s("FabricUIManagerBinding::setConstraints");
|
||||
|
||||
std::shared_ptr<Scheduler> scheduler = getScheduler();
|
||||
@@ -183,9 +190,12 @@ void Binding::setConstraints(
|
||||
|
||||
LayoutContext context;
|
||||
context.pointScaleFactor = {pointScaleFactor_};
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL;
|
||||
LayoutConstraints constraints = {};
|
||||
constraints.minimumSize = minimumSize;
|
||||
constraints.maximumSize = maximumSize;
|
||||
constraints.layoutDirection =
|
||||
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
|
||||
scheduler->constraintSurfaceLayout(surfaceId, constraints, context);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,9 @@ class Binding : public jni::HybridClass<Binding>, public SchedulerDelegate {
|
||||
jfloat minWidth,
|
||||
jfloat maxWidth,
|
||||
jfloat minHeight,
|
||||
jfloat maxHeight);
|
||||
jfloat maxHeight,
|
||||
jboolean isRTL,
|
||||
jboolean doLeftAndRightSwapInRTL);
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
|
||||
|
||||
@@ -62,7 +64,9 @@ class Binding : public jni::HybridClass<Binding>, public SchedulerDelegate {
|
||||
jfloat minWidth,
|
||||
jfloat maxWidth,
|
||||
jfloat minHeight,
|
||||
jfloat maxHeight);
|
||||
jfloat maxHeight,
|
||||
jboolean isRTL,
|
||||
jboolean doLeftAndRightSwapInRTL);
|
||||
|
||||
void renderTemplateToSurface(jint surfaceId, jstring uiTemplate);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user