mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
added title option for dialog.action
This commit is contained in:
@ -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({
|
||||||
|
5
ui/dialogs/dialogs.d.ts
vendored
5
ui/dialogs/dialogs.d.ts
vendored
@ -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.
|
||||||
*/
|
*/
|
||||||
|
@ -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++) {
|
||||||
|
Reference in New Issue
Block a user