Skip to content

Commit c9966e4

Browse files
Luna Weifacebook-github-bot
Luna Wei
authored andcommitted
Alert
Summary: Changelog: [Internal] Add flow declaration for Alert. Couldn't figure out how to do type statics on interfaces in Flow. Reviewed By: yungsters Differential Revision: D39186533 fbshipit-source-id: 928ee76080490a133c9773d2330473a688e0612d
1 parent 2aba352 commit c9966e4

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Libraries/Alert/Alert.js.flow

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow
9+
*/
10+
11+
export type AlertType =
12+
| 'default'
13+
| 'plain-text'
14+
| 'secure-text'
15+
| 'login-password';
16+
export type AlertButtonStyle = 'default' | 'cancel' | 'destructive';
17+
export type Buttons = Array<{
18+
text?: string,
19+
onPress?: ?Function,
20+
isPreferred?: boolean,
21+
style?: AlertButtonStyle,
22+
...
23+
}>;
24+
type Options = {
25+
cancelable?: ?boolean,
26+
userInterfaceStyle?: 'unspecified' | 'light' | 'dark',
27+
onDismiss?: ?() => void,
28+
...
29+
};
30+
31+
declare class Alert {
32+
static alert(
33+
title: ?string,
34+
message?: ?string,
35+
buttons?: Buttons,
36+
options?: Options,
37+
): void;
38+
static prompt(
39+
title: ?string,
40+
message?: ?string,
41+
callbackOrButtons?: ?(((text: string) => void) | Buttons),
42+
type?: ?AlertType,
43+
defaultValue?: string,
44+
keyboardType?: string,
45+
options?: Options,
46+
): void;
47+
}
48+
49+
module.exports = Alert;

0 commit comments

Comments
 (0)