Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions packages/react-native/React/Views/RCTLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ UIUserInterfaceLayoutDirection RCTUIKitLayoutDirectionFromYogaLayoutDirection(YG
YGDisplay RCTYogaDisplayTypeFromReactDisplayType(RCTDisplayType displayType)
{
switch (displayType) {
case RCTDisplayTypeNone:
return YGDisplayNone;
case RCTDisplayTypeFlex:
return YGDisplayFlex;
case RCTDisplayTypeNone:
return YGDisplayNone;
case RCTDisplayTypeInline:
RCTAssert(NO, @"RCTDisplayTypeInline cannot be converted to YGDisplay value.");
return YGDisplayNone;
Expand All @@ -128,11 +128,10 @@ RCTDisplayType RCTReactDisplayTypeFromYogaDisplayType(YGDisplay displayType)
{
switch (displayType) {
case YGDisplayFlex:
case YGDisplayContents:
case YGDisplayGrid:
return RCTDisplayTypeFlex;
case YGDisplayNone:
return RCTDisplayTypeNone;
case YGDisplayContents:
RCTAssert(NO, @"YGDisplayContents cannot be converted to RCTDisplayType value.");
return RCTDisplayTypeNone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public enum YogaAlign {
BASELINE(5),
SPACE_BETWEEN(6),
SPACE_AROUND(7),
SPACE_EVENLY(8);
SPACE_EVENLY(8),
START(9),
END(10);

private final int mIntValue;

Expand All @@ -41,6 +43,8 @@ public static YogaAlign fromInt(int value) {
case 6: return SPACE_BETWEEN;
case 7: return SPACE_AROUND;
case 8: return SPACE_EVENLY;
case 9: return START;
case 10: return END;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
public enum YogaDisplay {
FLEX(0),
NONE(1),
CONTENTS(2);
CONTENTS(2),
GRID(3);

private final int mIntValue;

Expand All @@ -29,6 +30,7 @@ public static YogaDisplay fromInt(int value) {
case 0: return FLEX;
case 1: return NONE;
case 2: return CONTENTS;
case 3: return GRID;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.yoga

/**
* Represents a list of grid tracks for use with grid-template-rows/columns.
*/
public class YogaGridTrackList {
private val tracks: MutableList<YogaGridTrackValue> = mutableListOf()

public fun addTrack(track: YogaGridTrackValue) {
tracks.add(track)
}

public fun getTracks(): List<YogaGridTrackValue> = tracks.toList()

public fun size(): Int = tracks.size

public operator fun get(index: Int): YogaGridTrackValue = tracks[index]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// @generated by enums.py

package com.facebook.yoga;

public enum YogaGridTrackType {
AUTO(0),
POINTS(1),
PERCENT(2),
FR(3),
MINMAX(4);

private final int mIntValue;

YogaGridTrackType(int intValue) {
mIntValue = intValue;
}

public int intValue() {
return mIntValue;
}

public static YogaGridTrackType fromInt(int value) {
switch (value) {
case 0: return AUTO;
case 1: return POINTS;
case 2: return PERCENT;
case 3: return FR;
case 4: return MINMAX;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.yoga

/**
* Represents a grid track value for use with grid-template-rows/columns.
*/
public class YogaGridTrackValue private constructor(
public val type: Type,
public val value: Float,
public val minValue: YogaGridTrackValue?,
public val maxValue: YogaGridTrackValue?
) {
public enum class Type {
AUTO,
POINTS,
PERCENT,
FR,
MINMAX
}

private constructor(type: Type, value: Float) : this(type, value, null, null)

private constructor(min: YogaGridTrackValue, max: YogaGridTrackValue) : this(Type.MINMAX, 0f, min, max)

public companion object {
@JvmStatic
public fun auto(): YogaGridTrackValue = YogaGridTrackValue(Type.AUTO, 0f)

@JvmStatic
public fun points(points: Float): YogaGridTrackValue = YogaGridTrackValue(Type.POINTS, points)

@JvmStatic
public fun percent(percent: Float): YogaGridTrackValue = YogaGridTrackValue(Type.PERCENT, percent)

@JvmStatic
public fun fr(fr: Float): YogaGridTrackValue = YogaGridTrackValue(Type.FR, fr)

@JvmStatic
public fun minMax(min: YogaGridTrackValue, max: YogaGridTrackValue): YogaGridTrackValue =
YogaGridTrackValue(min, max)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
package com.facebook.yoga;

public enum YogaJustify {
FLEX_START(0),
CENTER(1),
FLEX_END(2),
SPACE_BETWEEN(3),
SPACE_AROUND(4),
SPACE_EVENLY(5);
AUTO(0),
FLEX_START(1),
CENTER(2),
FLEX_END(3),
SPACE_BETWEEN(4),
SPACE_AROUND(5),
SPACE_EVENLY(6),
STRETCH(7),
START(8),
END(9);

private final int mIntValue;

Expand All @@ -29,12 +33,16 @@ public int intValue() {

public static YogaJustify fromInt(int value) {
switch (value) {
case 0: return FLEX_START;
case 1: return CENTER;
case 2: return FLEX_END;
case 3: return SPACE_BETWEEN;
case 4: return SPACE_AROUND;
case 5: return SPACE_EVENLY;
case 0: return AUTO;
case 1: return FLEX_START;
case 2: return CENTER;
case 3: return FLEX_END;
case 4: return SPACE_BETWEEN;
case 5: return SPACE_AROUND;
case 6: return SPACE_EVENLY;
case 7: return STRETCH;
case 8: return START;
case 9: return END;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,68 @@ public object YogaNative {
nativePointer: Long,
alwaysFormContainingBlock: Boolean,
)

@JvmStatic
public external fun jni_YGNodeStyleSetGridTemplateColumnsJNI(
nativePointer: Long,
types: IntArray,
values: FloatArray,
minTypes: IntArray,
minValues: FloatArray,
maxTypes: IntArray,
maxValues: FloatArray,
)

@JvmStatic
public external fun jni_YGNodeStyleSetGridTemplateRowsJNI(
nativePointer: Long,
types: IntArray,
values: FloatArray,
minTypes: IntArray,
minValues: FloatArray,
maxTypes: IntArray,
maxValues: FloatArray,
)

@JvmStatic
public external fun jni_YGNodeStyleSetGridAutoColumnsJNI(
nativePointer: Long,
types: IntArray,
values: FloatArray,
minTypes: IntArray,
minValues: FloatArray,
maxTypes: IntArray,
maxValues: FloatArray,
)

@JvmStatic
public external fun jni_YGNodeStyleSetGridAutoRowsJNI(
nativePointer: Long,
types: IntArray,
values: FloatArray,
minTypes: IntArray,
minValues: FloatArray,
maxTypes: IntArray,
maxValues: FloatArray,
)

@JvmStatic
public external fun jni_YGNodeStyleSetGridColumnStartJNI(nativePointer: Long, value: Int)

@JvmStatic
public external fun jni_YGNodeStyleSetGridColumnStartSpanJNI(nativePointer: Long, span: Int)

@JvmStatic public external fun jni_YGNodeStyleSetGridColumnEndJNI(nativePointer: Long, value: Int)

@JvmStatic
public external fun jni_YGNodeStyleSetGridColumnEndSpanJNI(nativePointer: Long, span: Int)

@JvmStatic public external fun jni_YGNodeStyleSetGridRowStartJNI(nativePointer: Long, value: Int)

@JvmStatic
public external fun jni_YGNodeStyleSetGridRowStartSpanJNI(nativePointer: Long, span: Int)

@JvmStatic public external fun jni_YGNodeStyleSetGridRowEndJNI(nativePointer: Long, value: Int)

@JvmStatic public external fun jni_YGNodeStyleSetGridRowEndSpanJNI(nativePointer: Long, span: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ public abstract class YogaNode : YogaProps {

public abstract fun setGapPercent(gutter: YogaGutter, gapLength: Float)

public abstract fun setGridTemplateColumns(trackList: YogaGridTrackList)

public abstract fun setGridTemplateRows(trackList: YogaGridTrackList)

public abstract fun setGridAutoColumns(trackList: YogaGridTrackList)

public abstract fun setGridAutoRows(trackList: YogaGridTrackList)

public abstract fun setGridColumnStart(value: Int)

public abstract fun setGridColumnStartSpan(span: Int)

public abstract fun setGridColumnEnd(value: Int)

public abstract fun setGridColumnEndSpan(span: Int)

public abstract fun setGridRowStart(value: Int)

public abstract fun setGridRowStartSpan(span: Int)

public abstract fun setGridRowEnd(value: Int)

public abstract fun setGridRowEndSpan(span: Int)

public abstract val layoutX: Float

public abstract val layoutY: Float
Expand Down
Loading
Loading