From 79cce6dd91410ac26a0b251fd0b522e3abfdd09a Mon Sep 17 00:00:00 2001 From: Peter Staev Date: Sat, 5 Sep 2015 11:03:55 +0300 Subject: [PATCH] added title option for dialog.action --- ui/dialogs/dialogs.android.ts | 13 +++++++++++-- ui/dialogs/dialogs.d.ts | 5 +++++ ui/dialogs/dialogs.ios.ts | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ui/dialogs/dialogs.android.ts b/ui/dialogs/dialogs.android.ts index 864631d3c..1a3b44b68 100644 --- a/ui/dialogs/dialogs.android.ts +++ b/ui/dialogs/dialogs.android.ts @@ -209,7 +209,7 @@ export function action(arg: any): Promise { var options: dialogs.ActionOptions; - var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL }; + var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL }; if (arguments.length === 1) { if (types.isString(arguments[0])) { @@ -236,7 +236,16 @@ export function action(arg: any): Promise { return new Promise((resolve, reject) => { try { var alert = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity); - alert.setTitle(options && types.isString(options.message) ? options.message : ""); + var message = options && types.isString(options.message) ? options.message : ""; + var title = options && types.isString(options.title) ? options.title : ""; + + if (title) { + alert.setTitle(title); + alert.setMessage(message); + } + else { + alert.setTitle(message); + } if (options.actions) { alert.setItems(options.actions, new android.content.DialogInterface.OnClickListener({ diff --git a/ui/dialogs/dialogs.d.ts b/ui/dialogs/dialogs.d.ts index 09a2de696..8114eb669 100644 --- a/ui/dialogs/dialogs.d.ts +++ b/ui/dialogs/dialogs.d.ts @@ -86,6 +86,11 @@ declare module "ui/dialogs" { * Provides options for the dialog. */ export interface ActionOptions { + /** + * Gets or sets the dialog title. + */ + title?: string; + /** * Gets or sets the dialog message. */ diff --git a/ui/dialogs/dialogs.ios.ts b/ui/dialogs/dialogs.ios.ts index 0a29fd597..3bf1efb23 100644 --- a/ui/dialogs/dialogs.ios.ts +++ b/ui/dialogs/dialogs.ios.ts @@ -387,7 +387,7 @@ function showUIAlertController(alertController: UIAlertController) { export function action(arg: any): Promise { var options: dialogs.ActionOptions; - var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL }; + var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL }; if (arguments.length === 1) { if (types.isString(arguments[0])) { @@ -445,7 +445,7 @@ export function action(arg: any): Promise { actionSheet.delegate = delegate; actionSheet.showInView(UIApplication.sharedApplication().keyWindow); } else { - var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.message, null, UIAlertControllerStyle.UIAlertControllerStyleActionSheet); + var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title, options.message, UIAlertControllerStyle.UIAlertControllerStyleActionSheet); if (options.actions) { for (i = 0; i < options.actions.length; i++) {