bottomDialog.dart 4.1 KB

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