1.0.16 • Published 3 years ago

nativescript-cfalert-dialog v1.0.16

Weekly downloads
30
License
Apache-2.0
Repository
github
Last release
3 years ago

nativescript-cfalert-dialog npm

Twitter URL Twitter URL

NPM

This plugin is a wrapper around CFAlertDialog for Android and CFAlertViewController.

Screenshots

Android

iOS

Installation

tns plugin add nativescript-cfalert-dialog

Configuration

no configuration step involved

Usage

NativeScript Core with { TypeScript } (works on Core, Angular and Vue as well)

import { CFAlertDialog,
         DialogOptions,
         CFAlertGravity,
         CFAlertActionAlignment,
         CFAlertActionStyle,
         CFAlertStyle } from 'nativescript-cfalert-dialog';

let cfalertDialog = new CFAlertDialog();

let options: DialogOptions = {
      // Options go here
      dialogStyle: CFAlertStyle.ALERT,
      title: "This is cool!",
    }

cfalertDialog.show(options); // That's about it ;)

API

show(options): Promise<string>;

Shows the CFAlert Dialog based on the options provided. It returns a promise which can either resolve with a button title (if button was clicked), or it can resolve empty (undefined).

dismiss(animate:boolean): void;

Dismiss the CFAlert Dialog (animate option effective on iOS only)

Options format

// Everything that has '?' is optional
export interface DialogOptions {
    dialogStyle: CFAlertStyle;
    title: string;
    titleColor?: string,
    message?: string;
    messageColor?: string;
    textColor?: string;
    textAlignment?: CFAlertGravity;
    backgroundColor?: string,
    backgroundBlur?: string, // iOS only
    cancellable?: boolean,
    headerView?: any, // nativeView
    footerView?: any, // nativeView
    onDismiss?: Function, // calback for dismiss, function (dialog)
    buttons?: [{
        text: string, // title
        buttonStyle: CFAlertActionStyle,
        buttonAlignment?: CFAlertActionAlignment,
        textColor?: string,
        backgroundColor?: string,
        onClick: Function // function (buttonName)
    }],    
    simpleList?: { // android only
        items: [string],
        onClick: Function // function(dialogInterface, index)
    },
    singleChoiceList?: { // android only
        items: [string],
        selectedItem: number,
        onClick: Function // function(dialogInterface, index)
    },
    multiChoiceList?: { // android only
        items: [string],
        selectedItems: [boolean], // should have same number of elements as 'items'
        onClick: Function // function (dialogInterface, index, b)
    }
}

License

Apache License Version 2.0, January 2004

1.0.16

3 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago