Since

0.1

AlertView is an alert box with buttons having custom behaviors. You can use AlertView for informing user or asking for confirmations. AlertView has buttons with callbacks that you can take action for each of them separately.

Example

import AlertView from '@smartface/native/ui/alertview';

const myAlertView = new AlertView({
title: "Alert Title",
message: "Alert Message"
});
myAlertView.addButton({
type: AlertView.Android.ButtonType.NEGATIVE,
text: "Cancel"
});
myAlertView.addButton({
type: AlertView.Android.ButtonType.POSITIVE,
text: "Okay",
onClick: () => {
console.log("Okay clicked.");
}
});

myAlertView.show();

Hierarchy

Implemented by

Properties

nativeObject: { [key: string]: any }

Type declaration

  • [key: string]: any
ios: Partial<{}>
android: Partial<IAlertViewAndroidProps>
title: string

Gets/sets title of AlertView.

Android

Ios

Since

0.1

message: string

Gets/sets message of AlertView.

Android

Ios

Since

0.1

onDismiss: ((alertView?: IAlertView) => void)

Type declaration

    • (alertView?: IAlertView): void
    • Gets/sets dismiss callback function.

      Example

      myAlertView.onDismiss = (alertView) =>  {
      console.log("Dismissed alert view with title: " + alertView.title);
      };

      Android

      Ios

      Since

      0.1

      Parameters

      • Optional alertView: IAlertView

        Dismissed AlertView object

      Returns void

textBoxes: { text: string }[]

Returns object which contains text of added TextBox

Android

Ios

Since

4.1.2

Methods

  • Readonly

    Gets showing status of AlertView. It is set to true if AlertView is currently displayed on screen, false otherwise.

    Property

    Android

    Ios

    Since

    0.1

    Returns void

  • Shows AlertView on the screen with specified properties, isShowing property set to true after this operation.

    Method

    show

    Android

    Ios

    Since

    0.1

    Returns void

  • Returns string

  • Dismisses the AlertView, isShowing property set to false after this operation.

    Android

    Ios

    Since

    0.1

    Returns void

  • Allows you to add button to AlertView. You can add maximum 3 buttons on Android platform, on iOS there is no limitation.

    Example

    myAlertView.addButton({
    type: AlertView.Android.ButtonType.POSITIVE,
    text: "Okay",
    onClick: function() {
    console.log("Okay clicked.");
    }
    });

    Android

    Ios

    Since

    0.1

    Parameters

    • params: { type: ButtonType; text: string; onClick: (() => void); index?: number }
      • type: ButtonType
      • text: string
      • onClick: (() => void)
          • (): void
          • Returns void

      • Optional index?: number

    Returns void

  • Allows to add TextBox to AlertView. In iOS, maximum two textbox can be added. It is not applied to Android but 2 textboxes recommended.

    Example

    myAlertView.addTextBox({
    text: "Hello!",
    hint: "Hint!",
    isPassword: false,
    android: {
    viewSpacings: { left: 50, right: 50 }
    }
    });

    Android

    Ios

    Since

    4.1.2

    Parameters

    • params: { text: string; hint: string; isPassword: boolean; keyboardType?: number; android: Partial<{ width: number; height: number; viewSpacings: { left: number; top: number; right: number; bottom: number } }> }
      • text: string
      • hint: string
      • isPassword: boolean
      • Optional keyboardType?: number
      • android: Partial<{ width: number; height: number; viewSpacings: { left: number; top: number; right: number; bottom: number } }>

    Returns void

Generated using TypeDoc