New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-cfalert-dialog

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-cfalert-dialog - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

10

cfalert-dialog.android.d.ts

@@ -45,7 +45,7 @@ export declare enum CFAlertStyle {

simpleList?: {
items: [string];
items: string[];
onClick: Function;
};
singleChoiceList?: {
items: [string];
items: string[];
selectedItem: number;

@@ -55,4 +55,4 @@ onClick: Function;

multiChoiceList?: {
items: [string];
selectedItems: [boolean];
items: string[];
selectedItems: boolean[];
onClick: Function;

@@ -62,3 +62,5 @@ };

export declare class CFAlertDialog {
private _alertDialog;
show(options: DialogOptions): void;
dismiss(animated: boolean): void;
}

70

cfalert-dialog.android.js

@@ -56,2 +56,6 @@ "use strict";

}());
var DEFAULT_DIALOG_OPTIONS = {
dialogStyle: alertStyle,
cancellable: true,
};
var CFAlertDialog = (function () {

@@ -61,6 +65,3 @@ function CFAlertDialog() {

CFAlertDialog.prototype.show = function (options) {
options = options || {
title: "Hello World",
dialogStyle: alertStyle
};
options = Object.assign({}, DEFAULT_DIALOG_OPTIONS, options);
var builder = new Builder(app.android.foregroundActivity);

@@ -70,39 +71,26 @@ if (typeof options.dialogStyle !== undefined) {

}
if (options.title) {
if (options.title)
builder.setTitle(options.title);
}
if (options.message) {
if (options.message)
builder.setMessage(options.message);
}
if (options.textAlignment !== undefined) {
if (options.textAlignment !== undefined)
builder.setTextGravity(gravity[options.textAlignment]);
}
if (options.backgroundColor) {
if (options.backgroundColor)
builder.setBackgroundColor(new color_1.Color(options.backgroundColor).android);
}
if (options.textColor) {
if (options.textColor)
builder.setTextColor(new color_1.Color(options.textColor).android);
}
if (options.cancellable !== undefined) {
builder.setCancelable(options.cancellable);
}
if (options.headerView) {
builder.setCancelable(options.cancellable);
if (options.headerView)
builder.setHeaderView(options.headerView);
}
if (options.footerView) {
if (options.footerView)
builder.setFooterView(options.footerView);
}
if (options.buttons) {
var _loop_1 = function (i) {
var button = options.buttons[i];
builder.addButton(button.text, -1, -1, actionStyles[button.buttonStyle], alignment[button.buttonAlignment], new android.content.DialogInterface.OnClickListener({
options.buttons.forEach(function (button) {
builder.addButton(button.text, button.textColor ? new color_1.Color(button.textColor).android : -1, button.backgroundColor ? new color_1.Color(button.backgroundColor).android : -1, actionStyles[button.buttonStyle], alignment[button.buttonAlignment], new android.content.DialogInterface.OnClickListener({
onClick: function (dialog, which) {
button.onClick(button.text);
dialog.dismiss();
}
},
}));
};
for (var i = 0; i < options.buttons.length; i++) {
_loop_1(i);
}
});
}

@@ -114,3 +102,3 @@ if (options.simpleList) {

dialogInterface.dismiss();
}
},
}));

@@ -122,3 +110,3 @@ }

options.singleChoiceList.onClick(dialogInterface, index);
}
},
}));

@@ -130,20 +118,28 @@ }

options.multiChoiceList.onClick(dialogInterface, index, b);
}
},
}));
}
var alertDialog = builder.show();
this._alertDialog = builder.show();
if (options.titleColor) {
alertDialog.setTitleColor(new color_1.Color(options.titleColor).android);
this._alertDialog.setTitleColor(new color_1.Color(options.titleColor).android);
}
if (options.messageColor) {
alertDialog.setMessageColor(new color_1.Color(options.messageColor).android);
this._alertDialog.setMessageColor(new color_1.Color(options.messageColor).android);
}
if (options.onDismiss) {
alertDialog.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({
this._alertDialog.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({
onDismiss: function () {
options.onDismiss();
}
},
}));
}
};
CFAlertDialog.prototype.dismiss = function (animated) {
if (!this._alertDialog)
return;
try {
this._alertDialog.dismiss();
}
catch (e) { }
};
return CFAlertDialog;

@@ -150,0 +146,0 @@ }());

