From 4cdafd997a08d808331d54be93ba5b9e2e6d4bc7 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Jan 2021 14:01:50 -0800 Subject: [PATCH] Add supoprt for Text Input view configs Summary: This diff adds TextInput in the list of components that support static view configs changelog: [internal] Reviewed By: yungsters Differential Revision: D26040854 fbshipit-source-id: d6b5d3a78ef4657acf3f2c4ebe527ad4ca40bcb5 --- .../AndroidTextInputNativeComponent.js | 17 +++++------------ .../TextInput/AndroidTextInputViewConfig.js | 9 ++++++--- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index dffccc428ff..9568442adf4 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -26,7 +26,7 @@ import requireNativeComponent from '../../ReactNative/requireNativeComponent'; import codegenNativeCommands from '../../Utilities/codegenNativeCommands'; import type {TextInputNativeCommands} from './TextInputNativeCommands'; import AndroidTextInputViewConfig from './AndroidTextInputViewConfig'; -const ReactNativeViewConfigRegistry = require('../../Renderer/shims/ReactNativeViewConfigRegistry'); +import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry'; export type KeyboardType = // Cross Platform @@ -545,17 +545,10 @@ export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['focus', 'blur', 'setTextAndSelection'], }); -let AndroidTextInputNativeComponent; -if (global.RN$Bridgeless) { - ReactNativeViewConfigRegistry.register('AndroidTextInput', () => { - return AndroidTextInputViewConfig; - }); - AndroidTextInputNativeComponent = 'AndroidTextInput'; -} else { - AndroidTextInputNativeComponent = requireNativeComponent( - 'AndroidTextInput', - ); -} +let AndroidTextInputNativeComponent = NativeComponentRegistry.get( + 'AndroidTextInput', + () => AndroidTextInputViewConfig, +); // 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 index 170a81526dc..553911491b1 100644 --- a/Libraries/Components/TextInput/AndroidTextInputViewConfig.js +++ b/Libraries/Components/TextInput/AndroidTextInputViewConfig.js @@ -11,7 +11,7 @@ 'use strict'; import ReactNativeViewViewConfig from '../../Components/View/ReactNativeViewViewConfig'; -import {type ViewConfig} from '../../Renderer/shims/ReactNativeTypes'; +import {type PartialViewConfig} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes'; const AndroidTextInputViewConfig = { uiViewClassName: 'AndroidTextInput', @@ -58,6 +58,9 @@ const AndroidTextInputViewConfig = { ...ReactNativeViewViewConfig.validAttributes, maxFontSizeMultiplier: true, + adjustsFontSizeToFit: true, + minimumFontScale: true, + autoFocus: true, placeholder: true, inlineImagePadding: true, contextMenuHidden: true, @@ -80,7 +83,7 @@ const AndroidTextInputViewConfig = { returnKeyType: true, keyboardType: true, multiline: true, - color: true, + color: {process: require('../../StyleSheet/processColor')}, autoCompleteType: true, numberOfLines: true, letterSpacing: true, @@ -111,4 +114,4 @@ const AndroidTextInputViewConfig = { }, }; -module.exports = (AndroidTextInputViewConfig: ViewConfig); +module.exports = (AndroidTextInputViewConfig: PartialViewConfig);