Skip to content

Commit

Permalink
Update Keyboard, Alert TS Types
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal] - Update changes to Keyboard, Alert from differences in those files from 0.70-stable...main

Reviewed By: NickGerleman

Differential Revision: D39629997

fbshipit-source-id: 85bb91d00a165e708dbf4e32d7f37ce8a6c02a72
  • Loading branch information
Luna Wei authored and facebook-github-bot committed Sep 19, 2022
1 parent e2a4466 commit c5217f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions types/__typetests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,7 @@ Alert.prompt(
},
{
text: 'OK',
isPreferred: true,
onPress: password => console.log('OK Pressed, password: ' + password),
},
],
Expand Down Expand Up @@ -1661,6 +1662,9 @@ const KeyboardTest = () => {
startCoordinates: {screenX: 0, screenY: 0, width: 0, height: 0},
isEventFromThisApp: true,
});
if (Keyboard.isVisible()) {
Keyboard.metrics();
}
};

const PermissionsAndroidTest = () => {
Expand Down
17 changes: 14 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7799,6 +7799,7 @@ export interface AccessibilityInfoStatic {
export interface AlertButton {
text?: string | undefined;
onPress?: ((value?: string) => void) | undefined;
isPreferred?: boolean;
style?: 'default' | 'cancel' | 'destructive' | undefined;
}

Expand Down Expand Up @@ -10194,7 +10195,7 @@ export type KeyboardEventEasing =
| 'linear'
| 'keyboard';

type ScreenRect = {
type KeyboardMetrics = {
screenX: number;
screenY: number;
width: number;
Expand All @@ -10205,7 +10206,7 @@ interface KeyboardEventIOS {
/**
* @platform ios
*/
startCoordinates: ScreenRect;
startCoordinates: KeyboardMetrics;
/**
* @platform ios
*/
Expand All @@ -10221,7 +10222,7 @@ export interface KeyboardEvent extends Partial<KeyboardEventIOS> {
* Always set to "keyboard" on Android.
*/
easing: KeyboardEventEasing;
endCoordinates: ScreenRect;
endCoordinates: KeyboardMetrics;
}

type KeyboardEventListener = (event: KeyboardEvent) => void;
Expand Down Expand Up @@ -10263,6 +10264,16 @@ export interface KeyboardStatic extends NativeEventEmitter {
* position changes with keyboard movements.
*/
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;
}

/**
Expand Down

0 comments on commit c5217f1

Please sign in to comment.