app_default_dialog.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:cs_resources/theme/app_colors_theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  6. import 'package:widgets/ext/ex_widget.dart';
  7. import 'package:widgets/my_load_image.dart';
  8. import '../my_text_view.dart';
  9. import 'dart:ui';
  10. import 'package:flutter/cupertino.dart';
  11. import 'package:flutter/widgets.dart';
  12. import 'package:widgets/widget_export.dart';
  13. import '../no_shadow_scroll_behavior.dart';
  14. /*
  15. * 默认的弹窗
  16. */
  17. class AppDefaultDialog extends StatelessWidget {
  18. String? title;
  19. String message;
  20. VoidCallback confirmAction;
  21. VoidCallback? cancelAction;
  22. bool isShowCancelBtn;
  23. String? confirmTxt;
  24. String? cancelTxt;
  25. AppDefaultDialog({
  26. required this.message,
  27. required this.confirmAction,
  28. this.title,
  29. this.cancelAction,
  30. this.isShowCancelBtn = true,
  31. this.confirmTxt,
  32. this.cancelTxt,
  33. });
  34. @override
  35. Widget build(BuildContext context) {
  36. //使用一个 Column 为最外层容器,可以方便的视线 wrap_content 的效果
  37. return Column(
  38. crossAxisAlignment: CrossAxisAlignment.center,
  39. mainAxisAlignment: MainAxisAlignment.center,
  40. children: [
  41. //Title (如果使用 Container 为最外层容器则默认为 match_parent 的效果,除非我们限制宽度和最大高度最小高度)
  42. Container(
  43. width: double.infinity,
  44. height: 55,
  45. decoration: BoxDecoration(
  46. color: context.appColors.btnBgDefault,
  47. borderRadius: const BorderRadius.only(
  48. topRight: Radius.circular(15),
  49. topLeft: Radius.circular(15),
  50. ),
  51. ),
  52. child: Row(
  53. children: [
  54. const SizedBox(width: 45),
  55. MyTextView(
  56. title ?? S.current.alert,
  57. fontSize: 18,
  58. textAlign: TextAlign.center,
  59. isFontMedium: true,
  60. textColor: Colors.white,
  61. ).expanded(),
  62. const MyAssetImage(Assets.baseServiceDialogDeleteIcon,width: 25,height: 25.5,).onTap((){
  63. onCancel();
  64. },padding: 10)
  65. ],
  66. ),
  67. ),
  68. Container(
  69. width: double.infinity,
  70. padding: const EdgeInsets.only(top: 30),
  71. decoration: BoxDecoration(
  72. color: context.appColors.whiteSecondBG,
  73. borderRadius: const BorderRadius.only(
  74. bottomLeft: Radius.circular(15),
  75. bottomRight: Radius.circular(15),
  76. ),
  77. ),
  78. child: Column(
  79. children: [
  80. Scrollbar(
  81. child: ScrollConfiguration(
  82. behavior: NoShadowScrollBehavior(),
  83. child: SingleChildScrollView(
  84. child: MyTextView(
  85. message,
  86. fontSize: 18,
  87. textColor: context.appColors.textBlack,
  88. isFontRegular: true,
  89. textAlign: TextAlign.center,
  90. paddingLeft: 30,
  91. paddingRight: 30,
  92. ),
  93. ),
  94. ),
  95. ).constrained(maxHeight: 210),
  96. Row(
  97. children: [
  98. const SizedBox(width: 18),
  99. Visibility(
  100. visible: isShowCancelBtn,
  101. child: Expanded(
  102. flex: 1,
  103. child: InkWell(
  104. onTap: () {
  105. onCancel();
  106. cancelAction?.call();
  107. },
  108. child: MyTextView(
  109. cancelTxt ?? S.current.no,
  110. fontSize: 16,
  111. isFontMedium: true,
  112. paddingTop: 13,
  113. marginRight: 15,
  114. paddingBottom: 13,
  115. textAlign: TextAlign.center,
  116. textColor: Colors.white,
  117. backgroundColor: context.appColors.orangeBG,
  118. cornerRadius: 7,
  119. ),
  120. )),
  121. ),
  122. Expanded(
  123. flex: 1,
  124. child: InkWell(
  125. onTap: () async {
  126. onCancel();
  127. confirmAction();
  128. },
  129. child: MyTextView(
  130. confirmTxt ?? S.current.yes,
  131. fontSize: 16,
  132. paddingTop: 13,
  133. paddingBottom: 13,
  134. isFontMedium: true,
  135. textAlign: TextAlign.center,
  136. textColor: Colors.white,
  137. backgroundColor: context.appColors.btnBgDefault,
  138. cornerRadius: 7,
  139. ),
  140. )),
  141. const SizedBox(width: 18),
  142. ],
  143. ).marginOnly(bottom: 30, top: 28),
  144. ],
  145. ),
  146. ),
  147. ],
  148. ).constrained(width: 300);
  149. }
  150. //取消弹框
  151. void onCancel() async {
  152. SmartDialog.dismiss();
  153. }
  154. }