Skip to content

Commit e7fd4e7

Browse files
author
Vladimir Enchev
committed
Dialog class refactored
1 parent 14ceb15 commit e7fd4e7

3 files changed

Lines changed: 12 additions & 44 deletions

File tree

ui/dialogs/dialogs.android.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function createAlertDialog(message: string, options: dialogs.DialogOptions): and
2121
function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options: dialogs.DialogButtonsOptions,
2222
callback: Function): void {
2323

24+
if (!options)
25+
return;
26+
2427
if (options.okButtonText) {
2528
alert.setPositiveButton(options.okButtonText, new android.content.DialogInterface.OnClickListener({
2629
onClick: function (dialog: android.content.DialogInterface, id: number) {
@@ -156,33 +159,19 @@ export function login(message: string, userName?: string, password?: string,
156159
export class Dialog {
157160
private _dialog: android.app.AlertDialog;
158161
private _android: android.app.AlertDialog.Builder;
159-
private _title: string;
160-
private _message: string;
161162
//private _view: view.View;
162163

163-
constructor() {
164-
this._android = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity);
164+
constructor(message: string, options?: dialogs.DialogButtonsOptions) {
165+
this._android = createAlertDialog(message, options);
166+
addButtonsToAlertDialog(this.android, options, function (r) {
167+
168+
});
165169
}
166170

167171
get android(): android.app.AlertDialog.Builder {
168172
return this._android;
169173
}
170174

171-
get title(): string {
172-
return this._title;
173-
}
174-
set title(value: string) {
175-
this._title = value;
176-
this.android.setTitle(this._title);
177-
}
178-
179-
get message(): string {
180-
return this._message;
181-
}
182-
set message(value: string) {
183-
this._message = value;
184-
this.android.setMessage(this._message);
185-
}
186175
/*
187176
get view(): view.View {
188177
return this._view;

ui/dialogs/dialogs.d.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
}
118118

119119
export class Dialog {
120+
constructor(message: string, options?: DialogButtonsOptions);
120121
/**
121122
* Shows the dialog.
122123
*/
@@ -127,16 +128,6 @@
127128
*/
128129
hide: () => void;
129130

130-
/**
131-
* Gets or sets dialog title.
132-
*/
133-
title: string;
134-
135-
/**
136-
* Gets or sets dialog message.
137-
*/
138-
message: string;
139-
140131
/**
141132
* Gets or sets dialog view.
142133
*/

ui/dialogs/dialogs.ios.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,27 +172,15 @@ export class Dialog {
172172
//private _view: view.View;
173173
//private _nativeView: UIKit.UIView;
174174

175-
constructor() {
176-
this._ios = new UIKit.UIAlertView();
175+
constructor(message: string, options?: dialogs.DialogButtonsOptions) {
176+
this._ios = createUIAlertView(message, options);
177+
addButtonsToAlertDialog(this._ios, options);
177178
}
178179

179180
get ios(): UIKit.UIAlertView {
180181
return this._ios;
181182
}
182183

183-
get title(): string {
184-
return this.ios.title;
185-
}
186-
set title(value: string) {
187-
this.ios.title = value;
188-
}
189-
190-
get message(): string {
191-
return this.ios.message;
192-
}
193-
set message(value: string) {
194-
this.ios.message = value;
195-
}
196184
/*
197185
get view(): view.View {
198186
return this._view;

0 commit comments

Comments
 (0)