mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Refine Keyboard API Event typings (#23272)
Summary: - Improve type inference of the `event.easing` keyboard event property with the `KeyboardEventEasing` type. - Exporting `KeyboardEventName` and `KeyboardEventEasing` for others to use. - Removing unnecessary optional property flag (ie.`?`) for all properties in `KeyboardEvent`. (I personally haven't seen any of the properties not being returned for all keyboard events). [iOS] [Changed] - Refine Keyboard API Event typings Pull Request resolved: https://github.com/facebook/react-native/pull/23272 Differential Revision: D13941758 Pulled By: cpojer fbshipit-source-id: 4891898c29cf6963069dbe6b4d439694761fd9e7
This commit is contained in:
committed by
Facebook Github Bot
parent
2aa2401766
commit
7ee13cc84c
@@ -17,7 +17,7 @@ const KeyboardObserver = require('NativeModules').KeyboardObserver;
|
||||
const dismissKeyboard = require('dismissKeyboard');
|
||||
const KeyboardEventEmitter = new NativeEventEmitter(KeyboardObserver);
|
||||
|
||||
type KeyboardEventName =
|
||||
export type KeyboardEventName =
|
||||
| 'keyboardWillShow'
|
||||
| 'keyboardDidShow'
|
||||
| 'keyboardWillHide'
|
||||
@@ -25,6 +25,13 @@ type KeyboardEventName =
|
||||
| 'keyboardWillChangeFrame'
|
||||
| 'keyboardDidChangeFrame';
|
||||
|
||||
export type KeyboardEventEasing =
|
||||
| 'easeIn'
|
||||
| 'easeInEaseOut'
|
||||
| 'easeOut'
|
||||
| 'linear'
|
||||
| 'keyboard';
|
||||
|
||||
type ScreenRect = $ReadOnly<{|
|
||||
screenX: number,
|
||||
screenY: number,
|
||||
@@ -33,11 +40,11 @@ type ScreenRect = $ReadOnly<{|
|
||||
|}>;
|
||||
|
||||
export type KeyboardEvent = $ReadOnly<{|
|
||||
duration?: number,
|
||||
easing?: string,
|
||||
duration: number,
|
||||
easing: KeyboardEventEasing,
|
||||
endCoordinates: ScreenRect,
|
||||
startCoordinates?: ScreenRect,
|
||||
isEventFromThisApp?: boolean,
|
||||
startCoordinates: ScreenRect,
|
||||
isEventFromThisApp: boolean,
|
||||
|}>;
|
||||
|
||||
type KeyboardEventListener = (e: KeyboardEvent) => void;
|
||||
|
||||
Reference in New Issue
Block a user