mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ccf5c86bd7
Summary: Changelog: [Internal] Prop autoFocus was not implemented in Fabric's TextInput. Reviewed By: mdvacca Differential Revision: D22019333 fbshipit-source-id: 03f043b93e1079a5d0bff55b08ebc9d2f973c55b
95 lines
2.7 KiB
C++
95 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "TextInputProps.h"
|
|
|
|
#include <react/attributedstring/conversions.h>
|
|
#include <react/components/iostextinput/propsConversions.h>
|
|
#include <react/core/propsConversions.h>
|
|
#include <react/graphics/conversions.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
TextInputProps::TextInputProps(
|
|
TextInputProps const &sourceProps,
|
|
RawProps const &rawProps)
|
|
: ViewProps(sourceProps, rawProps),
|
|
BaseTextProps(sourceProps, rawProps),
|
|
traits(convertRawProp(rawProps, sourceProps.traits, {})),
|
|
paragraphAttributes(
|
|
convertRawProp(rawProps, sourceProps.paragraphAttributes, {})),
|
|
defaultValue(convertRawProp(
|
|
rawProps,
|
|
"defaultValue",
|
|
sourceProps.defaultValue,
|
|
{})),
|
|
placeholder(
|
|
convertRawProp(rawProps, "placeholder", sourceProps.placeholder, {})),
|
|
placeholderTextColor(convertRawProp(
|
|
rawProps,
|
|
"placeholderTextColor",
|
|
sourceProps.placeholderTextColor,
|
|
{})),
|
|
maxLength(
|
|
convertRawProp(rawProps, "maxLength", sourceProps.maxLength, {})),
|
|
cursorColor(
|
|
convertRawProp(rawProps, "cursorColor", sourceProps.cursorColor, {})),
|
|
selectionColor(convertRawProp(
|
|
rawProps,
|
|
"selectionColor",
|
|
sourceProps.selectionColor,
|
|
{})),
|
|
underlineColorAndroid(convertRawProp(
|
|
rawProps,
|
|
"underlineColorAndroid",
|
|
sourceProps.underlineColorAndroid,
|
|
{})),
|
|
text(convertRawProp(rawProps, "text", sourceProps.text, {})),
|
|
mostRecentEventCount(convertRawProp(
|
|
rawProps,
|
|
"mostRecentEventCount",
|
|
sourceProps.mostRecentEventCount,
|
|
{})),
|
|
autoFocus(
|
|
convertRawProp(rawProps, "autoFocus", sourceProps.autoFocus, {})){};
|
|
|
|
TextAttributes TextInputProps::getEffectiveTextAttributes() const {
|
|
auto result = TextAttributes::defaultTextAttributes();
|
|
result.apply(textAttributes);
|
|
|
|
/*
|
|
* These props are applied to `View`, therefore they must not be a part of
|
|
* base text attributes.
|
|
*/
|
|
result.backgroundColor = clearColor();
|
|
result.opacity = 1;
|
|
|
|
return result;
|
|
}
|
|
|
|
ParagraphAttributes TextInputProps::getEffectiveParagraphAttributes() const {
|
|
auto result = paragraphAttributes;
|
|
|
|
if (!traits.multiline) {
|
|
result.maximumNumberOfLines = 1;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#ifdef ANDROID
|
|
folly::dynamic TextInputProps::getDynamic() const {
|
|
folly::dynamic props = folly::dynamic::object();
|
|
props["value"] = value;
|
|
return props;
|
|
}
|
|
#endif
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|