Skip to content

Commit d08e668

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add getDiffProps for TextInput component - paragraph attributes (facebook#51274)
Summary: Pull Request resolved: facebook#51274 See title Changelog: [Internal] Reviewed By: rshest Differential Revision: D74610302 fbshipit-source-id: ef1f946e0b7f7b51c06da167e5b8df2fc57933f6
1 parent d7b056c commit d08e668

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

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

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

359+
folly::dynamic AndroidTextInputProps::getDiffProps(
360+
const Props* prevProps) const {
361+
static const auto defaultProps = AndroidTextInputProps();
362+
363+
const AndroidTextInputProps* oldProps = prevProps == nullptr
364+
? &defaultProps
365+
: static_cast<const AndroidTextInputProps*>(prevProps);
366+
367+
folly::dynamic result = ViewProps::getDiffProps(oldProps);
368+
369+
// Base text input paragraph props
370+
if (paragraphAttributes.maximumNumberOfLines !=
371+
oldProps->paragraphAttributes.maximumNumberOfLines) {
372+
result["numberOfLines"] = paragraphAttributes.maximumNumberOfLines;
373+
}
374+
375+
if (paragraphAttributes.ellipsizeMode !=
376+
oldProps->paragraphAttributes.ellipsizeMode) {
377+
result["ellipsizeMode"] = toString(paragraphAttributes.ellipsizeMode);
378+
}
379+
380+
if (paragraphAttributes.textBreakStrategy !=
381+
oldProps->paragraphAttributes.textBreakStrategy) {
382+
result["textBreakStrategy"] =
383+
toString(paragraphAttributes.textBreakStrategy);
384+
}
385+
386+
if (paragraphAttributes.adjustsFontSizeToFit !=
387+
oldProps->paragraphAttributes.adjustsFontSizeToFit) {
388+
result["adjustsFontSizeToFit"] = paragraphAttributes.adjustsFontSizeToFit;
389+
}
390+
391+
if (paragraphAttributes.minimumFontSize !=
392+
oldProps->paragraphAttributes.minimumFontSize) {
393+
result["minimumFontSize"] = paragraphAttributes.minimumFontSize;
394+
}
395+
396+
if (paragraphAttributes.maximumFontSize !=
397+
oldProps->paragraphAttributes.maximumFontSize) {
398+
result["maximumFontSize"] = paragraphAttributes.maximumFontSize;
399+
}
400+
401+
if (paragraphAttributes.includeFontPadding !=
402+
oldProps->paragraphAttributes.includeFontPadding) {
403+
result["includeFontPadding"] = paragraphAttributes.includeFontPadding;
404+
}
405+
406+
if (paragraphAttributes.android_hyphenationFrequency !=
407+
oldProps->paragraphAttributes.android_hyphenationFrequency) {
408+
result["android_hyphenationFrequency"] =
409+
toString(paragraphAttributes.android_hyphenationFrequency);
410+
}
411+
412+
return result;
413+
}
414+
359415
} // namespace facebook::react

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ class AndroidTextInputProps final : public BaseTextInputProps {
124124
bool hasPaddingEnd{};
125125

126126
#if RN_DEBUG_STRING_CONVERTIBLE
127-
SharedDebugStringConvertibleList getDebugProps() const;
127+
SharedDebugStringConvertibleList getDebugProps() const override;
128128
#endif
129+
130+
folly::dynamic getDiffProps(const Props* prevProps) const override;
129131
};
130132

131133
} // namespace facebook::react

0 commit comments

Comments
 (0)