mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Extend Fabric measure function to support attachment positions parameters
Summary: This diff changes the Fabric measure API in order to support attachments parameters changelog: [internal] Reviewed By: JoshuaGross Differential Revision: D20087252 fbshipit-source-id: 20e1526aaa3695d38d0805416df8a32adb8296ad
This commit is contained in:
committed by
Facebook Github Bot
parent
af5ecb2916
commit
8bc7ad605d
@@ -429,6 +429,32 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight) {
|
||||
return measure(
|
||||
rootTag,
|
||||
componentName,
|
||||
localData,
|
||||
props,
|
||||
state,
|
||||
minWidth,
|
||||
maxWidth,
|
||||
minHeight,
|
||||
maxHeight,
|
||||
null);
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressWarnings("unused")
|
||||
private long measure(
|
||||
int rootTag,
|
||||
String componentName,
|
||||
ReadableMap localData,
|
||||
ReadableMap props,
|
||||
ReadableMap state,
|
||||
float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
float maxHeight,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
ReactContext context =
|
||||
rootTag < 0 ? mReactApplicationContext : mReactContextForRootTag.get(rootTag);
|
||||
return mMountingManager.measure(
|
||||
@@ -440,7 +466,8 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
|
||||
getYogaSize(minWidth, maxWidth),
|
||||
getYogaMeasureMode(minWidth, maxWidth),
|
||||
getYogaSize(minHeight, maxHeight),
|
||||
getYogaMeasureMode(minHeight, maxHeight));
|
||||
getYogaMeasureMode(minHeight, maxHeight),
|
||||
attachmentsPositions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -518,11 +518,21 @@ public class MountingManager {
|
||||
float width,
|
||||
@NonNull YogaMeasureMode widthMode,
|
||||
float height,
|
||||
@NonNull YogaMeasureMode heightMode) {
|
||||
@NonNull YogaMeasureMode heightMode,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
|
||||
return mViewManagerRegistry
|
||||
.get(componentName)
|
||||
.measure(context, localData, props, state, width, widthMode, height, heightMode);
|
||||
.measure(
|
||||
context,
|
||||
localData,
|
||||
props,
|
||||
state,
|
||||
width,
|
||||
widthMode,
|
||||
height,
|
||||
heightMode,
|
||||
attachmentsPositions);
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
|
||||
@@ -287,6 +287,28 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses can override this method to implement custom measure functions for the ViewManager
|
||||
*
|
||||
* @param context {@link com.facebook.react.bridge.ReactContext} used for the view.
|
||||
* @param localData {@link ReadableMap} containing "local data" defined in C++
|
||||
* @param props {@link ReadableMap} containing JS props
|
||||
* @param state {@link ReadableMap} containing state defined in C++
|
||||
* @param width width of the view (usually zero)
|
||||
* @param widthMode widthMode used during calculation of layout
|
||||
* @param height height of the view (usually zero)
|
||||
* @param heightMode widthMode used during calculation of layout
|
||||
* @param attachmentsPositions {@link int[]} array containing 2x times the amount of attachments
|
||||
* of the view. An attachment represents the position of an inline view that needs to be
|
||||
* rendered inside a component and it requires the content of the parent view in order to be
|
||||
* positioned. This array is meant to be used by the platform to RETURN the position of each
|
||||
* attachment, as a result of the calculation of layout. (e.g. this array is used to measure
|
||||
* inlineViews that are rendered inside Text components). On most of the components this array
|
||||
* will be contain a null value.
|
||||
* <p>Even values will represent the TOP of each attachment, Odd values represent the LEFT of
|
||||
* each attachment.
|
||||
* @return result of calculation of layout for the arguments received as a parameter.
|
||||
*/
|
||||
public long measure(
|
||||
Context context,
|
||||
ReadableMap localData,
|
||||
@@ -295,7 +317,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
YogaMeasureMode heightMode,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,8 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider>
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
YogaMeasureMode heightMode,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
SeekBar reactSlider = new ReactSlider(context, null, STYLE);
|
||||
final int spec =
|
||||
View.MeasureSpec.makeMeasureSpec(
|
||||
|
||||
+2
-1
@@ -203,7 +203,8 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch>
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
YogaMeasureMode heightMode,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
ReactSwitch view = new ReactSwitch(context);
|
||||
view.setShowText(false);
|
||||
int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
|
||||
|
||||
@@ -145,7 +145,8 @@ public class ReactTextViewManager
|
||||
float width,
|
||||
YogaMeasureMode widthMode,
|
||||
float height,
|
||||
YogaMeasureMode heightMode) {
|
||||
YogaMeasureMode heightMode,
|
||||
@Nullable int[] attachmentsPositions) {
|
||||
|
||||
return TextLayoutManager.measureText(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user