From 4dd93582b6b2aa6a1a219c1e8f5d613744e258c7 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Wed, 22 Jan 2020 14:10:16 -0800 Subject: [PATCH] Add a hand-written JS view config for AndroidTextInput Summary: Hand-writing a JS view config for AndroidTextInputNativeComponent. This diff was generated by adding logging to `getNativeComponentAttributes`. Diff preview: https://our.intern.facebook.com/intern/diff/view-version/96875488/ Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D19456328 fbshipit-source-id: b2d5abd2fde380be182b95881c335d24481343f1 --- .../AndroidTextInputNativeComponent.js | 19 ++++- .../TextInput/AndroidTextInputViewConfig.js | 84 +++++++++++++++++++ 2 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 Libraries/Components/TextInput/AndroidTextInputViewConfig.js diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index c14b13ea10a..09b88e8e96c 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -25,6 +25,8 @@ import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import requireNativeComponent from '../../ReactNative/requireNativeComponent'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import * as React from 'react'; +import AndroidTextInputViewConfig from './AndroidTextInputViewConfig'; +const ReactNativeViewConfigRegistry = require('../../Renderer/shims/ReactNativeViewConfigRegistry'); export type KeyboardType = // Cross Platform @@ -563,8 +565,17 @@ export const Commands: NativeCommands = codegenNativeCommands({ ], }); -const AndroidTextInputNativeComponent: HostComponent = requireNativeComponent( - 'AndroidTextInput', -); +let AndroidTextInputNativeComponent; +if (global.RN$Bridgeless) { + ReactNativeViewConfigRegistry.register('AndroidTextInput', () => { + return AndroidTextInputViewConfig; + }); + AndroidTextInputNativeComponent = 'AndroidTextInput'; +} else { + AndroidTextInputNativeComponent = requireNativeComponent( + 'AndroidTextInput', + ); +} -export default AndroidTextInputNativeComponent; +// flowlint-next-line unclear-type:off +export default ((AndroidTextInputNativeComponent: any): HostComponent); diff --git a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js new file mode 100644 index 00000000000..c4a43a77339 --- /dev/null +++ b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js @@ -0,0 +1,84 @@ +/** + * 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. + * + * @flow strict-local + * @format + */ + +'use strict'; + +import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig'; +import type {ReactNativeBaseComponentViewConfig} from '../../Renderer/shims/ReactNativeTypes'; + +const AndroidTextInputViewConfig = { + uiViewClassName: 'AndroidTextInput', + bubblingEventTypes: { + topTextInput: { + phasedRegistrationNames: { + bubbled: 'onTextInput', + captured: 'onTextInputCapture', + }, + }, + }, + directEventTypes: {}, + validAttributes: { + ...ReactNativeViewViewConfig.validAttributes, + + maxFontSizeMultiplier: true, + placeholder: true, + inlineImagePadding: true, + contextMenuHidden: true, + textShadowColor: {process: require('../../StyleSheet/processColor')}, + maxLength: true, + selectTextOnFocus: true, + textShadowRadius: true, + underlineColorAndroid: {process: require('../../StyleSheet/processColor')}, + textDecorationLine: true, + blurOnSubmit: true, + textAlignVertical: true, + fontStyle: true, + textShadowOffset: true, + selectionColor: {process: require('../../StyleSheet/processColor')}, + selection: true, + placeholderTextColor: {process: require('../../StyleSheet/processColor')}, + importantForAutofill: true, + lineHeight: true, + textTransform: true, + returnKeyType: true, + keyboardType: true, + multiline: true, + color: true, + autoCompleteType: true, + numberOfLines: true, + letterSpacing: true, + returnKeyLabel: true, + fontSize: true, + onKeyPress: true, + cursorColor: {process: require('../../StyleSheet/processColor')}, + text: true, + showSoftInputOnFocus: true, + textAlign: true, + autoCapitalize: true, + autoCorrect: true, + caretHidden: true, + secureTextEntry: true, + textBreakStrategy: true, + onScroll: true, + onContentSizeChange: true, + disableFullscreenUI: true, + includeFontPadding: true, + fontWeight: true, + fontFamily: true, + allowFontScaling: true, + onSelectionChange: true, + mostRecentEventCount: true, + inlineImageLeft: true, + editable: true, + fontVariant: true, + }, +}; + +module.exports = (AndroidTextInputViewConfig: ReactNativeBaseComponentViewConfig<>);