mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
AndroidTextInput: support proper measuring of AndroidTextInput text, and displaying attributed strings
Summary: Use a similar setup as Paragraph, and support in Fabric: - Correct measuring of AndroidTextInput - Correct display of AndroidTextInput attributed strings Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D18669957 fbshipit-source-id: 84e0ad8021c9edf8219e0c673c781276ca29787d
This commit is contained in:
committed by
Facebook Github Bot
parent
1cab7ad1d6
commit
07580f0f7e
@@ -13,103 +13,11 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/**
|
||||
* This was cribbed from BaseTextProps. Maybe we can unify someday.
|
||||
* TODO: we should probably just move this to BaseTextProps / subclass it
|
||||
*
|
||||
* @param rawProps
|
||||
* @param defaultTextAttributes
|
||||
* @return
|
||||
*/
|
||||
static TextAttributes convertRawProp(
|
||||
const RawProps &rawProps,
|
||||
const TextAttributes defaultTextAttributes) {
|
||||
auto textAttributes = TextAttributes{};
|
||||
|
||||
// Color
|
||||
textAttributes.foregroundColor =
|
||||
convertRawProp(rawProps, "color", defaultTextAttributes.foregroundColor);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.backgroundColor = convertRawProp(
|
||||
rawProps, "backgroundColor", defaultTextAttributes.backgroundColor);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.opacity =
|
||||
convertRawProp(rawProps, "opacity", defaultTextAttributes.opacity);
|
||||
|
||||
// Font
|
||||
textAttributes.fontFamily =
|
||||
convertRawProp(rawProps, "fontFamily", defaultTextAttributes.fontFamily);
|
||||
textAttributes.fontSize =
|
||||
convertRawProp(rawProps, "fontSize", defaultTextAttributes.fontSize);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
// is this maxFontSizeMultiplier?
|
||||
textAttributes.fontSizeMultiplier = convertRawProp(
|
||||
rawProps, "fontSizeMultiplier", defaultTextAttributes.fontSizeMultiplier);
|
||||
textAttributes.fontWeight =
|
||||
convertRawProp(rawProps, "fontWeight", defaultTextAttributes.fontWeight);
|
||||
textAttributes.fontStyle =
|
||||
convertRawProp(rawProps, "fontStyle", defaultTextAttributes.fontStyle);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.fontVariant = convertRawProp(
|
||||
rawProps, "fontVariant", defaultTextAttributes.fontVariant);
|
||||
textAttributes.allowFontScaling = convertRawProp(
|
||||
rawProps, "allowFontScaling", defaultTextAttributes.allowFontScaling);
|
||||
textAttributes.letterSpacing = convertRawProp(
|
||||
rawProps, "letterSpacing", defaultTextAttributes.letterSpacing);
|
||||
|
||||
// Paragraph
|
||||
textAttributes.lineHeight =
|
||||
convertRawProp(rawProps, "lineHeight", defaultTextAttributes.lineHeight);
|
||||
textAttributes.alignment =
|
||||
convertRawProp(rawProps, "textAlign", defaultTextAttributes.alignment);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.baseWritingDirection = convertRawProp(
|
||||
rawProps,
|
||||
"baseWritingDirection",
|
||||
defaultTextAttributes.baseWritingDirection);
|
||||
|
||||
// Decoration
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.textDecorationColor = convertRawProp(
|
||||
rawProps,
|
||||
"textDecorationColor",
|
||||
defaultTextAttributes.textDecorationColor);
|
||||
textAttributes.textDecorationLineType = convertRawProp(
|
||||
rawProps,
|
||||
"textDecorationLine",
|
||||
defaultTextAttributes.textDecorationLineType);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.textDecorationLineStyle = convertRawProp(
|
||||
rawProps,
|
||||
"textDecorationLineStyle",
|
||||
defaultTextAttributes.textDecorationLineStyle);
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.textDecorationLinePattern = convertRawProp(
|
||||
rawProps,
|
||||
"textDecorationLinePattern",
|
||||
defaultTextAttributes.textDecorationLinePattern);
|
||||
|
||||
// Shadow
|
||||
textAttributes.textShadowOffset = convertRawProp(
|
||||
rawProps, "textShadowOffset", defaultTextAttributes.textShadowOffset);
|
||||
textAttributes.textShadowRadius = convertRawProp(
|
||||
rawProps, "textShadowRadius", defaultTextAttributes.textShadowRadius);
|
||||
textAttributes.textShadowColor = convertRawProp(
|
||||
rawProps, "textShadowColor", defaultTextAttributes.textShadowColor);
|
||||
|
||||
// Special
|
||||
// Todo T53300333: not found in AndroidTextInput (java) and/or TextInput
|
||||
textAttributes.isHighlighted = convertRawProp(
|
||||
rawProps, "isHighlighted", defaultTextAttributes.isHighlighted);
|
||||
|
||||
return textAttributes;
|
||||
}
|
||||
|
||||
AndroidTextInputProps::AndroidTextInputProps(
|
||||
const AndroidTextInputProps &sourceProps,
|
||||
const RawProps &rawProps)
|
||||
: ViewProps(sourceProps, rawProps),
|
||||
|
||||
BaseTextProps(sourceProps, rawProps),
|
||||
autoCompleteType(convertRawProp(
|
||||
rawProps,
|
||||
"autoCompleteType",
|
||||
@@ -313,7 +221,8 @@ AndroidTextInputProps::AndroidTextInputProps(
|
||||
sourceProps.mostRecentEventCount,
|
||||
{0})),
|
||||
text(convertRawProp(rawProps, "text", sourceProps.text, {})),
|
||||
textAttributes(convertRawProp(rawProps, sourceProps.textAttributes)) {}
|
||||
paragraphAttributes(
|
||||
convertRawProp(rawProps, sourceProps.paragraphAttributes)) {}
|
||||
|
||||
// TODO T53300085: support this in codegen; this was hand-written
|
||||
folly::dynamic AndroidTextInputProps::getDynamic() const {
|
||||
|
||||
Reference in New Issue
Block a user