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 {
1717 customTitleView ?: View ;
1818 view ?: ViewBase | string ;
1919 context ?: any ;
20+ dismissOnBackgroundTap ?: boolean ;
2021 closeCallback ?: Function ;
2122 shouldResolveOnAction ?: ( result ) => boolean ;
2223}
Original file line number Diff line number Diff line change @@ -221,6 +221,10 @@ function prepareAndCreateAlertDialog(
221221 view . bindingContext = fromObject ( context ) ;
222222 }
223223
224+ if ( options . dismissOnBackgroundTap !== undefined ) {
225+ dlg . setCanceledOnTouchOutside ( options . dismissOnBackgroundTap ) ;
226+ }
227+
224228 if ( options . okButtonText ) {
225229 if ( ! DialogInterface ) {
226230 DialogInterface = android . content . DialogInterface ;
@@ -314,17 +318,17 @@ export class AlertDialog {
314318 dialog : androidx . appcompat . app . AlertDialog ;
315319 constructor ( private options : any ) { }
316320 onCloseListeners : any [ ] = [ ] ;
317- onClosed ( ) {
318- this . onCloseListeners . forEach ( ( l ) => l ( ) ) ;
321+ onClosed ( ... args ) {
322+ this . onCloseListeners . forEach ( ( l ) => l ( ... args ) ) ;
319323 this . onCloseListeners = [ ] ;
320324 }
321325 show ( onClosed ?) {
322326 if ( ! this . dialog ) {
323327 const alert = createAlertDialogBuilder ( this . options ) ;
324328 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 ) ;
328332 } ) ;
329333 showDialog ( this . dialog , this . options ) ;
330334 }
Original file line number Diff line number Diff line change @@ -213,6 +213,9 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
213213 if ( options && options . cancelable === false ) {
214214 alertController . mdc_dialogPresentationController . dismissOnBackgroundTap = false ;
215215 }
216+ if ( options && options . dismissOnBackgroundTap === false ) {
217+ alertController . mdc_dialogPresentationController . dismissOnBackgroundTap = false ;
218+ }
216219
217220 // const transitionController = MDCDialogTransitionController.alloc().init()
218221 // alertController.modalPresentationStyle = UIModalPresentationStyle.Custom;
You can’t perform that action at this time.
0 commit comments