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 @@ -158,6 +158,7 @@ AndroidTextInputProps::AndroidTextInputProps(
{false})),
fontWeight(convertRawProp(context, rawProps, "fontWeight", sourceProps.fontWeight, {})),
fontFamily(convertRawProp(context, rawProps, "fontFamily", sourceProps.fontFamily, {})),
fontVariant(convertRawProp(context, rawProps, "fontVariant", sourceProps.fontVariant, {})),
onKeyPress(convertRawProp(context, rawProps, "onKeyPress", sourceProps.onKeyPress, {false})),
onSelectionChange(convertRawProp(context, rawProps,
"onSelectionChange",
Expand Down Expand Up @@ -244,6 +245,7 @@ void AndroidTextInputProps::setProp(
RAW_SET_PROP_SWITCH_CASE_BASIC(includeFontPadding);
RAW_SET_PROP_SWITCH_CASE_BASIC(fontWeight);
RAW_SET_PROP_SWITCH_CASE_BASIC(fontFamily);
RAW_SET_PROP_SWITCH_CASE_BASIC(fontVariant);
RAW_SET_PROP_SWITCH_CASE_BASIC(onKeyPress);
RAW_SET_PROP_SWITCH_CASE_BASIC(onSelectionChange);
RAW_SET_PROP_SWITCH_CASE_BASIC(onContentSizeChange);
Expand Down Expand Up @@ -649,6 +651,11 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
result["fontFamily"] = fontFamily;
}

if (fontVariant != oldProps->fontVariant) {
result["fontVariant"] =
fontVariant.has_value() ? toDynamic(fontVariant.value()) : nullptr;
}

if (textAttributes.fontVariationSettings !=
oldProps->textAttributes.fontVariationSettings) {
result["fontVariationSettings"] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <react/renderer/components/textinput/BaseTextInputProps.h>
#include <react/renderer/components/textinput/basePrimitives.h>
#include <unordered_map>
#include <vector>

namespace facebook::react {

Expand Down Expand Up @@ -108,6 +109,7 @@ class AndroidTextInputProps final : public BaseTextInputProps {
bool includeFontPadding{false};
std::string fontWeight{};
std::string fontFamily{};
std::optional<std::vector<std::string>> fontVariant{};

/*
* Whether JS listens to these events. ReactTextInputManager only sets up the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ TEST(AndroidTextInputPropsDiffTest, removedFontSizeIsSentAsNull) {
});
}

// ReactTextInputManager reads an array, and supports values that the
// FontVariant enum in the text attributes can't represent.
TEST(AndroidTextInputPropsDiffTest, fontVariantIsSentAsAnArray) {
using folly::dynamic;
expectPayloadsMatchRawProps<AndroidTextInputProps>({
{dynamic::object(
"fontVariant", dynamic::array("small-caps", "common-ligatures"))},
{dynamic::object("fontVariant", dynamic::array())},
{dynamic::object("fontVariant", nullptr)},
});
}

} // namespace facebook::react

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ class facebook::react::AndroidTextInputProps : public facebook::react::BaseTextI
public folly::dynamic getDynamic() const;
public int inlineImagePadding;
public int numberOfLines;
public std::optional<std::vector<std::string>> fontVariant;
public std::string autoComplete;
public std::string fontFamily;
public std::string fontStyle;
Expand Down
Loading