npm i --save nativescript-sweet-alert
- Version: 1.0.4
- GitHub: https://github.com/NazimMertBilgi/nativescript-sweet-alert
- NPM: https://www.npmjs.com/package/nativescript-sweet-alert
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
SweetAlert library for NativeScript Android.
Based on:
- Android F0RIS/sweet-alert-dialog
Install
NativeScript 6x
tns plugin add nativescript-sweet-alert
Android Specifications
Usage Examples
NOTE: "options" may vary according to each method.
import { SweetAlert } from 'nativescript-sweet-alert';
import { ShowSuccess , ShowError } from 'nativescript-sweet-alert/classes';
// showSuccess
const options: ShowSuccess = {
text: "Hello",
contentText: "Alert Content Text",
confirmButtonText: "Ok",
cancelButtonText: "Close"
}
SweetAlert.showSuccess(options).then(value => {
// result: true, false, CLOSED
});
// showError
const options: ShowError = {
text: "Hello",
contentText: "Alert Content Text",
confirmButtonText: "Ok",
cancelButtonText: "Close"
}
SweetAlert.showError(options).then(value => {
// result: true, false, CLOSED
});
NativeScript SweetAlert - Methods
showNormal(options: ShowNormal): Promise<any>
showError(options: ShowError): Promise<any>
showSuccess(options: ShowSuccess): Promise<any>
showWarning(options: ShowWarning): Promise<any>
showCustomImage(options: ShowCustomImage): Promise<any>
showText(options: ShowText): Promise<any>
showCheckbox(options: ShowCheckbox): Promise<any>
How can I change the colors?
App_Resources/Android/src/main/res/values/colors.xml add to Color Properties
Why the TNS prefixed name?
TNS
stands for Telerik NativeScript
iOS uses classes prefixed with NS
(stemming from the NeXTSTEP days of old):
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/
To avoid confusion with iOS native classes, TNS
is used instead.
Demo
Need extra help getting these SweetAlert working in your application? Check out these tutorials that make use of the plugin:
SweetAlert in a NativeScript Core Demo
SweetAlert in a NativeScript Angular Demo
License
MIT