Update Keyboard, Alert TS Types

Summary: Changelog: [Internal] - Update changes to Keyboard, Alert from differences in those files from https://github.com/facebook/react-native/compare/0.70-stable...main

Reviewed By: NickGerleman

Differential Revision: D39629997

fbshipit-source-id: 85bb91d00a165e708dbf4e32d7f37ce8a6c02a72
This commit is contained in:
Luna Wei 2022-09-19 14:56:36 -07:00 коммит произвёл Facebook GitHub Bot
Родитель e2a446694f
Коммит c5217f199d
2 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -1066,6 +1066,7 @@ Alert.prompt(
}, },
{ {
text: 'OK', text: 'OK',
isPreferred: true,
onPress: password => console.log('OK Pressed, password: ' + password), onPress: password => console.log('OK Pressed, password: ' + password),
}, },
], ],
@ -1661,6 +1662,9 @@ const KeyboardTest = () => {
startCoordinates: {screenX: 0, screenY: 0, width: 0, height: 0}, startCoordinates: {screenX: 0, screenY: 0, width: 0, height: 0},
isEventFromThisApp: true, isEventFromThisApp: true,
}); });
if (Keyboard.isVisible()) {
Keyboard.metrics();
}
}; };
const PermissionsAndroidTest = () => { const PermissionsAndroidTest = () => {

17
types/index.d.ts поставляемый
Просмотреть файл

@ -7799,6 +7799,7 @@ export interface AccessibilityInfoStatic {
export interface AlertButton { export interface AlertButton {
text?: string | undefined; text?: string | undefined;
onPress?: ((value?: string) => void) | undefined; onPress?: ((value?: string) => void) | undefined;
isPreferred?: boolean;
style?: 'default' | 'cancel' | 'destructive' | undefined; style?: 'default' | 'cancel' | 'destructive' | undefined;
} }
@ -10194,7 +10195,7 @@ export type KeyboardEventEasing =
| 'linear' | 'linear'
| 'keyboard'; | 'keyboard';
type ScreenRect = { type KeyboardMetrics = {
screenX: number; screenX: number;
screenY: number; screenY: number;
width: number; width: number;
@ -10205,7 +10206,7 @@ interface KeyboardEventIOS {
/** /**
* @platform ios * @platform ios
*/ */
startCoordinates: ScreenRect; startCoordinates: KeyboardMetrics;
/** /**
* @platform ios * @platform ios
*/ */
@ -10221,7 +10222,7 @@ export interface KeyboardEvent extends Partial<KeyboardEventIOS> {
* Always set to "keyboard" on Android. * Always set to "keyboard" on Android.
*/ */
easing: KeyboardEventEasing; easing: KeyboardEventEasing;
endCoordinates: ScreenRect; endCoordinates: KeyboardMetrics;
} }
type KeyboardEventListener = (event: KeyboardEvent) => void; type KeyboardEventListener = (event: KeyboardEvent) => void;
@ -10263,6 +10264,16 @@ export interface KeyboardStatic extends NativeEventEmitter {
* position changes with keyboard movements. * position changes with keyboard movements.
*/ */
scheduleLayoutAnimation: (event: KeyboardEvent) => void; scheduleLayoutAnimation: (event: KeyboardEvent) => void;
/**
* Whether the keyboard is last known to be visible.
*/
isVisible(): boolean;
/**
* Return the metrics of the soft-keyboard if visible.
*/
metrics(): KeyboardMetrics | undefined;
} }
/** /**