From e7fd4e73fe6601ba3ddfd84dd9eb9aebfdd64d51 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Tue, 10 Jun 2014 17:20:58 +0300 Subject: [PATCH] Dialog class refactored --- ui/dialogs/dialogs.android.ts | 27 ++++++++------------------- ui/dialogs/dialogs.d.ts | 11 +---------- ui/dialogs/dialogs.ios.ts | 18 +++--------------- 3 files changed, 12 insertions(+), 44 deletions(-) diff --git a/ui/dialogs/dialogs.android.ts b/ui/dialogs/dialogs.android.ts index 1ff40ca26..be9a61db5 100644 --- a/ui/dialogs/dialogs.android.ts +++ b/ui/dialogs/dialogs.android.ts @@ -21,6 +21,9 @@ function createAlertDialog(message: string, options: dialogs.DialogOptions): and function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options: dialogs.DialogButtonsOptions, callback: Function): void { + if (!options) + return; + if (options.okButtonText) { alert.setPositiveButton(options.okButtonText, new android.content.DialogInterface.OnClickListener({ onClick: function (dialog: android.content.DialogInterface, id: number) { @@ -156,33 +159,19 @@ export function login(message: string, userName?: string, password?: string, export class Dialog { private _dialog: android.app.AlertDialog; private _android: android.app.AlertDialog.Builder; - private _title: string; - private _message: string; //private _view: view.View; - constructor() { - this._android = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity); + constructor(message: string, options?: dialogs.DialogButtonsOptions) { + this._android = createAlertDialog(message, options); + addButtonsToAlertDialog(this.android, options, function (r) { + + }); } get android(): android.app.AlertDialog.Builder { return this._android; } - get title(): string { - return this._title; - } - set title(value: string) { - this._title = value; - this.android.setTitle(this._title); - } - - get message(): string { - return this._message; - } - set message(value: string) { - this._message = value; - this.android.setMessage(this._message); - } /* get view(): view.View { return this._view; diff --git a/ui/dialogs/dialogs.d.ts b/ui/dialogs/dialogs.d.ts index fcde37957..5607ff0d7 100644 --- a/ui/dialogs/dialogs.d.ts +++ b/ui/dialogs/dialogs.d.ts @@ -117,6 +117,7 @@ } export class Dialog { + constructor(message: string, options?: DialogButtonsOptions); /** * Shows the dialog. */ @@ -127,16 +128,6 @@ */ hide: () => void; - /** - * Gets or sets dialog title. - */ - title: string; - - /** - * Gets or sets dialog message. - */ - message: string; - /** * Gets or sets dialog view. */ diff --git a/ui/dialogs/dialogs.ios.ts b/ui/dialogs/dialogs.ios.ts index 6a33bfc20..227f18443 100644 --- a/ui/dialogs/dialogs.ios.ts +++ b/ui/dialogs/dialogs.ios.ts @@ -172,27 +172,15 @@ export class Dialog { //private _view: view.View; //private _nativeView: UIKit.UIView; - constructor() { - this._ios = new UIKit.UIAlertView(); + constructor(message: string, options?: dialogs.DialogButtonsOptions) { + this._ios = createUIAlertView(message, options); + addButtonsToAlertDialog(this._ios, options); } get ios(): UIKit.UIAlertView { return this._ios; } - get title(): string { - return this.ios.title; - } - set title(value: string) { - this.ios.title = value; - } - - get message(): string { - return this.ios.message; - } - set message(value: string) { - this.ios.message = value; - } /* get view(): view.View { return this._view;