From fd95437bd068594744ac3a62e40e148656a56328 Mon Sep 17 00:00:00 2001 From: nossbigg Date: Sat, 2 Feb 2019 23:57:36 +0800 Subject: [PATCH] Refine Keyboard API Event typings --- Libraries/Components/Keyboard/Keyboard.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index 6930a0578fbc12..3a89f8b6101eb6 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -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;