Skip to content

Commit

Permalink
Add a hand-written JS view config for AndroidTextInput
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Emily Janzer authored and facebook-github-bot committed Jan 22, 2020
1 parent 6871416 commit 4dd9358
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -563,8 +565,17 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
],
});

const AndroidTextInputNativeComponent: HostComponent<NativeProps> = requireNativeComponent<NativeProps>(
'AndroidTextInput',
);
let AndroidTextInputNativeComponent;
if (global.RN$Bridgeless) {
ReactNativeViewConfigRegistry.register('AndroidTextInput', () => {
return AndroidTextInputViewConfig;
});
AndroidTextInputNativeComponent = 'AndroidTextInput';
} else {
AndroidTextInputNativeComponent = requireNativeComponent<NativeProps>(
'AndroidTextInput',
);
}

export default AndroidTextInputNativeComponent;
// flowlint-next-line unclear-type:off
export default ((AndroidTextInputNativeComponent: any): HostComponent<NativeProps>);
84 changes: 84 additions & 0 deletions Libraries/Components/TextInput/AndroidTextInputViewConfig.js
Original file line number Diff line number Diff line change
@@ -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<>);

0 comments on commit 4dd9358

Please sign in to comment.