mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Expose LayoutDirection to Fabric android
Summary: This diff exposes LayoutDirection as part of UpdateLayoutMountItem Reviewed By: JoshuaGross Differential Revision: D16060521 fbshipit-source-id: 163bf2a0bdca62dcecb03a8aaa2f4bf595b18c8f
This commit is contained in:
committed by
Facebook Github Bot
parent
3c2395212c
commit
d07ab35bfb
@@ -265,8 +265,9 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private MountItem updateLayoutMountItem(int reactTag, int x, int y, int width, int height) {
|
||||
return new UpdateLayoutMountItem(reactTag, x, y, width, height);
|
||||
private MountItem updateLayoutMountItem(
|
||||
int reactTag, int x, int y, int width, int height, int layoutDirection) {
|
||||
return new UpdateLayoutMountItem(reactTag, x, y, width, height, layoutDirection);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/components/scrollview/ScrollViewProps.h>
|
||||
#include <react/core/conversions.h>
|
||||
#include <react/core/EventBeat.h>
|
||||
#include <react/core/EventEmitter.h>
|
||||
#include <react/debug/SystraceSection.h>
|
||||
@@ -315,7 +316,7 @@ local_ref<JMountItem::javaobject> createUpdateLayoutMountItem(
|
||||
oldChildShadowView.layoutMetrics != newChildShadowView.layoutMetrics) {
|
||||
static auto updateLayoutInstruction =
|
||||
jni::findClassStatic(UIManagerJavaDescriptor)
|
||||
->getMethod<alias_ref<JMountItem>(jint, jint, jint, jint, jint)>(
|
||||
->getMethod<alias_ref<JMountItem>(jint, jint, jint, jint, jint, jint)>(
|
||||
"updateLayoutMountItem");
|
||||
auto layoutMetrics = newChildShadowView.layoutMetrics;
|
||||
auto pointScaleFactor = layoutMetrics.pointScaleFactor;
|
||||
@@ -325,8 +326,9 @@ local_ref<JMountItem::javaobject> createUpdateLayoutMountItem(
|
||||
int y = round(frame.origin.y * pointScaleFactor);
|
||||
int w = round(frame.size.width * pointScaleFactor);
|
||||
int h = round(frame.size.height * pointScaleFactor);
|
||||
auto layoutDirection = toInt(newChildShadowView.layoutMetrics.layoutDirection);
|
||||
return updateLayoutInstruction(
|
||||
javaUIManager, newChildShadowView.tag, x, y, w, h);
|
||||
javaUIManager, newChildShadowView.tag, x, y, w, h, layoutDirection);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
+28
-2
@@ -6,6 +6,9 @@
|
||||
*/
|
||||
package com.facebook.react.fabric.mounting.mountitems;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.util.LayoutDirection;
|
||||
import com.facebook.react.fabric.mounting.MountingManager;
|
||||
|
||||
public class UpdateLayoutMountItem implements MountItem {
|
||||
@@ -15,13 +18,30 @@ public class UpdateLayoutMountItem implements MountItem {
|
||||
private final int mY;
|
||||
private final int mWidth;
|
||||
private final int mHeight;
|
||||
private final int mLayoutDirection;
|
||||
|
||||
public UpdateLayoutMountItem(int reactTag, int x, int y, int width, int height) {
|
||||
public UpdateLayoutMountItem(
|
||||
int reactTag, int x, int y, int width, int height, int layoutDirection) {
|
||||
mReactTag = reactTag;
|
||||
mX = x;
|
||||
mY = y;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mLayoutDirection = convertLayoutDirection(layoutDirection);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
private int convertLayoutDirection(int layoutDirection) {
|
||||
switch (layoutDirection) {
|
||||
case 0:
|
||||
return LayoutDirection.INHERIT;
|
||||
case 1:
|
||||
return LayoutDirection.LTR;
|
||||
case 2:
|
||||
return LayoutDirection.RTL;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported layout direction: " + layoutDirection);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +65,10 @@ public class UpdateLayoutMountItem implements MountItem {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public int getLayoutDirection() {
|
||||
return mLayoutDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UpdateLayoutMountItem ["
|
||||
@@ -56,6 +80,8 @@ public class UpdateLayoutMountItem implements MountItem {
|
||||
+ " - height: "
|
||||
+ mHeight
|
||||
+ " - width: "
|
||||
+ mWidth;
|
||||
+ mWidth
|
||||
+ " - layoutDirection: "
|
||||
+ +mLayoutDirection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ReactTextViewManager
|
||||
textViewProps.getTopPadding(),
|
||||
textViewProps.getEndPadding(),
|
||||
textViewProps.getBottomPadding(),
|
||||
textViewProps.getTextAlign(),
|
||||
0,
|
||||
textBreakStrategy,
|
||||
justificationMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user