mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Dialog class refactored
This commit is contained in:
@ -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;
|
||||
|
11
ui/dialogs/dialogs.d.ts
vendored
11
ui/dialogs/dialogs.d.ts
vendored
@ -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.
|
||||
*/
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user