mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
AndroidTextInput: support using commands instead of setNativeProps (native change)
Summary: In AndroidTextInput, support codegen'd ViewCommands in native and add three commands that will eventually replace usage of setNativeProps on Android. TextInput will use these commands in a future diff. Changelog: [Internal] Reviewed By: TheSavior Differential Revision: D18612150 fbshipit-source-id: 5d427040686e8c5ab504dd845bc8ef863f558c35
This commit is contained in:
committed by
Facebook Github Bot
parent
98b8a17645
commit
7ab5eb4caf
+31
-20
@@ -36,29 +36,40 @@ AttributedString AndroidTextInputShadowNode::getAttributedString(
|
||||
textAttributes.apply(getProps()->textAttributes);
|
||||
|
||||
// Use BaseTextShadowNode to get attributed string from children
|
||||
{
|
||||
auto const &attributedString =
|
||||
BaseTextShadowNode::getAttributedString(textAttributes, *this);
|
||||
if (!attributedString.isEmpty() || !usePlaceholders) {
|
||||
return attributedString;
|
||||
auto const &attributedString =
|
||||
BaseTextShadowNode::getAttributedString(textAttributes, *this);
|
||||
if (!attributedString.isEmpty()) {
|
||||
return attributedString;
|
||||
}
|
||||
if (!getProps()->text.empty() || usePlaceholders) {
|
||||
// If the BaseTextShadowNode didn't detect any child Text nodes, we
|
||||
// may actually just have a `text` attribute.
|
||||
// TODO: figure out why BaseTextShadowNode doesn't pick this up, this
|
||||
// is a bug. A minimal Playground example that triggers this: P122991121
|
||||
auto textAttributedString = AttributedString{};
|
||||
auto fragment = AttributedString::Fragment{};
|
||||
fragment.string = getProps()->text;
|
||||
|
||||
if (usePlaceholders) {
|
||||
// Return placeholder text instead, if text was empty.
|
||||
if (fragment.string.empty()) {
|
||||
fragment.string = getProps()->placeholder;
|
||||
}
|
||||
// For measurement purposes, we want to make sure that there's at least a
|
||||
// single character in the string so that the measured height is greater
|
||||
// than zero. Otherwise, empty TextInputs with no placeholder don't
|
||||
// display at all.
|
||||
if (fragment.string.empty()) {
|
||||
fragment.string = " ";
|
||||
}
|
||||
}
|
||||
fragment.textAttributes = textAttributes;
|
||||
fragment.parentShadowView = ShadowView(*this);
|
||||
textAttributedString.appendFragment(fragment);
|
||||
return textAttributedString;
|
||||
}
|
||||
|
||||
// Return placeholder text instead, if text was empty.
|
||||
auto placeholderAttributedString = AttributedString{};
|
||||
auto fragment = AttributedString::Fragment{};
|
||||
fragment.string = getProps()->placeholder;
|
||||
|
||||
// For measurement purposes, we want to make sure that there's at least a
|
||||
// single character in the string so that the measured height is greater than
|
||||
// zero. Otherwise, empty TextInputs with no placeholder don't display at all.
|
||||
if (fragment.string == "") {
|
||||
fragment.string = " ";
|
||||
}
|
||||
fragment.textAttributes = textAttributes;
|
||||
fragment.parentShadowView = ShadowView(*this);
|
||||
placeholderAttributedString.appendFragment(fragment);
|
||||
return placeholderAttributedString;
|
||||
return attributedString;
|
||||
}
|
||||
|
||||
void AndroidTextInputShadowNode::setTextLayoutManager(
|
||||
|
||||
Reference in New Issue
Block a user