comments_dialog.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import 'package:flutter/material.dart';
  2. import 'package:cs_resources/generated/l10n.dart';
  3. import 'package:widgets/ext/ex_widget.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:widgets/my_text_view.dart';
  6. import 'package:widgets/no_shadow_scroll_behavior.dart';
  7. import 'package:widgets/widget_export.dart';
  8. class CommentsDialog extends StatelessWidget {
  9. String? title;
  10. String? message;
  11. Widget? Function(BuildContext)? messageBuilder;
  12. VoidCallback confirmAction;
  13. VoidCallback? cancelAction;
  14. bool isShowCancelBtn;
  15. bool isShowConfirmBtn;
  16. String? confirmTxt;
  17. String? cancelTxt;
  18. double? height = 0.0;
  19. double? minHeight = 0.0;
  20. double? maxHeight = 300.0;
  21. CommentsDialog({
  22. this.title,
  23. this.message,
  24. Widget Function(BuildContext)? this.messageBuilder,
  25. required this.confirmAction,
  26. this.cancelAction,
  27. this.isShowCancelBtn = true,
  28. this.isShowConfirmBtn = true,
  29. this.confirmTxt,
  30. this.cancelTxt,
  31. height,
  32. minHeight,
  33. maxHeight,
  34. Key? key,
  35. }): height = height?? 0.0,
  36. minHeight = minHeight?? 0.0,
  37. maxHeight = maxHeight?? 5000,
  38. super(key:key);
  39. @override
  40. Widget build(BuildContext context) {
  41. return Container(
  42. width: double.infinity,
  43. padding: const EdgeInsets.only(top: 30),
  44. constraints: BoxConstraints(
  45. minHeight: minHeight!,
  46. maxHeight: maxHeight!,
  47. ),
  48. decoration: BoxDecoration(
  49. color: context.appColors.whiteSecondBG,
  50. borderRadius: const BorderRadius.only(
  51. topLeft: Radius.circular(0),
  52. topRight: Radius.circular(0),
  53. ),
  54. ),
  55. child: SizedBox(
  56. height: height!,
  57. child: Column(
  58. crossAxisAlignment: CrossAxisAlignment.center,
  59. children: [
  60. Expanded(
  61. child: Scrollbar(
  62. child: ScrollConfiguration(
  63. behavior: NoShadowScrollBehavior(),
  64. child: SingleChildScrollView(
  65. child: messageBuilder?.call(context) ??
  66. MyTextView(
  67. message!,
  68. fontSize: 18,
  69. textColor: context.appColors.textBlack,
  70. isFontRegular: true,
  71. textAlign: TextAlign.center,
  72. paddingLeft: 30,
  73. paddingRight: 30,
  74. ),
  75. ),
  76. ),
  77. ).constrained(maxHeight: maxHeight! - 60),
  78. ),
  79. Row(
  80. children: [
  81. const SizedBox(width: 18),
  82. Visibility(
  83. visible: isShowCancelBtn,
  84. child: Expanded(
  85. flex: 1,
  86. child: InkWell(
  87. onTap: () {
  88. onCancel();
  89. cancelAction?.call();
  90. },
  91. child: MyTextView(
  92. cancelTxt ?? S.current.no,
  93. fontSize: 16,
  94. isFontMedium: true,
  95. paddingTop: 13,
  96. marginRight: 15,
  97. paddingBottom: 13,
  98. textAlign: TextAlign.center,
  99. textColor: Colors.white,
  100. backgroundColor: context.appColors.orangeBG,
  101. cornerRadius: 7,
  102. ),
  103. )),
  104. ),
  105. Expanded(
  106. flex: 1,
  107. child: Visibility(
  108. visible: isShowConfirmBtn,
  109. child: InkWell(
  110. onTap: () async {
  111. onCancel();
  112. confirmAction();
  113. },
  114. child: MyTextView(
  115. confirmTxt ?? S.current.yes,
  116. fontSize: 16,
  117. paddingTop: 13,
  118. paddingBottom: 13,
  119. isFontMedium: true,
  120. textAlign: TextAlign.center,
  121. textColor: Colors.white,
  122. backgroundColor: context.appColors.btnBgDefault,
  123. cornerRadius: 7,
  124. ),
  125. ),
  126. )),
  127. const SizedBox(width: 18),
  128. ],
  129. ).marginOnly(bottom: 30, top: 28),
  130. ],
  131. ),
  132. ),
  133. );
  134. }
  135. //取消弹框
  136. void onCancel() async {
  137. SmartDialog.dismiss();
  138. }
  139. }