dialoghelper.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flyinsonolite/controls/dialog/fisdialog.dart';
  4. import 'package:flyinsonolite/controls/text/fistext.dart';
  5. import 'package:flyinsonolite/infrastructure/scale.dart';
  6. import 'package:flyinsonolite/infrastructure/storage.dart';
  7. class DialogHelper {
  8. static Future showErrorDialog(BuildContext context, String message) async {
  9. await showDialog(
  10. context: context,
  11. builder: (context) {
  12. return LayoutBuilder(
  13. builder: (BuildContext context, BoxConstraints constraints) {
  14. return FISDialog(
  15. i18nBook.common.error.t,
  16. FISText(message,
  17. style: Storage.currentTheme.dialogStyle.messageTextStyle
  18. .copyWith(
  19. fontSize: Storage.currentTheme.dialogStyle
  20. .messageTextStyle.fontSize!.s)),
  21. true,
  22. true,
  23. minHeight: 150.s,
  24. );
  25. });
  26. },
  27. barrierDismissible: false);
  28. }
  29. static Future showConfirmDialog(
  30. BuildContext context, String message, VoidCallback onConfirm,
  31. {bool showConfirmButton = true,
  32. bool showCancelButton = true,
  33. bool showCloseButton = true}) async {
  34. await showDialog(
  35. context: context,
  36. builder: (context) {
  37. return LayoutBuilder(
  38. builder: (BuildContext context, BoxConstraints constraints) {
  39. return FISDialog(
  40. i18nBook.common.tip.t,
  41. FISText(message,
  42. style: Storage.currentTheme.dialogStyle.messageTextStyle
  43. .copyWith(
  44. fontSize: Storage.currentTheme.dialogStyle
  45. .messageTextStyle.fontSize!.s)),
  46. showConfirmButton,
  47. showCancelButton,
  48. onConfirm: onConfirm,
  49. showCloseButton: showCloseButton,
  50. minHeight: 150.s);
  51. });
  52. },
  53. barrierDismissible: false);
  54. }
  55. }