Skip to content

Commit 63c0287

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add getDiffProps for TextInput component - base text input props (facebook#51275)
Summary: Pull Request resolved: facebook#51275 See title Changelog: [Internal] Reviewed By: rshest Differential Revision: D74610301 fbshipit-source-id: cbd3f8eab75838f8b68a668ec44d3e14aa591f25
1 parent d08e668 commit 63c0287

File tree

1 file changed

+84
-0
lines changed
  • packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput

1 file changed

+84
-0
lines changed

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,15 @@ SharedDebugStringConvertibleList AndroidTextInputProps::getDebugProps() const {
356356
}
357357
#endif
358358

359+
static folly::dynamic toDynamic(
360+
const std::vector<std::string>& acceptDragAndDropTypes) {
361+
folly::dynamic acceptDragAndDropTypesArray = folly::dynamic::array();
362+
for (const auto& acceptDragAndDropType : acceptDragAndDropTypes) {
363+
acceptDragAndDropTypesArray.push_back(acceptDragAndDropType);
364+
}
365+
return acceptDragAndDropTypesArray;
366+
}
367+
359368
folly::dynamic AndroidTextInputProps::getDiffProps(
360369
const Props* prevProps) const {
361370
static const auto defaultProps = AndroidTextInputProps();
@@ -409,6 +418,81 @@ folly::dynamic AndroidTextInputProps::getDiffProps(
409418
toString(paragraphAttributes.android_hyphenationFrequency);
410419
}
411420

421+
// Base text input props
422+
if (defaultValue != oldProps->defaultValue) {
423+
result["defaultValue"] = defaultValue;
424+
}
425+
426+
if (placeholder != oldProps->placeholder) {
427+
result["placeholder"] = placeholder;
428+
}
429+
430+
if (placeholderTextColor != oldProps->placeholderTextColor) {
431+
result["placeholderTextColor"] = *placeholderTextColor;
432+
}
433+
434+
if (cursorColor != oldProps->cursorColor) {
435+
result["cursorColor"] = *cursorColor;
436+
}
437+
438+
if (selectionColor != oldProps->selectionColor) {
439+
result["selectionColor"] = *selectionColor;
440+
}
441+
442+
if (selectionHandleColor != oldProps->selectionHandleColor) {
443+
result["selectionHandleColor"] = *selectionHandleColor;
444+
}
445+
446+
if (underlineColorAndroid != oldProps->underlineColorAndroid) {
447+
result["underlineColorAndroid"] = *underlineColorAndroid;
448+
}
449+
450+
if (maxLength != oldProps->maxLength) {
451+
result["maxLength"] = maxLength;
452+
}
453+
454+
if (text != oldProps->text) {
455+
result["text"] = text;
456+
}
457+
458+
if (mostRecentEventCount != oldProps->mostRecentEventCount) {
459+
result["mostRecentEventCount"] = mostRecentEventCount;
460+
}
461+
462+
if (autoFocus != oldProps->autoFocus) {
463+
result["autoFocus"] = autoFocus;
464+
}
465+
466+
if (autoCapitalize != oldProps->autoCapitalize) {
467+
result["autoCapitalize"] = autoCapitalize;
468+
}
469+
470+
if (editable != oldProps->editable) {
471+
result["editable"] = editable;
472+
}
473+
474+
if (readOnly != oldProps->readOnly) {
475+
result["readOnly"] = readOnly;
476+
}
477+
478+
if (submitBehavior != oldProps->submitBehavior) {
479+
result["submitBehavior"] = toDynamic(submitBehavior);
480+
}
481+
482+
if (multiline != oldProps->multiline) {
483+
result["multiline"] = multiline;
484+
}
485+
486+
if (disableKeyboardShortcuts != oldProps->disableKeyboardShortcuts) {
487+
result["disableKeyboardShortcuts"] = disableKeyboardShortcuts;
488+
}
489+
490+
if (acceptDragAndDropTypes != oldProps->acceptDragAndDropTypes) {
491+
result["acceptDragAndDropTypes"] = acceptDragAndDropTypes.has_value()
492+
? toDynamic(acceptDragAndDropTypes.value())
493+
: nullptr;
494+
}
495+
412496
return result;
413497
}
414498

0 commit comments

Comments
 (0)