UNPKG

nativescript-easy-dialog

Version:

nativescript-easy-dialogr for ios And android

92 lines 4.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var frame = require("tns-core-modules/ui/frame"); var color_1 = require("tns-core-modules/color"); var CFAlertStyle; (function (CFAlertStyle) { CFAlertStyle[CFAlertStyle["NOTIFICATION"] = 2] = "NOTIFICATION"; CFAlertStyle[CFAlertStyle["ALERT"] = 0] = "ALERT"; CFAlertStyle[CFAlertStyle["BOTTOM_SHEET"] = 1] = "BOTTOM_SHEET"; })(CFAlertStyle = exports.CFAlertStyle || (exports.CFAlertStyle = {})); var CFAlertActionStyle; (function (CFAlertActionStyle) { 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["START"] = 2] = "START"; CFAlertActionAlignment[CFAlertActionAlignment["END"] = 1] = "END"; CFAlertActionAlignment[CFAlertActionAlignment["CENTER"] = 3] = "CENTER"; CFAlertActionAlignment[CFAlertActionAlignment["JUSTIFIED"] = 0] = "JUSTIFIED"; })(CFAlertActionAlignment = exports.CFAlertActionAlignment || (exports.CFAlertActionAlignment = {})); var CFAlertGravity; (function (CFAlertGravity) { CFAlertGravity[CFAlertGravity["START"] = 0] = "START"; CFAlertGravity[CFAlertGravity["CENTER_HORIZONTAL"] = 1] = "CENTER_HORIZONTAL"; CFAlertGravity[CFAlertGravity["END"] = 2] = "END"; })(CFAlertGravity = exports.CFAlertGravity || (exports.CFAlertGravity = {})); var CFAlertDialog = (function () { function CFAlertDialog() { } CFAlertDialog.prototype.show = function (options) { if (options.simpleList || options.singleChoiceList || options.multiChoiceList) { alert("Lists are not available on iOS."); return; } 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; 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 () { if (options.onDismiss) options.onDismiss(); }); if (options.backgroundBlur) { alertController.backgroundStyle = CFAlertControllerBackgroundStyle.Blur; } else { alertController.backgroundStyle = 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); } } viewController.presentViewControllerAnimatedCompletion(alertController, true, null); }; return CFAlertDialog; }()); exports.CFAlertDialog = CFAlertDialog; //# sourceMappingURL=cfalert-dialog.ios.js.map