export declare enum CFAlertStyle {
NOTIFICATION = 2,
ALERT = 0,
BOTTOM_SHEET = 1,
NOTIFICATION = 2,
}
export declare enum CFAlertActionStyle {
POSITIVE = 0,
DEFAULT = 1,
NEGATIVE = 2,
POSITIVE = 0,
}
export declare enum CFAlertActionAlignment {
JUSTIFIED = 0,
END = 1,
START = 2,
END = 1,
CENTER = 3,
JUSTIFIED = 0,
}

@@ -49,3 +49,6 @@ export declare enum CFAlertGravity {

export declare class CFAlertDialog {
private _alertController;
show(options: DialogOptions): void;
dismiss(animated: boolean): void;
private _addActions(buttons?);
}

@@ -7,18 +7,18 @@ "use strict";

(function (CFAlertStyle) {
CFAlertStyle[CFAlertStyle["NOTIFICATION"] = 2] = "NOTIFICATION";
CFAlertStyle[CFAlertStyle["ALERT"] = 0] = "ALERT";
CFAlertStyle[CFAlertStyle["BOTTOM_SHEET"] = 1] = "BOTTOM_SHEET";
CFAlertStyle[CFAlertStyle["NOTIFICATION"] = 2] = "NOTIFICATION";
})(CFAlertStyle = exports.CFAlertStyle || (exports.CFAlertStyle = {}));
var CFAlertActionStyle;
(function (CFAlertActionStyle) {
CFAlertActionStyle[CFAlertActionStyle["POSITIVE"] = 0] = "POSITIVE";
CFAlertActionStyle[CFAlertActionStyle["DEFAULT"] = 1] = "DEFAULT";
CFAlertActionStyle[CFAlertActionStyle["NEGATIVE"] = 2] = "NEGATIVE";
CFAlertActionStyle[CFAlertActionStyle["POSITIVE"] = 0] = "POSITIVE";
})(CFAlertActionStyle = exports.CFAlertActionStyle || (exports.CFAlertActionStyle = {}));
var CFAlertActionAlignment;
(function (CFAlertActionAlignment) {
CFAlertActionAlignment[CFAlertActionAlignment["JUSTIFIED"] = 0] = "JUSTIFIED";
CFAlertActionAlignment[CFAlertActionAlignment["END"] = 1] = "END";
CFAlertActionAlignment[CFAlertActionAlignment["START"] = 2] = "START";
CFAlertActionAlignment[CFAlertActionAlignment["END"] = 1] = "END";
CFAlertActionAlignment[CFAlertActionAlignment["CENTER"] = 3] = "CENTER";
CFAlertActionAlignment[CFAlertActionAlignment["JUSTIFIED"] = 0] = "JUSTIFIED";
})(CFAlertActionAlignment = exports.CFAlertActionAlignment || (exports.CFAlertActionAlignment = {}));

@@ -31,2 +31,9 @@ var CFAlertGravity;

})(CFAlertGravity = exports.CFAlertGravity || (exports.CFAlertGravity = {}));
var DEFAULT_DIALOG_OPTIONS = {
dialogStyle: CFAlertStyle.ALERT,
title: 'Hello world!',
titleColor: 'black',
messageColor: 'black',
cancellable: true,
};
var CFAlertDialog = (function () {

@@ -36,57 +43,46 @@ function CFAlertDialog() {

CFAlertDialog.prototype.show = function (options) {
if (options.simpleList ||
options.singleChoiceList ||
options.multiChoiceList) {
alert("Lists are not available on iOS.");
return;
if (options.simpleList || options.singleChoiceList || options.multiChoiceList) {
return alert('Lists are not available on iOS.');
}
if (!options.dialogStyle)
options.dialogStyle = CFAlertStyle.ALERT;
if (!options.title)
options.title = "Hello world!";
if (!options.titleColor) {
options.titleColor = new color_1.Color("black").ios;
}
else {
options.titleColor = new color_1.Color(options.titleColor).ios;
}
if (options.messageColor)
options.messageColor = new color_1.Color(options.messageColor).ios;
options = Object.assign({}, DEFAULT_DIALOG_OPTIONS, options);
options.titleColor = new color_1.Color(options.titleColor).ios;
options.messageColor = new color_1.Color(options.messageColor).ios;
if (typeof options.textAlignment === undefined)
options.textAlignment = CFAlertGravity.START;
var viewController = frame.topmost().currentPage.ios;
var alertController = CFAlertViewController.alloc().initWithTitleTitleColorMessageMessageColorTextAlignmentPreferredStyleHeaderViewFooterViewDidDismissAlertHandler(options.title, options.titleColor, options.message, options.messageColor, options.textAlignment, options.dialogStyle, options.headerView, options.footerView, function () {
this._alertController = CFAlertViewController.alloc().initWithTitleTitleColorMessageMessageColorTextAlignmentPreferredStyleHeaderViewFooterViewDidDismissAlertHandler(options.title, options.titleColor, options.message, options.messageColor, options.textAlignment, options.dialogStyle, options.headerView, options.footerView, function () {
if (options.onDismiss)
options.onDismiss();
});
if (options.backgroundBlur) {
alertController.backgroundStyle =
CFAlertControllerBackgroundStyle.Blur;
}
else {
alertController.backgroundStyle =
CFAlertControllerBackgroundStyle.Plain;
}
this._alertController.shouldDismissOnBackgroundTap = options.cancellable;
this._alertController.backgroundStyle = options.backgroundBlur
? CFAlertControllerBackgroundStyle.Blur
: CFAlertControllerBackgroundStyle.Plain;
if (options.backgroundColor)
alertController.backgroundColor = new color_1.Color(options.backgroundColor).ios;
if (options.buttons) {
var _loop_1 = function (x) {
var btnOpts = options.buttons[x];
if (!btnOpts.buttonAlignment)
btnOpts.buttonAlignment = CFAlertActionAlignment.JUSTIFIED;
if (btnOpts.textColor)
btnOpts.textColor = new color_1.Color(btnOpts.textColor).ios;
if (btnOpts.backgroundColor)
btnOpts.backgroundColor = new color_1.Color(btnOpts.backgroundColor).ios;
var btn = CFAlertAction.alloc().initWithTitleStyleAlignmentBackgroundColorTextColorHandler(btnOpts.text, btnOpts.buttonStyle, btnOpts.buttonAlignment, btnOpts.backgroundColor, btnOpts.textColor, function (action) {
btnOpts.onClick(action.title);
});
alertController.addAction(btn);
};
for (var x = 0; options.buttons.length > x; x++) {
_loop_1(x);
}
this._alertController.backgroundColor = new color_1.Color(options.backgroundColor).ios;
this._addActions(options.buttons);
viewController.presentViewControllerAnimatedCompletion(this._alertController, true, null);
};
CFAlertDialog.prototype.dismiss = function (animated) {
if (!this._alertController)
return;
try {
this._alertController.dismissAlertWithAnimationCompletion(animated, function () { });
}
viewController.presentViewControllerAnimatedCompletion(alertController, true, null);
catch (e) { }
};
CFAlertDialog.prototype._addActions = function (buttons) {
var _this = this;
if (buttons === void 0) { buttons = []; }
buttons.forEach(function (btnOpts) {
if (!btnOpts.buttonAlignment)
btnOpts.buttonAlignment = CFAlertActionAlignment.JUSTIFIED;
if (btnOpts.textColor)
btnOpts.textColor = new color_1.Color(btnOpts.textColor).ios;
if (btnOpts.backgroundColor)
btnOpts.backgroundColor = new color_1.Color(btnOpts.backgroundColor).ios;
var btn = CFAlertAction.alloc().initWithTitleStyleAlignmentBackgroundColorTextColorHandler(btnOpts.text, btnOpts.buttonStyle, btnOpts.buttonAlignment, btnOpts.backgroundColor, btnOpts.textColor, function (action) { return btnOpts.onClick(action.title); });
_this._alertController.addAction(btn);
});
};
return CFAlertDialog;

@@ -93,0 +89,0 @@ }());

{
"name": "nativescript-cfalert-dialog",
"version": "1.0.8",
"version": "1.0.9",
"description": "CFAlert Dialog wrapper for NativeScript",

@@ -52,4 +52,16 @@ "main": "cfalert-dialog",

"name": "MultiShiv19",
"email": "sp@shiv19.com"
"email": "sp@shiv19.com",
"url": "https://shiv19.com"
},
"contributors": [
{
"name": "Dave Coffin",
"email": "dave@davecoffin.com",
"url": "https://github.com/davecoffin"
},
{
"name": "Jeremy PELE",
"url": "https://github.com/jeremypele"
}
],
"repository": {

@@ -56,0 +68,0 @@ "url": "https://github.com/shiv19/nativescript-cfalert-dialog",

@@ -60,2 +60,6 @@ # nativescript-cfalert-dialog [![npm](https://img.shields.io/npm/dt/express.svg)](https://www.npmjs.com/package/nativescript-cfalert-dialog)

`dismiss(animate:boolean): void;`
Dismiss the CFAlert Dialog (animate option effective on iOS only)
## Options format

@@ -62,0 +66,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc