@@ -14,7 +14,7 @@ import {
14
14
View ,
15
15
capitalizationType ,
16
16
fromObject ,
17
- inputType ,
17
+ inputType
18
18
} from '@nativescript/core' ;
19
19
import { LoginOptions , MDCAlertControlerOptions , PromptOptions } from './dialogs' ;
20
20
import { isDialogOptions } from './dialogs-common' ;
@@ -35,12 +35,14 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
35
35
}
36
36
if ( options && options . cancelable === false ) {
37
37
builder . setCancelable ( false ) ;
38
- builder . setOnKeyListener ( new android . content . DialogInterface . OnKeyListener ( {
39
- onKey ( dialog , keyCode , event ) {
40
- // Prevent dialog close on back press button
41
- return keyCode === android . view . KeyEvent . KEYCODE_BACK ;
42
- }
43
- } ) ) ;
38
+ builder . setOnKeyListener (
39
+ new android . content . DialogInterface . OnKeyListener ( {
40
+ onKey ( dialog , keyCode , event ) {
41
+ // Prevent dialog close on back press button
42
+ return keyCode === android . view . KeyEvent . KEYCODE_BACK ;
43
+ }
44
+ } )
45
+ ) ;
44
46
}
45
47
if ( options . titleIcon ) {
46
48
builder . setIcon ( options . titleIcon . android ) ;
@@ -53,7 +55,7 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
53
55
options . view instanceof View
54
56
? options . view
55
57
: Builder . createViewFromEntry ( {
56
- moduleName : options . view as string ,
58
+ moduleName : options . view as string
57
59
} ) ;
58
60
59
61
view . cssClasses . add ( CSSUtils . MODAL_ROOT_VIEW_CSS_CLASS ) ;
@@ -159,7 +161,6 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
159
161
callback && callback ( result ) ;
160
162
} ;
161
163
162
- const activity = Application . android . foregroundActivity || ( Application . android . startActivity as globalAndroid . app . Activity ) ;
163
164
builder . setOnDismissListener (
164
165
new android . content . DialogInterface . OnDismissListener ( {
165
166
onDismiss ( ) {
@@ -171,7 +172,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
171
172
view . _isAddedToNativeVisualTree = false ;
172
173
( builder as any ) . _currentModalCustomView = null ;
173
174
}
174
- } ,
175
+ }
175
176
} )
176
177
) ;
177
178
const dlg = builder . create ( ) ;
@@ -198,7 +199,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
198
199
new android . content . DialogInterface . OnClickListener ( {
199
200
onClick ( dialog : android . content . DialogInterface , id : number ) {
200
201
onDone ( true , dialog ) ;
201
- } ,
202
+ }
202
203
} )
203
204
) ;
204
205
// alert.setPositiveButton(
@@ -214,7 +215,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
214
215
new android . content . DialogInterface . OnClickListener ( {
215
216
onClick ( dialog : android . content . DialogInterface , id : number ) {
216
217
onDone ( false , dialog ) ;
217
- } ,
218
+ }
218
219
} )
219
220
) ;
220
221
// alert.setNegativeButton(
@@ -235,7 +236,7 @@ function prepareAndCreateAlertDialog(builder: androidx.appcompat.app.AlertDialog
235
236
new android . content . DialogInterface . OnClickListener ( {
236
237
onClick ( dialog : android . content . DialogInterface , id : number ) {
237
238
onDone ( undefined , dialog ) ;
238
- } ,
239
+ }
239
240
} )
240
241
) ;
241
242
// alert.setNeutralButton(
@@ -255,7 +256,7 @@ export function alert(arg: any): Promise<void> {
255
256
try {
256
257
const defaultOptions = {
257
258
title : DialogStrings . ALERT ,
258
- okButtonText : DialogStrings . OK ,
259
+ okButtonText : DialogStrings . OK
259
260
} ;
260
261
const options = ! isDialogOptions ( arg ) ? Object . assign ( defaultOptions , { message : arg + '' } ) : Object . assign ( defaultOptions , arg ) ;
261
262
@@ -296,11 +297,11 @@ export function confirm(arg: any): Promise<boolean> {
296
297
const defaultOptions = {
297
298
title : DialogStrings . CONFIRM ,
298
299
okButtonText : DialogStrings . OK ,
299
- cancelButtonText : DialogStrings . CANCEL ,
300
+ cancelButtonText : DialogStrings . CANCEL
300
301
} ;
301
302
const options = ! isDialogOptions ( arg )
302
303
? Object . assign ( defaultOptions , {
303
- message : arg + '' ,
304
+ message : arg + ''
304
305
} )
305
306
: Object . assign ( defaultOptions , arg ) ;
306
307
const alert = createAlertDialogBuilder ( options ) ;
@@ -320,7 +321,7 @@ export function prompt(arg: any): Promise<PromptResult> {
320
321
title : DialogStrings . PROMPT ,
321
322
okButtonText : DialogStrings . OK ,
322
323
cancelButtonText : DialogStrings . CANCEL ,
323
- inputType : inputType . text ,
324
+ inputType : inputType . text
324
325
} ;
325
326
326
327
if ( arguments . length === 1 ) {
@@ -411,7 +412,7 @@ export function login(arg: any): Promise<LoginResult> {
411
412
const defaultOptions = {
412
413
title : DialogStrings . LOGIN ,
413
414
okButtonText : DialogStrings . OK ,
414
- cancelButtonText : DialogStrings . CANCEL ,
415
+ cancelButtonText : DialogStrings . CANCEL
415
416
} ;
416
417
417
418
if ( arguments . length === 1 ) {
@@ -471,7 +472,7 @@ export function login(arg: any): Promise<LoginResult> {
471
472
resolve ( {
472
473
result : r ,
473
474
userName : userNameTextField . text ,
474
- password : passwordTextField . text ,
475
+ password : passwordTextField . text
475
476
} ) ;
476
477
} ,
477
478
( r ) => ( { result : r , userName : userNameTextField . text , password : passwordTextField . text } )
@@ -539,7 +540,7 @@ export function action(arg: any): Promise<string> {
539
540
new android . content . DialogInterface . OnClickListener ( {
540
541
onClick ( dialog : android . content . DialogInterface , which : number ) {
541
542
resolve ( options . actions [ which ] ) ;
542
- } ,
543
+ }
543
544
} )
544
545
) ;
545
546
}
0 commit comments