Skip to content

Commit cde792a

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add getDiffProps for TextInput component - Android text input props (facebook#51276)
Summary: Pull Request resolved: facebook#51276 This diff adds the Android specific props to the `getDiffProps` implementation and enables `TextInput` components for Props 2.0 use in the Fabric mounting manager Changelog: [Internal] Reviewed By: rshest Differential Revision: D74610303 fbshipit-source-id: c45abf2b272f5dfb50f4f1bad256e9130a808900
1 parent 63c0287 commit cde792a

File tree

3 files changed

+137
-1
lines changed

3 files changed

+137
-1
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ jni::local_ref<jobject> getProps(
228228
strcmp(newShadowView.componentName, "ScrollView") == 0 ||
229229
strcmp(newShadowView.componentName, "RawText") == 0 ||
230230
strcmp(newShadowView.componentName, "Text") == 0 ||
231-
strcmp(newShadowView.componentName, "Paragraph") == 0)) {
231+
strcmp(newShadowView.componentName, "Paragraph") == 0 ||
232+
strcmp(newShadowView.componentName, "TextInput") == 0)) {
232233
return ReadableNativeMap::newObjectCxxArgs(
233234
newProps->getDiffProps(oldProps));
234235
}

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.cpp

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,135 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
493493
: nullptr;
494494
}
495495

496+
// Android text input props
497+
if (autoComplete != oldProps->autoComplete) {
498+
result["autoComplete"] = autoComplete;
499+
}
500+
501+
if (returnKeyLabel != oldProps->returnKeyLabel) {
502+
result["returnKeyLabel"] = returnKeyLabel;
503+
}
504+
505+
if (numberOfLines != oldProps->numberOfLines) {
506+
result["numberOfLines"] = numberOfLines;
507+
}
508+
509+
if (disableFullscreenUI != oldProps->disableFullscreenUI) {
510+
result["disableFullscreenUI"] = disableFullscreenUI;
511+
}
512+
513+
if (textBreakStrategy != oldProps->textBreakStrategy) {
514+
result["textBreakStrategy"] = textBreakStrategy;
515+
}
516+
517+
if (inlineImageLeft != oldProps->inlineImageLeft) {
518+
result["inlineImageLeft"] = inlineImageLeft;
519+
}
520+
521+
if (inlineImagePadding != oldProps->inlineImagePadding) {
522+
result["inlineImagePadding"] = inlineImagePadding;
523+
}
524+
525+
if (importantForAutofill != oldProps->importantForAutofill) {
526+
result["importantForAutofill"] = importantForAutofill;
527+
}
528+
529+
if (showSoftInputOnFocus != oldProps->showSoftInputOnFocus) {
530+
result["showSoftInputOnFocus"] = showSoftInputOnFocus;
531+
}
532+
533+
if (autoCorrect != oldProps->autoCorrect) {
534+
result["autoCorrect"] = autoCorrect;
535+
}
536+
537+
if (allowFontScaling != oldProps->allowFontScaling) {
538+
result["allowFontScaling"] = allowFontScaling;
539+
}
540+
541+
if (maxFontSizeMultiplier != oldProps->maxFontSizeMultiplier) {
542+
result["maxFontSizeMultiplier"] = maxFontSizeMultiplier;
543+
}
544+
545+
if (keyboardType != oldProps->keyboardType) {
546+
result["keyboardType"] = keyboardType;
547+
}
548+
549+
if (returnKeyType != oldProps->returnKeyType) {
550+
result["returnKeyType"] = returnKeyType;
551+
}
552+
553+
if (secureTextEntry != oldProps->secureTextEntry) {
554+
result["secureTextEntry"] = secureTextEntry;
555+
}
556+
557+
if (value != oldProps->value) {
558+
result["value"] = value;
559+
}
560+
561+
if (selectTextOnFocus != oldProps->selectTextOnFocus) {
562+
result["selectTextOnFocus"] = selectTextOnFocus;
563+
}
564+
565+
if (caretHidden != oldProps->caretHidden) {
566+
result["caretHidden"] = caretHidden;
567+
}
568+
569+
if (contextMenuHidden != oldProps->contextMenuHidden) {
570+
result["contextMenuHidden"] = contextMenuHidden;
571+
}
572+
573+
if (textShadowColor != oldProps->textShadowColor) {
574+
result["textShadowColor"] = *textShadowColor;
575+
}
576+
577+
if (textShadowRadius != oldProps->textShadowRadius) {
578+
result["textShadowRadius"] = textShadowRadius;
579+
}
580+
581+
if (textDecorationLine != oldProps->textDecorationLine) {
582+
result["textDecorationLine"] = textDecorationLine;
583+
}
584+
585+
if (fontStyle != oldProps->fontStyle) {
586+
result["fontStyle"] = fontStyle;
587+
}
588+
589+
if (textShadowOffset != oldProps->textShadowOffset) {
590+
result["textShadowOffset"] = toDynamic(textShadowOffset);
591+
}
592+
593+
if (lineHeight != oldProps->lineHeight) {
594+
result["lineHeight"] = lineHeight;
595+
}
596+
597+
if (textTransform != oldProps->textTransform) {
598+
result["textTransform"] = textTransform;
599+
}
600+
601+
if (letterSpacing != oldProps->letterSpacing) {
602+
result["letterSpacing"] = letterSpacing;
603+
}
604+
605+
if (fontSize != oldProps->fontSize) {
606+
result["fontSize"] = fontSize;
607+
}
608+
609+
if (textAlign != oldProps->textAlign) {
610+
result["textAlign"] = textAlign;
611+
}
612+
613+
if (includeFontPadding != oldProps->includeFontPadding) {
614+
result["includeFontPadding"] = includeFontPadding;
615+
}
616+
617+
if (fontWeight != oldProps->fontWeight) {
618+
result["fontWeight"] = fontWeight;
619+
}
620+
621+
if (fontFamily != oldProps->fontFamily) {
622+
result["fontFamily"] = fontFamily;
623+
}
624+
496625
return result;
497626
}
498627

packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput/AndroidTextInputProps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ struct AndroidTextInputTextShadowOffsetStruct {
2727
double height;
2828
};
2929

30+
inline static bool operator==(
31+
const AndroidTextInputTextShadowOffsetStruct& lhs,
32+
const AndroidTextInputTextShadowOffsetStruct& rhs) {
33+
return lhs.width == rhs.width && lhs.height == rhs.height;
34+
}
35+
3036
static inline void fromRawValue(
3137
const PropsParserContext& context,
3238
const RawValue& value,

0 commit comments

Comments
 (0)