mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
feat: flex gap bindings (#34974)
Summary: This PR adds React native binding for https://github.com/facebook/yoga/pull/1116 ## Changelog [General] [Added] - Flex gap yoga bindings <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Pull Request resolved: https://github.com/facebook/react-native/pull/34974 Test Plan: Run rn tester app and go to view example. You'll find a flex gap example. Example location - `packages/rn-tester/js/examples/View/ViewExample.js` ### Tested on - [x] iOS Fabric - [x] iOS non-fabric - [x] Android Fabric - [x] Android non-fabric To test on non-fabric Android, I just switched these booleans. Let me know if there's anything else I might have missed. <img width="674" alt="Screenshot 2022-10-14 at 3 30 48 AM" src="https://user-images.githubusercontent.com/23293248/195718971-7aee4e7e-dbf0-4452-9d47-7925919c61dc.png"> Reviewed By: mdvacca Differential Revision: D40527474 Pulled By: NickGerleman fbshipit-source-id: 81c2c97c76f58fad3bb40fb378aaf8b6ebd30d63
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a68c418082
commit
9f3a3e13cc
@@ -224,6 +224,30 @@ public class LayoutShadowNode extends ReactShadowNodeImpl {
|
||||
super.setFlexGrow(flexGrow);
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.ROW_GAP, defaultFloat = YogaConstants.UNDEFINED)
|
||||
public void setRowGap(float rowGap) {
|
||||
if (isVirtual()) {
|
||||
return;
|
||||
}
|
||||
super.setRowGap(PixelUtil.toPixelFromDIP(rowGap));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.COLUMN_GAP, defaultFloat = YogaConstants.UNDEFINED)
|
||||
public void setColumnGap(float columnGap) {
|
||||
if (isVirtual()) {
|
||||
return;
|
||||
}
|
||||
super.setColumnGap(PixelUtil.toPixelFromDIP(columnGap));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.GAP, defaultFloat = YogaConstants.UNDEFINED)
|
||||
public void setGap(float gap) {
|
||||
if (isVirtual()) {
|
||||
return;
|
||||
}
|
||||
super.setGap(PixelUtil.toPixelFromDIP(gap));
|
||||
}
|
||||
|
||||
@ReactProp(name = ViewProps.FLEX_SHRINK, defaultFloat = 0f)
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
if (isVirtual()) {
|
||||
|
||||
@@ -308,6 +308,12 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
|
||||
|
||||
void setFlexGrow(float flexGrow);
|
||||
|
||||
void setRowGap(float rowGap);
|
||||
|
||||
void setColumnGap(float columnGap);
|
||||
|
||||
void setGap(float gap);
|
||||
|
||||
void setFlexShrink(float flexShrink);
|
||||
|
||||
void setFlexBasis(float flexBasis);
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.facebook.yoga.YogaDirection;
|
||||
import com.facebook.yoga.YogaDisplay;
|
||||
import com.facebook.yoga.YogaEdge;
|
||||
import com.facebook.yoga.YogaFlexDirection;
|
||||
import com.facebook.yoga.YogaGutter;
|
||||
import com.facebook.yoga.YogaJustify;
|
||||
import com.facebook.yoga.YogaMeasureFunction;
|
||||
import com.facebook.yoga.YogaNode;
|
||||
@@ -794,6 +795,21 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
||||
mYogaNode.setFlexGrow(flexGrow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRowGap(float rowGap) {
|
||||
mYogaNode.setGap(YogaGutter.ROW, rowGap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColumnGap(float columnGap) {
|
||||
mYogaNode.setGap(YogaGutter.COLUMN, columnGap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGap(float gap) {
|
||||
mYogaNode.setGap(YogaGutter.ALL, gap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlexShrink(float flexShrink) {
|
||||
mYogaNode.setFlexShrink(flexShrink);
|
||||
|
||||
@@ -32,6 +32,9 @@ public class ViewProps {
|
||||
public static final String FLEX_BASIS = "flexBasis";
|
||||
public static final String FLEX_DIRECTION = "flexDirection";
|
||||
public static final String FLEX_WRAP = "flexWrap";
|
||||
public static final String ROW_GAP = "rowGap";
|
||||
public static final String COLUMN_GAP = "columnGap";
|
||||
public static final String GAP = "gap";
|
||||
public static final String HEIGHT = "height";
|
||||
public static final String JUSTIFY_CONTENT = "justifyContent";
|
||||
public static final String LEFT = "left";
|
||||
@@ -203,6 +206,9 @@ public class ViewProps {
|
||||
FLEX_BASIS,
|
||||
FLEX_DIRECTION,
|
||||
FLEX_GROW,
|
||||
ROW_GAP,
|
||||
COLUMN_GAP,
|
||||
GAP,
|
||||
FLEX_SHRINK,
|
||||
FLEX_WRAP,
|
||||
JUSTIFY_CONTENT,
|
||||
|
||||
Reference in New Issue
Block a user