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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b7d74a3f02bd03cdb690692033bfa634>>
* @generated SignedSource<<aa3d5cd24fcf2899f3399abf5817131c>>
*/

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableBridgelessArchitecture(): Boolean = true

override fun enableCppPropsIteratorSetter(): Boolean = false
override fun enableCppPropsIteratorSetter(): Boolean = true

override fun enableCustomFocusSearchOnClippedElementsAndroid(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<27603b5ebd0d0ced33789cc995cee9c1>>
* @generated SignedSource<<5ea58a9bc8cf405df4d60e2080621c85>>
*/

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
}

bool enableCppPropsIteratorSetter() override {
return false;
return true;
}

bool enableCustomFocusSearchOnClippedElementsAndroid() override {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.
*/

#include <gtest/gtest.h>

#include <react/renderer/components/image/ImageProps.h>
#include <react/test_utils/PropsIteratorSetterParity.h>

namespace facebook::react {

using folly::dynamic;

TEST(ImagePropsIteratorSetterParityTest, setsAndClearsImageProps) {
const auto parity = buildIteratorSetterParity<ImageProps>(dynamic::object(
"source",
dynamic::array(
dynamic::object("uri", "https://example.com/a.png")("width", 10)(
"height", 20)))(
"defaultSource", dynamic::object("uri", "https://example.com/b.png"))(
"loadingIndicatorSrc",
dynamic::object("uri", "https://example.com/c.png"))(
"resizeMode", "contain")("blurRadius", 2)(
"capInsets",
dynamic::object("top", 1)("left", 2)("bottom", 3)("right", 4))(
"tintColor", 0xFF00FF00)("internal_analyticTag", "tag")(
"resizeMethod", "resize")("resizeMultiplier", 2)(
"shouldNotifyLoadEvents", true)("overlayColor", 0xFFFF0000)(
"fadeDuration", 100)("progressiveRenderingEnabled", true));

EXPECT_ITERATOR_SETTER_PARITY(parity, sources);
EXPECT_ITERATOR_SETTER_PARITY(parity, defaultSource);
EXPECT_ITERATOR_SETTER_PARITY(parity, loadingIndicatorSource);
EXPECT_ITERATOR_SETTER_PARITY(parity, resizeMode);
EXPECT_ITERATOR_SETTER_PARITY(parity, blurRadius);
EXPECT_ITERATOR_SETTER_PARITY(parity, capInsets);
EXPECT_ITERATOR_SETTER_PARITY(parity, tintColor);
EXPECT_ITERATOR_SETTER_PARITY(parity, internal_analyticTag);
EXPECT_ITERATOR_SETTER_PARITY(parity, resizeMethod);
EXPECT_ITERATOR_SETTER_PARITY(parity, resizeMultiplier);
EXPECT_ITERATOR_SETTER_PARITY(parity, shouldNotifyLoadEvents);
EXPECT_ITERATOR_SETTER_PARITY(parity, overlayColor);
EXPECT_ITERATOR_SETTER_PARITY(parity, fadeDuration);
EXPECT_ITERATOR_SETTER_PARITY(parity, progressiveRenderingEnabled);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ BaseScrollViewProps::BaseScrollViewProps(
rawProps,
"horizontal",
sourceProps.horizontal,
true)),
false)),
scrollEventThrottle(convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.
*/

#include <gtest/gtest.h>

#include <react/renderer/components/scrollview/ScrollViewProps.h>
#include <react/test_utils/PropsIteratorSetterParity.h>

namespace facebook::react {

using folly::dynamic;

TEST(ScrollViewPropsIteratorSetterParityTest, setsAndClearsScrollViewProps) {
const dynamic edgeInsets =
dynamic::object("top", 1)("left", 2)("bottom", 3)("right", 4);
const auto parity = buildIteratorSetterParity<ScrollViewProps>(
dynamic::object("alwaysBounceHorizontal", true)(
"alwaysBounceVertical", true)("bounces", false)("bouncesZoom", false)(
"canCancelContentTouches", false)("centerContent", true)(
"automaticallyAdjustContentInsets", true)(
"automaticallyAdjustsScrollIndicatorInsets", false)(
"automaticallyAdjustKeyboardInsets", true)("decelerationRate", 0.5)(
"directionalLockEnabled", true)("indicatorStyle", "black")(
"keyboardDismissMode", "on-drag")(
"maintainVisibleContentPosition",
dynamic::object("minIndexForVisible", 1))("maximumZoomScale", 3)(
"minimumZoomScale", 0.5)("scrollEnabled", false)(
"endDraggingSensitivityMultiplier", 2)("pagingEnabled", true)(
"pinchGestureEnabled", false)("scrollsToTop", false)(
"showsHorizontalScrollIndicator", false)(
"showsVerticalScrollIndicator", false)("persistentScrollbar", true)(
"horizontal", true)("scrollEventThrottle", 16)("zoomScale", 2)(
"contentInset", edgeInsets)(
"contentOffset", dynamic::object("x", 5)("y", 6))(
"scrollIndicatorInsets", edgeInsets)("snapToInterval", 50)(
"snapToAlignment", "center")("disableIntervalMomentum", true)(
"snapToOffsets", dynamic::array(10, 20))("snapToStart", false)(
"snapToEnd", false)("contentInsetAdjustmentBehavior", "always")(
"scrollToOverflowEnabled", true)("isInvertedVirtualizedList", true));

EXPECT_ITERATOR_SETTER_PARITY(parity, alwaysBounceHorizontal);
EXPECT_ITERATOR_SETTER_PARITY(parity, alwaysBounceVertical);
EXPECT_ITERATOR_SETTER_PARITY(parity, bounces);
EXPECT_ITERATOR_SETTER_PARITY(parity, bouncesZoom);
EXPECT_ITERATOR_SETTER_PARITY(parity, canCancelContentTouches);
EXPECT_ITERATOR_SETTER_PARITY(parity, centerContent);
EXPECT_ITERATOR_SETTER_PARITY(parity, automaticallyAdjustContentInsets);
EXPECT_ITERATOR_SETTER_PARITY(
parity, automaticallyAdjustsScrollIndicatorInsets);
EXPECT_ITERATOR_SETTER_PARITY(parity, automaticallyAdjustKeyboardInsets);
EXPECT_ITERATOR_SETTER_PARITY(parity, decelerationRate);
EXPECT_ITERATOR_SETTER_PARITY(parity, directionalLockEnabled);
EXPECT_ITERATOR_SETTER_PARITY(parity, indicatorStyle);
EXPECT_ITERATOR_SETTER_PARITY(parity, keyboardDismissMode);
EXPECT_ITERATOR_SETTER_PARITY(parity, maintainVisibleContentPosition);
EXPECT_ITERATOR_SETTER_PARITY(parity, maximumZoomScale);
EXPECT_ITERATOR_SETTER_PARITY(parity, minimumZoomScale);
EXPECT_ITERATOR_SETTER_PARITY(parity, scrollEnabled);
EXPECT_ITERATOR_SETTER_PARITY(parity, endDraggingSensitivityMultiplier);
EXPECT_ITERATOR_SETTER_PARITY(parity, pagingEnabled);
EXPECT_ITERATOR_SETTER_PARITY(parity, pinchGestureEnabled);
EXPECT_ITERATOR_SETTER_PARITY(parity, scrollsToTop);
EXPECT_ITERATOR_SETTER_PARITY(parity, showsHorizontalScrollIndicator);
EXPECT_ITERATOR_SETTER_PARITY(parity, showsVerticalScrollIndicator);
EXPECT_ITERATOR_SETTER_PARITY(parity, persistentScrollbar);
EXPECT_ITERATOR_SETTER_PARITY(parity, horizontal);
EXPECT_ITERATOR_SETTER_PARITY(parity, scrollEventThrottle);
EXPECT_ITERATOR_SETTER_PARITY(parity, zoomScale);
EXPECT_ITERATOR_SETTER_PARITY(parity, contentInset);
EXPECT_ITERATOR_SETTER_PARITY(parity, contentOffset);
EXPECT_ITERATOR_SETTER_PARITY(parity, scrollIndicatorInsets);
EXPECT_ITERATOR_SETTER_PARITY(parity, snapToInterval);
EXPECT_ITERATOR_SETTER_PARITY(parity, snapToAlignment);
EXPECT_ITERATOR_SETTER_PARITY(parity, disableIntervalMomentum);
EXPECT_ITERATOR_SETTER_PARITY(parity, snapToOffsets);
EXPECT_ITERATOR_SETTER_PARITY(parity, snapToStart);
EXPECT_ITERATOR_SETTER_PARITY(parity, snapToEnd);
EXPECT_ITERATOR_SETTER_PARITY(parity, contentInsetAdjustmentBehavior);
EXPECT_ITERATOR_SETTER_PARITY(parity, scrollToOverflowEnabled);
EXPECT_ITERATOR_SETTER_PARITY(parity, isInvertedVirtualizedList);
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* 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.
*/

#include <gtest/gtest.h>

#include <react/renderer/components/text/ParagraphProps.h>
#include <react/renderer/components/text/TextProps.h>
#include <react/test_utils/PropsIteratorSetterParity.h>

namespace facebook::react {

using folly::dynamic;

TEST(TextPropsIteratorSetterParityTest, setsAndClearsTextProps) {
const auto parity = buildIteratorSetterParity<TextProps>(dynamic::object(
"color", 0xFF00FF00)("fontFamily", "Menlo")("fontSize", 18)(
"fontSizeMultiplier", 2)("fontWeight", "bold")("fontStyle", "italic")(
"fontVariant", dynamic::array("small-caps"))(
"fontVariationSettings", "'wght' 700")("allowFontScaling", false)(
"maxFontSizeMultiplier", 3)("dynamicTypeRamp", "body")(
"letterSpacing", 1.5)("textTransform", "uppercase")("lineHeight", 22)(
"textAlign", "center")("writingDirection", "rtl")(
"lineBreakStrategyIOS", "standard")("lineBreakModeIOS", "clipping")(
"textDecorationColor", 0xFFFF0000)("textDecorationLine", "underline")(
"textDecorationStyle", "dashed")(
"textShadowOffset", dynamic::object("width", 1)("height", 2))(
"textShadowRadius", 3)("textShadowColor", 0xFF0000FF)(
"isHighlighted", true)("isPressable", true)("accessibilityRole", "link")(
"role", "button")("opacity", 0.5)("backgroundColor", 0xFF00FFFF));

EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.foregroundColor);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontFamily);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontSize);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontSizeMultiplier);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontWeight);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontStyle);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontVariant);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontVariationSettings);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.allowFontScaling);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.maxFontSizeMultiplier);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.dynamicTypeRamp);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.letterSpacing);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textTransform);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.lineHeight);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.alignment);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.baseWritingDirection);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.lineBreakStrategy);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.lineBreakMode);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textDecorationColor);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textDecorationLineType);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textDecorationStyle);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textShadowOffset);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textShadowRadius);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.textShadowColor);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.isHighlighted);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.isPressable);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.accessibilityRole);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.role);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.opacity);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.backgroundColor);
}

