Skip to content

Commit

Permalink
Fix codegen for Array<EdgeInsetsValue>
Browse files Browse the repository at this point in the history
Summary:
Changelog:
[Internal][Added] - Add support for props of type Array<EdgeInsetsValue>

Reviewed By: christophpurrer

Differential Revision: D42651078

fbshipit-source-id: 3b8683ab199c3d590136cec0e6a67e9e85aaa2c0
  • Loading branch information
genkikondo authored and facebook-github-bot committed Jan 23, 2023
1 parent 114e03e commit 04cf92f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
* @flow strict-local
*/

import type {PointValue} from '../../../../../Libraries/StyleSheet/StyleSheetTypes';
import type {
EdgeInsetsValue,
PointValue,
} from '../../../../../Libraries/StyleSheet/StyleSheetTypes';
import type {ColorValue} from '../../../../../Libraries/StyleSheet/StyleSheet';
import type {ImageSource} from '../../../../../Libraries/Image/ImageSource';
import type {
Expand All @@ -31,8 +34,7 @@ type NativeProps = $ReadOnly<{|
colors?: $ReadOnlyArray<ColorValue>,
srcs?: $ReadOnlyArray<ImageSource>,
points?: $ReadOnlyArray<PointValue>,
// TODO(T104760003) Fix EdgeInsetsValue in codegen
// edgeInsets?: $ReadOnlyArray<EdgeInsetsValue>,
edgeInsets?: $ReadOnlyArray<EdgeInsetsValue>,
sizes?: WithDefault<$ReadOnlyArray<'small' | 'large'>, 'small'>,
object?: $ReadOnlyArray<$ReadOnly<{|prop: string|}>>,
|}>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ArrayPropsNativeComponentViewProps::ArrayPropsNativeComponentViewProps(
colors(convertRawProp(context, rawProps, \\"colors\\", sourceProps.colors, {})),
srcs(convertRawProp(context, rawProps, \\"srcs\\", sourceProps.srcs, {})),
points(convertRawProp(context, rawProps, \\"points\\", sourceProps.points, {})),
edgeInsets(convertRawProp(context, rawProps, \\"edgeInsets\\", sourceProps.edgeInsets, {})),
sizes(convertRawProp(context, rawProps, \\"sizes\\", sourceProps.sizes, {static_cast<ArrayPropsNativeComponentViewSizesMask>(ArrayPropsNativeComponentViewSizes::Small)})),
object(convertRawProp(context, rawProps, \\"object\\", sourceProps.object, {}))
{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Object {
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/graphics/RectangleEdges.h>
#include <react/renderer/imagemanager/primitives.h>
#include <vector>
Expand Down Expand Up @@ -120,6 +121,7 @@ class JSI_EXPORT ArrayPropsNativeComponentViewProps final : public ViewProps {
std::vector<SharedColor> colors{};
std::vector<ImageSource> srcs{};
std::vector<Point> points{};
std::vector<EdgeInsets> edgeInsets{};
ArrayPropsNativeComponentViewSizesMask sizes{static_cast<ArrayPropsNativeComponentViewSizesMask>(ArrayPropsNativeComponentViewSizes::Small)};
std::vector<ArrayPropsNativeComponentViewObjectStruct> object{};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class ArrayPropsNativeComponentViewManagerDelegate<T extends View, U exte
case \\"points\\":
mViewManager.setPoints(view, (ReadableArray) value);
break;
case \\"edgeInsets\\":
mViewManager.setEdgeInsets(view, (ReadableArray) value);
break;
case \\"sizes\\":
mViewManager.setSizes(view, (ReadableArray) value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface ArrayPropsNativeComponentViewManagerInterface<T extends View> {
void setColors(T view, @Nullable ReadableArray value);
void setSrcs(T view, @Nullable ReadableArray value);
void setPoints(T view, @Nullable ReadableArray value);
void setEdgeInsets(T view, @Nullable ReadableArray value);
void setSizes(T view, @Nullable ReadableArray value);
void setObject(T view, @Nullable ReadableArray value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const __INTERNAL_VIEW_CONFIG = {
srcs: true,
points: true,
edgeInsets: true,
sizes: true,
object: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ function getReactDiffProcessValue(typeAnnotation: PropTypeAnnotation) {
return j.literal(true);
case 'PointPrimitive':
return j.literal(true);
case 'EdgeInsetsPrimitive':
return j.literal(true);
default:
throw new Error(
`Received unknown array native typeAnnotation: "${typeAnnotation.elementType.name}"`,
Expand Down

0 comments on commit 04cf92f

Please sign in to comment.