mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
alert fixed
This commit is contained in:
@@ -4,6 +4,7 @@ import page = require("ui/page");
|
||||
import button = require("ui/button");
|
||||
import textField = require("ui/text-field");
|
||||
import label = require("ui/label");
|
||||
import types = require("utils/types");
|
||||
|
||||
export var STRING = "string",
|
||||
PROMPT = "Prompt",
|
||||
@@ -78,4 +79,8 @@ export function getLabelColor(): color.Color {
|
||||
}
|
||||
|
||||
return labelColor;
|
||||
}
|
||||
|
||||
export function isDialogOptions(arg): boolean {
|
||||
return !types.isNullOrUndefined(arg) && (arg.message || arg.title);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options
|
||||
export function alert(arg: any): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
var options = types.isString(arg) ? { title: dialogsCommon.ALERT, okButtonText: dialogsCommon.OK, message: arg } : arg;
|
||||
var options = !dialogsCommon.isDialogOptions(arg) ? { title: dialogsCommon.ALERT, okButtonText: dialogsCommon.OK, message: arg + "" } : arg;
|
||||
|
||||
var alert = createAlertDialog(options);
|
||||
|
||||
@@ -112,7 +112,7 @@ export function alert(arg: any): Promise<void> {
|
||||
export function confirm(arg: any): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
var options = types.isString(arg) ? { title: dialogsCommon.CONFIRM, okButtonText: dialogsCommon.OK, cancelButtonText: dialogsCommon.CANCEL, message: arg } : arg;
|
||||
var options = !dialogsCommon.isDialogOptions(arg) ? { title: dialogsCommon.CONFIRM, okButtonText: dialogsCommon.OK, cancelButtonText: dialogsCommon.CANCEL, message: arg + "" } : arg;
|
||||
var alert = createAlertDialog(options);
|
||||
|
||||
addButtonsToAlertDialog(alert, options, function (result) { resolve(result); });
|
||||
|
||||
@@ -136,7 +136,7 @@ function raiseCallback(callback, result) {
|
||||
export function alert(arg: any): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
try {
|
||||
var options = types.isString(arg) ? { title: dialogsCommon.ALERT, okButtonText: dialogsCommon.OK, message: arg } : arg;
|
||||
var options = !dialogsCommon.isDialogOptions(arg) ? { title: dialogsCommon.ALERT, okButtonText: dialogsCommon.OK, message: arg + "" } : arg;
|
||||
|
||||
if (utils.ios.MajorVersion < 8) {
|
||||
var alert = createUIAlertView(options);
|
||||
@@ -171,7 +171,7 @@ export function alert(arg: any): Promise<void> {
|
||||
export function confirm(arg: any): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
try {
|
||||
var options = types.isString(arg) ? { title: dialogsCommon.CONFIRM, okButtonText: dialogsCommon.OK, cancelButtonText: dialogsCommon.CANCEL, message: arg } : arg;
|
||||
var options = !dialogsCommon.isDialogOptions(arg) ? { title: dialogsCommon.CONFIRM, okButtonText: dialogsCommon.OK, cancelButtonText: dialogsCommon.CANCEL, message: arg + "" } : arg;
|
||||
|
||||
if (utils.ios.MajorVersion < 8) {
|
||||
var alert = createUIAlertView(options);
|
||||
|
||||
Reference in New Issue
Block a user