mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
dialog close callback implement for Dialog class
This commit is contained in:
@ -161,10 +161,12 @@ export class Dialog {
|
|||||||
private _android: android.app.AlertDialog.Builder;
|
private _android: android.app.AlertDialog.Builder;
|
||||||
//private _view: view.View;
|
//private _view: view.View;
|
||||||
|
|
||||||
constructor(message: string, options?: dialogs.DialogButtonsOptions) {
|
constructor(message: string, callback?: (result: boolean) => {}, options?: dialogs.DialogButtonsOptions) {
|
||||||
this._android = createAlertDialog(message, options);
|
this._android = createAlertDialog(message, options);
|
||||||
addButtonsToAlertDialog(this.android, options, function (r) {
|
addButtonsToAlertDialog(this.android, options, function (r) {
|
||||||
|
if (callback) {
|
||||||
|
callback(r);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
ui/dialogs/dialogs.d.ts
vendored
2
ui/dialogs/dialogs.d.ts
vendored
@ -117,7 +117,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Dialog {
|
export class Dialog {
|
||||||
constructor(message: string, options?: DialogButtonsOptions);
|
constructor(message: string, callback?: (result: boolean) => {}, options?: DialogButtonsOptions);
|
||||||
/**
|
/**
|
||||||
* Shows the dialog.
|
* Shows the dialog.
|
||||||
*/
|
*/
|
||||||
|
@ -172,9 +172,21 @@ export class Dialog {
|
|||||||
//private _view: view.View;
|
//private _view: view.View;
|
||||||
//private _nativeView: UIKit.UIView;
|
//private _nativeView: UIKit.UIView;
|
||||||
|
|
||||||
constructor(message: string, options?: dialogs.DialogButtonsOptions) {
|
constructor(message: string, callback?: (result: boolean) => {}, options?: dialogs.DialogButtonsOptions) {
|
||||||
this._ios = createUIAlertView(message, options);
|
this._ios = createUIAlertView(message, options);
|
||||||
addButtonsToAlertDialog(this._ios, options);
|
addButtonsToAlertDialog(this._ios, options);
|
||||||
|
|
||||||
|
// Assign first to local variable, otherwise it will be garbage collected since delegate is weak reference.
|
||||||
|
var delegate = createDelegate(function (view, index) {
|
||||||
|
if (callback) {
|
||||||
|
callback(index === 2 ? undefined : index === 0);
|
||||||
|
}
|
||||||
|
// Remove the local variable for the delegate.
|
||||||
|
delegate = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
this._ios.delegate = delegate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get ios(): UIKit.UIAlertView {
|
get ios(): UIKit.UIAlertView {
|
||||||
|
Reference in New Issue
Block a user