File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export interface MDCAlertControlerOptions {
17
17
customTitleView ?: View ;
18
18
view ?: ViewBase | string ;
19
19
context ?: any ;
20
+ dismissOnBackgroundTap ?: boolean ;
20
21
closeCallback ?: Function ;
21
22
shouldResolveOnAction ?: ( result ) => boolean ;
22
23
}
Original file line number Diff line number Diff line change @@ -221,6 +221,10 @@ function prepareAndCreateAlertDialog(
221
221
view . bindingContext = fromObject ( context ) ;
222
222
}
223
223
224
+ if ( options . dismissOnBackgroundTap !== undefined ) {
225
+ dlg . setCanceledOnTouchOutside ( options . dismissOnBackgroundTap ) ;
226
+ }
227
+
224
228
if ( options . okButtonText ) {
225
229
if ( ! DialogInterface ) {
226
230
DialogInterface = android . content . DialogInterface ;
@@ -314,17 +318,17 @@ export class AlertDialog {
314
318
dialog : androidx . appcompat . app . AlertDialog ;
315
319
constructor ( private options : any ) { }
316
320
onCloseListeners : any [ ] = [ ] ;
317
- onClosed ( ) {
318
- this . onCloseListeners . forEach ( ( l ) => l ( ) ) ;
321
+ onClosed ( ... args ) {
322
+ this . onCloseListeners . forEach ( ( l ) => l ( ... args ) ) ;
319
323
this . onCloseListeners = [ ] ;
320
324
}
321
325
show ( onClosed ?) {
322
326
if ( ! this . dialog ) {
323
327
const alert = createAlertDialogBuilder ( this . options ) ;
324
328
this . dialog = alert . create ( ) ;
325
- this . dialog = prepareAndCreateAlertDialog ( alert , this . options , ( ) => {
326
- this . onClosed ( ) ;
327
- onClosed ?.( ) ;
329
+ this . dialog = prepareAndCreateAlertDialog ( alert , this . options , ( ... args ) => {
330
+ this . onClosed ( ... args ) ;
331
+ onClosed ?.( ... args ) ;
328
332
} ) ;
329
333
showDialog ( this . dialog , this . options ) ;
330
334
}
Original file line number Diff line number Diff line change @@ -213,6 +213,9 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
213
213
if ( options && options . cancelable === false ) {
214
214
alertController . mdc_dialogPresentationController . dismissOnBackgroundTap = false ;
215
215
}
216
+ if ( options && options . dismissOnBackgroundTap === false ) {
217
+ alertController . mdc_dialogPresentationController . dismissOnBackgroundTap = false ;
218
+ }
216
219
217
220
// const transitionController = MDCDialogTransitionController.alloc().init()
218
221
// alertController.modalPresentationStyle = UIModalPresentationStyle.Custom;
You can’t perform that action at this time.
0 commit comments