From 322b6df0afb7300f8e7bf88968c3144a8feb0835 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Tue, 17 Oct 2023 13:07:58 -0700 Subject: [PATCH] Bindings for `alignContent: "space-evenly"` (#41020) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41020 This adds Fabric and Paper bindings to support `alignContent: "space-evenly"` as implemented in https://github.com/facebook/yoga/pull/1422 Changelog: [General][Added] - Bindings for `alignContent: "space-evenly"` Reviewed By: yungsters Differential Revision: D50347978 fbshipit-source-id: acbc0325490be4b0b376586eeaab42a6bdbcd8cc --- .../react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts | 1 + .../react-native/Libraries/StyleSheet/StyleSheetTypes.js | 3 ++- packages/react-native/React/Base/RCTConvert.m | 3 ++- .../java/com/facebook/react/uimanager/LayoutShadowNode.java | 5 +++++ .../ReactCommon/react/renderer/components/view/conversions.h | 4 ++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts index 92fe7cdaf36bb3..f7a0de83adc47d 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.d.ts @@ -40,6 +40,7 @@ export interface FlexStyle { | 'stretch' | 'space-between' | 'space-around' + | 'space-evenly' | undefined; alignItems?: FlexAlignType | undefined; alignSelf?: 'auto' | FlexAlignType | undefined; diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index fb2db1c4c60e31..c4f45c7e61c6b1 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -552,7 +552,8 @@ type ____LayoutStyle_Internal = $ReadOnly<{ | 'center' | 'stretch' | 'space-between' - | 'space-around', + | 'space-around' + | 'space-evenly', /** `overflow` controls how children are measured and displayed. * `overflow: hidden` causes views to be clipped while `overflow: scroll` diff --git a/packages/react-native/React/Base/RCTConvert.m b/packages/react-native/React/Base/RCTConvert.m index 34822463593f8f..55f42ebf49e9e3 100644 --- a/packages/react-native/React/Base/RCTConvert.m +++ b/packages/react-native/React/Base/RCTConvert.m @@ -1172,7 +1172,8 @@ + (NSPropertyList)NSPropertyList:(id)json @"stretch" : @(YGAlignStretch), @"baseline" : @(YGAlignBaseline), @"space-between" : @(YGAlignSpaceBetween), - @"space-around" : @(YGAlignSpaceAround) + @"space-around" : @(YGAlignSpaceAround), + @"space-evenly" : @(YGAlignSpaceEvenly) }), YGAlignFlexStart, intValue) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java index 46b833a053a2dc..6513dd6268cc67 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LayoutShadowNode.java @@ -541,6 +541,11 @@ public void setAlignContent(@Nullable String alignContent) { setAlignContent(YogaAlign.SPACE_AROUND); return; } + case "space-evenly": + { + setAlignContent(YogaAlign.SPACE_EVENLY); + return; + } default: { FLog.w(ReactConstants.TAG, "invalid value for alignContent: " + alignContent); diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h index 49662454c9242a..5c4bbbfc04fc5f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -284,6 +284,10 @@ inline void fromRawValue( result = yoga::Align::SpaceAround; return; } + if (stringValue == "space-evenly") { + result = yoga::Align::SpaceEvenly; + return; + } LOG(ERROR) << "Could not parse yoga::Align:" << stringValue; react_native_expect(false); }