此接口在当前屏幕上方显示一个操作系统特有的警报。警报的外观由底层操作系统平台决定。某些平台甚至允许在应用程序不在前台时显示警报。
无法通过在其中嵌入 ReactXP 视图或使用 ReactXP 样式来定制警报。
interface AlertButtonSpec {
// Button text
text?: string;
// Invoked when button is pressed
onPress?: () => void;
// Alert style to use (supported on some platforms)
style?: 'default' | 'cancel' | 'destructive';
}
interface AlertModalTheme {
// Modal background style
bodyStyle?: StyleRuleSet<ViewStyle>;
// Style for title text
titleTextStyle?: StyleRuleSet<TextStyle>;
// Style for message text
messageTextStyle?: StyleRuleSet<TextStyle>;
// Style for button control
buttonStyle?: StyleRuleSet<ButtonStyle>;
// Style applied when hovering over button
buttonHoverStyle?: StyleRuleSet<ButtonStyle>;
// Style for button text
buttonTextStyle?: StyleRuleSet<TextStyle>;
// Override style for cancel button
cancelButtonStyle?: StyleRuleSet<ButtonStyle>;
// Override style for cancel button hover state
cancelButtonHoverStyle?: StyleRuleSet<ButtonStyle>;
// Override style for cancel button
cancelButtonTextStyle?: StyleRuleSet<TextStyle>;;
}
interface AlertOptions {
// Optional icon (web only)
icon?: string;
// Optional theme (web only)
theme?: AlertModalTheme;
// (Android, iOS, and Windows only)
// Optional: the id of the root view this alert is associated with.
// Defaults to the view set by UserInterface.setMainView().
rootViewId?: string;
// Optional: Prevent the dialog from being dismissed when pressing away from the dialog
preventDismissOnPress?: boolean;
}
// Displays an alert over the top of the current screen. Theming support is
// provided for web only and is ignored on other platforms.
show(title: string, message?: string, buttons? AlertButtonSpec[], options?: AlertOptions): void;