[react-native] Enhance Keyboard API Event typings

This commit is contained in:
nossbigg
2019-02-05 08:19:00 +08:00
parent 1657e8649f
commit ce19f8a19b
2 changed files with 43 additions and 0 deletions
+37
View File
@@ -16,6 +16,7 @@
// Kacper Wiszczuk <https://github.com/esemesek>
// Ryan Nickel <https://github.com/mrnickel>
// Souvik Ghosh <https://github.com/souvik-ghosh>
// Cheng Gibson <https://github.com/nossbigg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -8995,8 +8996,44 @@ export interface ARTStatic {
Text: typeof ARTText;
}
export type KeyboardEventName =
| "keyboardWillShow"
| "keyboardDidShow"
| "keyboardWillHide"
| "keyboardDidHide"
| "keyboardWillChangeFrame"
| "keyboardDidChangeFrame";
export type KeyboardEventEasing =
| "easeIn"
| "easeInEaseOut"
| "easeOut"
| "linear"
| "keyboard";
type ScreenRect = {
screenX: number;
screenY: number;
width: number;
height: number;
};
export interface KeyboardEvent {
duration: number;
easing: KeyboardEventEasing;
endCoordinates: ScreenRect;
startCoordinates: ScreenRect;
isEventFromThisApp: boolean;
}
type KeyboardEventListener = (event: KeyboardEvent) => void;
export interface KeyboardStatic extends NativeEventEmitter {
dismiss: () => void;
addListener(
eventType: KeyboardEventName,
listener: KeyboardEventListener
): EmitterSubscription;
}
//////////////////////////////////////////////////////////////////////////
+6
View File
@@ -85,6 +85,7 @@ import {
DatePickerAndroid,
ViewPropTypes,
requireNativeComponent,
Keyboard,
} from "react-native";
declare module "react-native" {
@@ -843,3 +844,8 @@ const ShareTest = () => {
}
});
};
const KeyboardTest = () => {
const subscriber = Keyboard.addListener("keyboardDidHide", (event) => {event});
subscriber.remove();
}