added title option for dialog.action

This commit is contained in:
Peter Staev
2015-09-05 11:03:55 +03:00
parent 9a985e7efe
commit 79cce6dd91
3 changed files with 18 additions and 4 deletions

View File

@ -209,7 +209,7 @@ export function action(arg: any): Promise<string> {
var options: dialogs.ActionOptions; var options: dialogs.ActionOptions;
var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL }; var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL };
if (arguments.length === 1) { if (arguments.length === 1) {
if (types.isString(arguments[0])) { if (types.isString(arguments[0])) {
@ -236,7 +236,16 @@ export function action(arg: any): Promise<string> {
return new Promise<string>((resolve, reject) => { return new Promise<string>((resolve, reject) => {
try { try {
var alert = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity); 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) { if (options.actions) {
alert.setItems(options.actions, new android.content.DialogInterface.OnClickListener({ alert.setItems(options.actions, new android.content.DialogInterface.OnClickListener({

View File

@ -86,6 +86,11 @@ declare module "ui/dialogs" {
* Provides options for the dialog. * Provides options for the dialog.
*/ */
export interface ActionOptions { export interface ActionOptions {
/**
* Gets or sets the dialog title.
*/
title?: string;
/** /**
* Gets or sets the dialog message. * Gets or sets the dialog message.
*/ */

View File

@ -387,7 +387,7 @@ function showUIAlertController(alertController: UIAlertController) {
export function action(arg: any): Promise<string> { export function action(arg: any): Promise<string> {
var options: dialogs.ActionOptions; var options: dialogs.ActionOptions;
var defaultOptions = { cancelButtonText: dialogsCommon.CANCEL }; var defaultOptions = { title: null, cancelButtonText: dialogsCommon.CANCEL };
if (arguments.length === 1) { if (arguments.length === 1) {
if (types.isString(arguments[0])) { if (types.isString(arguments[0])) {
@ -445,7 +445,7 @@ export function action(arg: any): Promise<string> {
actionSheet.delegate = delegate; actionSheet.delegate = delegate;
actionSheet.showInView(UIApplication.sharedApplication().keyWindow); actionSheet.showInView(UIApplication.sharedApplication().keyWindow);
} else { } else {
var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.message, null, UIAlertControllerStyle.UIAlertControllerStyleActionSheet); var alertController = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title, options.message, UIAlertControllerStyle.UIAlertControllerStyleActionSheet);
if (options.actions) { if (options.actions) {
for (i = 0; i < options.actions.length; i++) { for (i = 0; i < options.actions.length; i++) {