mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5abe5843e2
Summary: Support existing, backwards-compatible AndroidTextInput component for minimal support of TextInput on Android. Reviewed By: shergin, mdvacca Differential Revision: D17086758 fbshipit-source-id: 25726f22229e0d5dfe96eb36b386a5317601283d
164 lines
4.6 KiB
C++
164 lines
4.6 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.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// #include <react/components/text/BaseTextProps.h>
|
|
#include <react/core/Props.h>
|
|
#include <react/graphics/Color.h>
|
|
#include <react/graphics/Geometry.h>
|
|
|
|
#include <react/attributedstring/TextAttributes.h>
|
|
#include <react/attributedstring/conversions.h>
|
|
#include <react/components/view/ViewProps.h>
|
|
#include <react/core/propsConversions.h>
|
|
#include <react/graphics/Color.h>
|
|
#include <react/imagemanager/primitives.h>
|
|
#include <cinttypes>
|
|
#include <vector>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
struct AndroidTextInputSelectionStruct {
|
|
int start;
|
|
int end;
|
|
};
|
|
|
|
static inline void fromRawValue(
|
|
const RawValue &value,
|
|
AndroidTextInputSelectionStruct &result) {
|
|
auto map = (better::map<std::string, RawValue>)value;
|
|
|
|
auto start = map.find("start");
|
|
if (start != map.end()) {
|
|
fromRawValue(start->second, result.start);
|
|
}
|
|
auto end = map.find("end");
|
|
if (end != map.end()) {
|
|
fromRawValue(end->second, result.end);
|
|
}
|
|
}
|
|
|
|
static inline std::string toString(
|
|
const AndroidTextInputSelectionStruct &value) {
|
|
return "[Object AndroidTextInputSelectionStruct]";
|
|
}
|
|
|
|
struct AndroidTextInputTextShadowOffsetStruct {
|
|
double width;
|
|
double height;
|
|
};
|
|
|
|
static inline void fromRawValue(
|
|
const RawValue &value,
|
|
AndroidTextInputTextShadowOffsetStruct &result) {
|
|
auto map = (better::map<std::string, RawValue>)value;
|
|
|
|
auto width = map.find("width");
|
|
if (width != map.end()) {
|
|
fromRawValue(width->second, result.width);
|
|
}
|
|
auto height = map.find("height");
|
|
if (height != map.end()) {
|
|
fromRawValue(height->second, result.height);
|
|
}
|
|
}
|
|
|
|
static inline std::string toString(
|
|
const AndroidTextInputTextShadowOffsetStruct &value) {
|
|
return "[Object AndroidTextInputTextShadowOffsetStruct]";
|
|
}
|
|
|
|
#ifdef ANDROID
|
|
inline folly::dynamic toDynamic(
|
|
const AndroidTextInputTextShadowOffsetStruct &value) {
|
|
folly::dynamic dynamicValue = folly::dynamic::object();
|
|
dynamicValue["width"] = value.width;
|
|
dynamicValue["height"] = value.height;
|
|
return dynamicValue;
|
|
}
|
|
|
|
inline folly::dynamic toDynamic(const AndroidTextInputSelectionStruct &value) {
|
|
folly::dynamic dynamicValue = folly::dynamic::object();
|
|
dynamicValue["start"] = value.start;
|
|
dynamicValue["end"] = value.end;
|
|
return dynamicValue;
|
|
}
|
|
#endif
|
|
|
|
class AndroidTextInputProps final : public ViewProps {
|
|
public:
|
|
AndroidTextInputProps() = default;
|
|
AndroidTextInputProps(
|
|
const AndroidTextInputProps &sourceProps,
|
|
const RawProps &rawProps);
|
|
|
|
folly::dynamic getDynamic() const;
|
|
|
|
#pragma mark - Props
|
|
|
|
const std::string autoCompleteType{};
|
|
const std::string returnKeyLabel{};
|
|
const int numberOfLines{0};
|
|
const bool disableFullscreenUI{false};
|
|
const std::string textBreakStrategy{};
|
|
const SharedColor underlineColorAndroid{};
|
|
const std::string inlineImageLeft{};
|
|
const int inlineImagePadding{0};
|
|
const std::string importantForAutofill{};
|
|
const bool showSoftInputOnFocus{false};
|
|
const std::string autoCapitalize{};
|
|
const bool autoCorrect{false};
|
|
const bool autoFocus{false};
|
|
const bool allowFontScaling{false};
|
|
const Float maxFontSizeMultiplier{0.0};
|
|
const bool editable{false};
|
|
const std::string keyboardType{};
|
|
const std::string returnKeyType{};
|
|
const int maxLength{0};
|
|
const bool multiline{false};
|
|
const std::string placeholder{};
|
|
const SharedColor placeholderTextColor{};
|
|
const bool secureTextEntry{false};
|
|
const SharedColor selectionColor{};
|
|
const AndroidTextInputSelectionStruct selection{};
|
|
const std::string value{};
|
|
const std::string defaultValue{};
|
|
const bool selectTextOnFocus{false};
|
|
const bool blurOnSubmit{false};
|
|
const bool caretHidden{false};
|
|
const bool contextMenuHidden{false};
|
|
const SharedColor textShadowColor{};
|
|
const Float textShadowRadius{0.0};
|
|
const std::string textDecorationLine{};
|
|
const std::string fontStyle{};
|
|
const AndroidTextInputTextShadowOffsetStruct textShadowOffset{};
|
|
const Float lineHeight{0.0};
|
|
const std::string textTransform{};
|
|
const int color{0};
|
|
const Float letterSpacing{0.0};
|
|
const Float fontSize{0.0};
|
|
const std::string textAlign{};
|
|
const bool includeFontPadding{false};
|
|
const std::string fontWeight{};
|
|
const std::string fontFamily{};
|
|
const std::string textAlignVertical{};
|
|
const SharedColor cursorColor{};
|
|
const int mostRecentEventCount{0};
|
|
const std::string text{};
|
|
|
|
/**
|
|
* TextAttributes: see all BaseText. These attributes are not set
|
|
* directly; see convertRawProps.
|
|
*/
|
|
const TextAttributes textAttributes{};
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|