Skip to content

Commit

Permalink
feat: Add Fabric logical border radius implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel committed Dec 6, 2022
1 parent 17f221c commit e3d2a0f
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Libraries/Components/View/ReactNativeStyleAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
borderColor: colorAttributes,
borderCurve: true,
borderEndColor: colorAttributes,
borderEndEndRadius: true,
borderEndStartRadius: true,
borderLeftColor: colorAttributes,
borderRadius: true,
borderRightColor: colorAttributes,
borderStartColor: colorAttributes,
borderStartEndRadius: true,
borderStartStartRadius: true,
borderStyle: true,
borderTopColor: colorAttributes,
borderTopEndRadius: true,
Expand Down
12 changes: 8 additions & 4 deletions Libraries/NativeComponent/BaseViewConfig.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,17 @@ const validAttributesForNonEventProps = {
paddingTop: true,
paddingVertical: true,

borderWidth: true,
borderStartWidth: true,
borderEndWidth: true,
borderTopWidth: true,
borderBottomWidth: true,
borderEndEndRadius: true,
borderEndStartRadius: true,
borderEndWidth: true,
borderLeftWidth: true,
borderRightWidth: true,
borderStartEndRadius: true,
borderStartStartRadius: true,
borderStartWidth: true,
borderTopWidth: true,
borderWidth: true,

start: true,
end: true,
Expand Down
4 changes: 4 additions & 0 deletions Libraries/NativeComponent/BaseViewConfig.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ const validAttributesForNonEventProps = {
borderBottomRightRadius: true,
borderBottomStartRadius: true,
borderBottomEndRadius: true,
borderEndEndRadius: true,
borderEndStartRadius: true,
borderStartEndRadius: true,
borderStartStartRadius: true,
display: true,
zIndex: true,

Expand Down
4 changes: 4 additions & 0 deletions Libraries/StyleSheet/StyleSheetTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,16 @@ export interface ViewStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
borderBottomWidth?: number | undefined;
borderColor?: ColorValue | undefined;
borderEndColor?: ColorValue | undefined;
borderEndEndRadius?: number | undefined;
borderEndStartRadius?: number | undefined;
borderLeftColor?: ColorValue | undefined;
borderLeftWidth?: number | undefined;
borderRadius?: number | undefined;
borderRightColor?: ColorValue | undefined;
borderRightWidth?: number | undefined;
borderStartColor?: ColorValue | undefined;
borderStartEndRadius?: number | undefined;
borderStartStartRadius?: number | undefined;
borderStyle?: 'solid' | 'dotted' | 'dashed' | undefined;
borderTopColor?: ColorValue | undefined;
borderTopEndRadius?: number | undefined;
Expand Down
4 changes: 4 additions & 0 deletions Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ export type ____ViewStyle_InternalCore = $ReadOnly<{
borderBottomLeftRadius?: number | AnimatedNode,
borderBottomRightRadius?: number | AnimatedNode,
borderBottomStartRadius?: number | AnimatedNode,
borderEndEndRadius?: number | AnimatedNode,
borderEndStartRadius?: number | AnimatedNode,
borderStartEndRadius?: number | AnimatedNode,
borderStartStartRadius?: number | AnimatedNode,
borderTopEndRadius?: number | AnimatedNode,
borderTopLeftRadius?: number | AnimatedNode,
borderTopRightRadius?: number | AnimatedNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ void YogaLayoutableShadowNode::updateYogaProps() {
if (CompactValue(result.padding()[YGEdgeBottom]).isUndefined()) {
result.padding()[YGEdgeBottom] = props.paddingBlockEnd;
}
if (CompactValue(result.borderRadii.bottomRight).isUndefined()) {
result.borderRadii.bottomRight = props.borderEndEndRadius;
}
if (CompactValue(result.borderRadii.bottomLeft).isUndefined()) {
result.borderRadii.bottomLeft = props.borderEndStartRadius;
}
if (CompactValue(result.borderRadii.topRight).isUndefined()) {
result.borderRadii.topRight = props.borderStartEndRadius;
}
if (CompactValue(result.borderRadii.topLeft).isUndefined()) {
result.borderRadii.topLeft = props.borderStartStartRadius;
}

return result;
}
Expand Down
38 changes: 38 additions & 0 deletions ReactCommon/react/renderer/components/view/YogaStylableProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ void YogaStylableProps::setProp(
REBUILD_FIELD_YG_EDGES(border, "border", "Width");

// Aliases
RAW_SET_PROP_SWITCH_CASE(
borderEndEndRadius, "borderEndEndRadius", CompactValue::ofUndefined());
RAW_SET_PROP_SWITCH_CASE(
borderEndStartRadius,
"borderEndStartRadius",
CompactValue::ofUndefined());
RAW_SET_PROP_SWITCH_CASE(
borderStartEndRadius,
"borderStartEndRadius",
CompactValue::ofUndefined());
RAW_SET_PROP_SWITCH_CASE(
borderStartStartRadius,
"borderStartStartRadius",
CompactValue::ofUndefined());
RAW_SET_PROP_SWITCH_CASE(
marginInline, "marginInline", CompactValue::ofUndefined());
RAW_SET_PROP_SWITCH_CASE(
Expand Down Expand Up @@ -245,6 +259,30 @@ void YogaStylableProps::convertRawPropAliases(
const PropsParserContext &context,
YogaStylableProps const &sourceProps,
RawProps const &rawProps) {
borderEndEndRadius = convertRawProp(
context,
rawProps,
"borderEndEndRadius",
sourceProps.borderEndEndRadius,
CompactValue::ofUndefined());
borderEndStartRadius = convertRawProp(
context,
rawProps,
"borderEndStartRadius",
sourceProps.borderEndStartRadius,
CompactValue::ofUndefined());
borderStartEndRadius = convertRawProp(
context,
rawProps,
"borderStartEndRadius",
sourceProps.borderStartEndRadius,
CompactValue::ofUndefined());
borderStartStartRadius = convertRawProp(
context,
rawProps,
"borderStartStartRadius",
sourceProps.borderStartStartRadius,
CompactValue::ofUndefined());
marginInline = convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class YogaStylableProps : public Props {
CompactValue paddingBlockStart;
CompactValue paddingBlockEnd;

CompactValue borderEndEndRadius;
CompactValue borderEndStartRadius;
CompactValue borderStartEndRadius;
CompactValue borderStartStartRadius;

#if RN_DEBUG_STRING_CONVERTIBLE

#pragma mark - DebugStringConvertible (Partial)
Expand Down

0 comments on commit e3d2a0f

Please sign in to comment.