mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
[react-native] Enhance Keyboard API Event typings
This commit is contained in:
Vendored
+37
@@ -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;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user