Dialog class refactored

This commit is contained in:
Vladimir Enchev
2014-06-10 17:20:58 +03:00
parent 14ceb15156
commit e7fd4e73fe
3 changed files with 12 additions and 44 deletions

View File

@ -21,6 +21,9 @@ function createAlertDialog(message: string, options: dialogs.DialogOptions): and
function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options: dialogs.DialogButtonsOptions, function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options: dialogs.DialogButtonsOptions,
callback: Function): void { callback: Function): void {
if (!options)
return;
if (options.okButtonText) { if (options.okButtonText) {
alert.setPositiveButton(options.okButtonText, new android.content.DialogInterface.OnClickListener({ alert.setPositiveButton(options.okButtonText, new android.content.DialogInterface.OnClickListener({
onClick: function (dialog: android.content.DialogInterface, id: number) { onClick: function (dialog: android.content.DialogInterface, id: number) {
@ -156,33 +159,19 @@ export function login(message: string, userName?: string, password?: string,
export class Dialog { export class Dialog {
private _dialog: android.app.AlertDialog; private _dialog: android.app.AlertDialog;
private _android: android.app.AlertDialog.Builder; private _android: android.app.AlertDialog.Builder;
private _title: string;
private _message: string;
//private _view: view.View; //private _view: view.View;
constructor() { constructor(message: string, options?: dialogs.DialogButtonsOptions) {
this._android = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity); this._android = createAlertDialog(message, options);
addButtonsToAlertDialog(this.android, options, function (r) {
});
} }
get android(): android.app.AlertDialog.Builder { get android(): android.app.AlertDialog.Builder {
return this._android; 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 { get view(): view.View {
return this._view; return this._view;

View File

@ -117,6 +117,7 @@
} }
export class Dialog { export class Dialog {
constructor(message: string, options?: DialogButtonsOptions);
/** /**
* Shows the dialog. * Shows the dialog.
*/ */
@ -127,16 +128,6 @@
*/ */
hide: () => void; hide: () => void;
/**
* Gets or sets dialog title.
*/
title: string;
/**
* Gets or sets dialog message.
*/
message: string;
/** /**
* Gets or sets dialog view. * Gets or sets dialog view.
*/ */

View File

@ -172,27 +172,15 @@ export class Dialog {
//private _view: view.View; //private _view: view.View;
//private _nativeView: UIKit.UIView; //private _nativeView: UIKit.UIView;
constructor() { constructor(message: string, options?: dialogs.DialogButtonsOptions) {
this._ios = new UIKit.UIAlertView(); this._ios = createUIAlertView(message, options);
addButtonsToAlertDialog(this._ios, options);
} }
get ios(): UIKit.UIAlertView { get ios(): UIKit.UIAlertView {
return this._ios; 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 { get view(): view.View {
return this._view; return this._view;