Showing
1 changed file
with
45 additions
and
30 deletions
@@ -314,6 +314,9 @@ extension ExtensionDialog on GetInterface { | @@ -314,6 +314,9 @@ extension ExtensionDialog on GetInterface { | ||
314 | double radius = 20.0, | 314 | double radius = 20.0, |
315 | // ThemeData themeData, | 315 | // ThemeData themeData, |
316 | List<Widget> actions, | 316 | List<Widget> actions, |
317 | + | ||
318 | + // onWillPop Scope | ||
319 | + WillPopCallback onWillPop, | ||
317 | }) { | 320 | }) { |
318 | var leanCancel = onCancel != null || textCancel != null; | 321 | var leanCancel = onCancel != null || textCancel != null; |
319 | var leanConfirm = onConfirm != null || textConfirm != null; | 322 | var leanConfirm = onConfirm != null || textConfirm != null; |
@@ -362,37 +365,49 @@ extension ExtensionDialog on GetInterface { | @@ -362,37 +365,49 @@ extension ExtensionDialog on GetInterface { | ||
362 | } | 365 | } |
363 | } | 366 | } |
364 | 367 | ||
365 | - return dialog<T>( | ||
366 | - AlertDialog( | ||
367 | - titlePadding: EdgeInsets.all(8), | ||
368 | - contentPadding: EdgeInsets.all(8), | ||
369 | - backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, | ||
370 | - shape: RoundedRectangleBorder( | ||
371 | - borderRadius: BorderRadius.all(Radius.circular(radius))), | ||
372 | - title: Text(title, textAlign: TextAlign.center, style: titleStyle), | ||
373 | - content: Column( | ||
374 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
375 | - mainAxisSize: MainAxisSize.min, | ||
376 | - children: [ | ||
377 | - content ?? | ||
378 | - Text(middleText ?? "", | ||
379 | - textAlign: TextAlign.center, style: middleTextStyle), | ||
380 | - SizedBox(height: 16), | ||
381 | - ButtonTheme( | ||
382 | - minWidth: 78.0, | ||
383 | - height: 34.0, | ||
384 | - child: Wrap( | ||
385 | - alignment: WrapAlignment.center, | ||
386 | - spacing: 8, | ||
387 | - runSpacing: 8, | ||
388 | - children: actions, | ||
389 | - ), | ||
390 | - ) | ||
391 | - ], | ||
392 | - ), | ||
393 | - // actions: actions, // ?? <Widget>[cancelButton, confirmButton], | ||
394 | - buttonPadding: EdgeInsets.zero, | 368 | + Widget baseAlertDialog = AlertDialog( |
369 | + titlePadding: EdgeInsets.all(8), | ||
370 | + contentPadding: EdgeInsets.all(8), | ||
371 | + backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, | ||
372 | + shape: RoundedRectangleBorder( | ||
373 | + borderRadius: BorderRadius.all(Radius.circular(radius))), | ||
374 | + title: Text(title, textAlign: TextAlign.center, style: titleStyle), | ||
375 | + content: Column( | ||
376 | + crossAxisAlignment: CrossAxisAlignment.center, | ||
377 | + mainAxisSize: MainAxisSize.min, | ||
378 | + children: [ | ||
379 | + content ?? | ||
380 | + Text(middleText ?? "", | ||
381 | + textAlign: TextAlign.center, style: middleTextStyle), | ||
382 | + SizedBox(height: 16), | ||
383 | + ButtonTheme( | ||
384 | + minWidth: 78.0, | ||
385 | + height: 34.0, | ||
386 | + child: Wrap( | ||
387 | + alignment: WrapAlignment.center, | ||
388 | + spacing: 8, | ||
389 | + runSpacing: 8, | ||
390 | + children: actions, | ||
391 | + ), | ||
392 | + ) | ||
393 | + ], | ||
395 | ), | 394 | ), |
395 | + // actions: actions, // ?? <Widget>[cancelButton, confirmButton], | ||
396 | + buttonPadding: EdgeInsets.zero, | ||
397 | + ); | ||
398 | + | ||
399 | + if (onWillPop != null) { | ||
400 | + return dialog<T>( | ||
401 | + WillPopScope( | ||
402 | + onWillPop: onWillPop, | ||
403 | + child: baseAlertDialog, | ||
404 | + ), | ||
405 | + barrierDismissible: barrierDismissible, | ||
406 | + ); | ||
407 | + } | ||
408 | + | ||
409 | + return dialog<T>( | ||
410 | + baseAlertDialog, | ||
396 | barrierDismissible: barrierDismissible, | 411 | barrierDismissible: barrierDismissible, |
397 | ); | 412 | ); |
398 | } | 413 | } |
-
Please register or login to post a comment