Skip to content

Commit 79cce6d

Browse files
committed
added title option for dialog.action
1 parent 9a985e7 commit 79cce6d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

ui/dialogs/dialogs.android.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export function action(arg: any): Promise<string> {
209209

210210
var options: dialogs.ActionOptions;
211211

212-
var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL };
212+
var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL };
213213

214214
if (arguments.length === 1) {
215215
if (types.isString(arguments[0])) {
@@ -236,7 +236,16 @@ export function action(arg: any): Promise<string> {
236236
return new Promise<string>((resolve, reject) => {
237237
try {
238238
var alert = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity);
239-
alert.setTitle(options && types.isString(options.message) ? options.message : "");
239+
var message = options && types.isString(options.message) ? options.message : "";
240+
var title = options && types.isString(options.title) ? options.title : "";
241+
242+
if (title) {
243+
alert.setTitle(title);
244+
alert.setMessage(message);
245+
}
246+
else {
247+
alert.setTitle(message);
248+
}
240249

241250
if (options.actions) {
242251
alert.setItems(options.actions, new android.content.DialogInterface.OnClickListener({

ui/dialogs/dialogs.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ declare module "ui/dialogs" {
8686
* Provides options for the dialog.
8787
*/
8888
export interface ActionOptions {
89+
/**
90+
* Gets or sets the dialog title.
91+
*/
92+
title?: string;
93+
8994
/**
9095
* Gets or sets the dialog message.
9196
*/

ui/dialogs/dialogs.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ function showUIAlertController(alertController: UIAlertController) {
387387
export function action(arg: any): Promise<string> {
388388
var options: dialogs.ActionOptions;
389389

390-
var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL };
390+
var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL };
391391

392392
if (arguments.length === 1) {
393393
if (types.isString(arguments[0])) {
@@ -445,7 +445,7 @@ export function action(arg: any): Promise<string> {
445445
actionSheet.delegate = delegate;
446446
actionSheet.showInView(UIApplication.sharedApplication().keyWindow);
447447
} else {
448-
var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.message, null, UIAlertControllerStyle.UIAlertControllerStyleActionSheet);
448+
var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title, options.message, UIAlertControllerStyle.UIAlertControllerStyleActionSheet);
449449

450450
if (options.actions) {
451451
for (i = 0; i < options.actions.length; i++) {

0 commit comments

Comments
 (0)