mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
AndroidTextInput: support using commands instead of setNativeProps (native change)
Summary: In AndroidTextInput, support codegen'd ViewCommands in native and add three commands that will eventually replace usage of setNativeProps on Android. TextInput will use these commands in a future diff. Changelog: [Internal] Reviewed By: TheSavior Differential Revision: D18612150 fbshipit-source-id: 5d427040686e8c5ab504dd845bc8ef863f558c35
This commit is contained in:
committed by
Facebook Github Bot
parent
98b8a17645
commit
7ab5eb4caf
@@ -18,11 +18,13 @@ import type {
|
||||
Float,
|
||||
Int32,
|
||||
WithDefault,
|
||||
} from 'react-native/Libraries/Types/CodegenTypes';
|
||||
} from '../../Types/CodegenTypes';
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import type {TextStyleProp, ViewStyleProp} from '../../StyleSheet/StyleSheet';
|
||||
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
|
||||
import {requireNativeComponent} from 'react-native';
|
||||
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
|
||||
import * as React from 'react';
|
||||
|
||||
export type KeyboardType =
|
||||
// Cross Platform
|
||||
@@ -534,6 +536,33 @@ export type NativeProps = $ReadOnly<{|
|
||||
text?: ?string,
|
||||
|}>;
|
||||
|
||||
type NativeType = HostComponent<NativeProps>;
|
||||
|
||||
interface NativeCommands {
|
||||
+focus: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
+blur: (viewRef: React.ElementRef<NativeType>) => void;
|
||||
+setMostRecentEventCount: (
|
||||
viewRef: React.ElementRef<NativeType>,
|
||||
eventCount: Int32,
|
||||
) => void;
|
||||
+setTextAndSelection: (
|
||||
viewRef: React.ElementRef<NativeType>,
|
||||
mostRecentEventCount: Int32,
|
||||
value: ?string, // in theory this is nullable
|
||||
start: Int32,
|
||||
end: Int32,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: [
|
||||
'focus',
|
||||
'blur',
|
||||
'setMostRecentEventCount',
|
||||
'setTextAndSelection',
|
||||
],
|
||||
});
|
||||
|
||||
const AndroidTextInputNativeComponent: HostComponent<NativeProps> = requireNativeComponent<NativeProps>(
|
||||
'AndroidTextInput',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user