Alert

Diese Schnittstelle zeigt eine OS-spezifische Warnung über dem aktuellen Bildschirm an. Das Erscheinungsbild der Warnung wird von der zugrunde liegenden OS-Plattform bestimmt. Einige Plattformen erlauben die Anzeige von Warnungen, auch wenn die App nicht im Vordergrund läuft.

Es gibt keine Möglichkeit, die Warnung anzupassen, indem ReactXP-Ansichten darin eingebettet oder ReactXP-Stile verwendet werden.

Typen

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;
}

Methoden

// 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;