CloseTaskDialog.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import 'package:deus_app/common/utils/CommonUtils.dart';
  2. import 'package:deus_app/common/utils/ConstantString.dart';
  3. import 'package:deus_app/common/utils/ToastUtils.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. class CloseTaskDialog {
  7. static void showCupertinoAlertDialog(
  8. BuildContext context, _CallBack onPressed) {
  9. String result = '';
  10. showDialog(
  11. context: context,
  12. barrierDismissible:false,
  13. builder: (BuildContext context) {
  14. return Theme(
  15. data: ThemeData(
  16. dialogBackgroundColor: Colors.white,
  17. dialogTheme: DialogTheme(backgroundColor: Colors.white)),
  18. child: CupertinoAlertDialog(
  19. title: Text(ConstantString.close_task),
  20. content: Column(
  21. children: <Widget>[
  22. SizedBox(
  23. height: 10,
  24. ),
  25. new TextField(
  26. maxLines: 3,
  27. decoration: InputDecoration(border: OutlineInputBorder()),
  28. style: TextStyle(fontSize: 14),
  29. onChanged: (value) {
  30. result = value;
  31. },
  32. )
  33. ],
  34. ),
  35. actions: <Widget>[
  36. CupertinoDialogAction(
  37. child: Text("取消"),
  38. onPressed: () {
  39. Navigator.pop(context);
  40. },
  41. ),
  42. CupertinoDialogAction(
  43. child: Text("确定"),
  44. onPressed: () {
  45. if (!CommonUtils.validationInput(result)) {
  46. showToast(ConstantString.notesNull);
  47. } else {
  48. onPressed(result);
  49. Navigator.pop(context);
  50. }
  51. },
  52. ),
  53. ],
  54. ));
  55. });
  56. }
  57. static void showAlertDialog(
  58. BuildContext context, _Back onPressed,String text) {
  59. showDialog(
  60. context: context,
  61. barrierDismissible:false,
  62. builder: (BuildContext context) {
  63. return Theme(
  64. data: ThemeData(
  65. dialogBackgroundColor: Colors.white,
  66. dialogTheme: DialogTheme(backgroundColor: Colors.white)),
  67. child: CupertinoAlertDialog(
  68. title: Text('提示'),
  69. content: Column(
  70. children: <Widget>[
  71. SizedBox(
  72. height: 10,
  73. ),
  74. Container(
  75. padding: EdgeInsets.all(10),
  76. child: Text(text),
  77. )
  78. ],
  79. ),
  80. actions: <Widget>[
  81. CupertinoDialogAction(
  82. child: Text("取消"),
  83. onPressed: () {
  84. Navigator.pop(context);
  85. },
  86. ),
  87. CupertinoDialogAction(
  88. child: Text("确定"),
  89. onPressed: () {
  90. onPressed();
  91. Navigator.pop(context);
  92. },
  93. ),
  94. ],
  95. ));
  96. });
  97. }
  98. }
  99. typedef _CallBack = void Function(String msg);
  100. typedef _Back = void Function();