TEST(TextPropsIteratorSetterParityTest, setsAndClearsParagraphProps) {
const auto parity = buildIteratorSetterParity<ParagraphProps>(
dynamic::object("numberOfLines", 2)("ellipsizeMode", "middle")(
"textBreakStrategy", "simple")(
"experimental_textWidthMode", "longest-line")(
"adjustsFontSizeToFit", true)("minimumFontScale", 0.5)(
"minimumFontSize", 8)("includeFontPadding", false)(
"android_hyphenationFrequency", "full")("lineBreak", "strict")(
"wordBreak", "auto-phrase")("textAlignVertical", "center")(
"selectable", true)("onTextLayout", true)("fontSize", 18)(
"opacity", 0.5)("backgroundColor", 0xFF00FFFF));

EXPECT_ITERATOR_SETTER_PARITY(
parity, paragraphAttributes.maximumNumberOfLines);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.ellipsizeMode);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.textBreakStrategy);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.textWidthMode);
EXPECT_ITERATOR_SETTER_PARITY(
parity, paragraphAttributes.adjustsFontSizeToFit);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.minimumFontScale);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.minimumFontSize);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.includeFontPadding);
EXPECT_ITERATOR_SETTER_PARITY(
parity, paragraphAttributes.android_hyphenationFrequency);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.lineBreak);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.wordBreak);
EXPECT_ITERATOR_SETTER_PARITY(parity, paragraphAttributes.textAlignVertical);
EXPECT_ITERATOR_SETTER_PARITY(parity, isSelectable);
EXPECT_ITERATOR_SETTER_PARITY(parity, onTextLayout);
EXPECT_ITERATOR_SETTER_PARITY(parity, textAttributes.fontSize);
EXPECT_ITERATOR_SETTER_PARITY(parity, opacity);
EXPECT_ITERATOR_SETTER_PARITY(parity, backgroundColor);

// Paragraph applies `opacity` and `backgroundColor` to its view, not to its
// text attributes
EXPECT_TRUE(std::isnan(parity.iterator.textAttributes.opacity));
EXPECT_EQ(parity.iterator.textAttributes.backgroundColor, SharedColor{});
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,24 @@ void BaseTextInputProps::setProp(
paragraphAttributes,
textBreakStrategy,
"textBreakStrategy");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
paragraphAttributes,
textWidthMode,
"experimental_textWidthMode");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
paragraphAttributes,
adjustsFontSizeToFit,
"adjustsFontSizeToFit");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
paragraphAttributes,
minimumFontScale,
"minimumFontScale");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
Expand All @@ -191,6 +203,10 @@ void BaseTextInputProps::setProp(
paragraphAttributes,
android_hyphenationFrequency,
"android_hyphenationFrequency");
REBUILD_FIELD_SWITCH_CASE(
paDefaults, value, paragraphAttributes, lineBreak, "lineBreak");
REBUILD_FIELD_SWITCH_CASE(
paDefaults, value, paragraphAttributes, wordBreak, "wordBreak");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
Expand Down
Loading
Loading