app_default_dialog.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  3. import 'package:widgets/ext/ex_widget.dart';
  4. import 'package:cs_resources/constants/color_constants.dart';
  5. import '../my_text_view.dart';
  6. import '../no_shadow_scroll_behavior.dart';
  7. import 'dart:ui';
  8. import 'package:flutter/cupertino.dart';
  9. import 'package:flutter/widgets.dart';
  10. import 'package:widgets/widget_export.dart';
  11. /*
  12. * 默认的弹窗
  13. */
  14. class AppDefaultDialog extends StatelessWidget {
  15. String title;
  16. String message;
  17. VoidCallback confirmAction;
  18. VoidCallback? cancelAction;
  19. AppDefaultDialog({
  20. required this.title,
  21. required this.message,
  22. required this.confirmAction,
  23. this.cancelAction,
  24. });
  25. @override
  26. Widget build(BuildContext context) {
  27. //使用一个 Column 为最外层容器,可以方便的视线 wrap_content 的效果
  28. return Column(
  29. crossAxisAlignment: CrossAxisAlignment.center,
  30. mainAxisAlignment: MainAxisAlignment.center,
  31. children: [
  32. //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度)
  33. Container(
  34. width: double.infinity,
  35. decoration: const BoxDecoration(
  36. color: Colors.white,
  37. borderRadius: BorderRadius.all(Radius.circular(15)),
  38. ),
  39. child: Column(
  40. children: [
  41. MyTextView(
  42. title,
  43. fontSize: 19,
  44. isFontMedium: true,
  45. textColor: ColorConstants.black,
  46. marginTop: 15,
  47. marginBottom: 15,
  48. ),
  49. Scrollbar(
  50. child: ScrollConfiguration(
  51. behavior: NoShadowScrollBehavior(),
  52. child: SingleChildScrollView(
  53. child: MyTextView(
  54. message,
  55. fontSize: 16,
  56. textColor: Colors.black,
  57. isFontRegular: true,
  58. textAlign: TextAlign.center,
  59. paddingLeft: 30,
  60. paddingRight: 30,
  61. ),
  62. ),
  63. ),
  64. ).constrained(maxHeight: 210),
  65. Container(
  66. margin: EdgeInsets.only(top: 25),
  67. color: Color(0XFFCECECE),
  68. height: 0.5,
  69. ),
  70. Row(
  71. children: [
  72. Expanded(
  73. flex: 1,
  74. child: InkWell(
  75. onTap: () {
  76. onCancel();
  77. cancelAction?.call();
  78. },
  79. child: MyTextView(
  80. "Cancel",
  81. fontSize: 17.5,
  82. isFontMedium: true,
  83. textAlign: TextAlign.center,
  84. textColor: Color(0XFF0085C4),
  85. cornerRadius: 3,
  86. borderWidth: 1,
  87. ),
  88. )),
  89. Container(
  90. color: Color(0xff09141F).withOpacity(0.13),
  91. width: 0.5,
  92. ),
  93. Expanded(
  94. flex: 1,
  95. child: InkWell(
  96. onTap: () async {
  97. onCancel();
  98. confirmAction();
  99. },
  100. child: MyTextView(
  101. "Confirm",
  102. marginLeft: 10,
  103. fontSize: 17.5,
  104. isFontMedium: true,
  105. textAlign: TextAlign.center,
  106. textColor: Color(0XFF0085C4),
  107. cornerRadius: 3,
  108. ),
  109. )),
  110. ],
  111. ).constrained(height: 46),
  112. ],
  113. ),
  114. ),
  115. ],
  116. ).constrained(width: 295);
  117. }
  118. //取消弹框
  119. void onCancel() async {
  120. SmartDialog.dismiss();
  121. }
  122. }