app_default_dialog.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  3. import 'package:get/get.dart';
  4. import 'package:cs_resources/generated/assets.dart';
  5. import 'package:widgets/ext/ex_widget.dart';
  6. import 'package:cs_resources/constants/color_constants.dart';
  7. import '../my_load_image.dart';
  8. import '../my_text_view.dart';
  9. import '../no_shadow_scroll_behavior.dart';
  10. import '../utils/dark_theme_util.dart';
  11. class AppDefaultDialog extends StatelessWidget {
  12. VoidCallback? cancelAction;
  13. VoidCallback? confirmAction;
  14. String? cancelText;
  15. String? confirmText;
  16. String? title;
  17. String message;
  18. AppDefaultDialog(this.message, {this.cancelText, this.cancelAction, this.confirmText, this.confirmAction, this.title});
  19. @override
  20. Widget build(BuildContext context) {
  21. return Column(
  22. crossAxisAlignment: CrossAxisAlignment.center,
  23. mainAxisAlignment: MainAxisAlignment.center,
  24. children: [
  25. //Title
  26. Container(
  27. decoration: BoxDecoration(
  28. color: DarkThemeUtil.multiColors(ColorConstants.appBlue, darkColor: ColorConstants.darkBlackItemLight),
  29. borderRadius: const BorderRadius.only(
  30. topLeft: Radius.circular(5),
  31. topRight: Radius.circular(5),
  32. ),
  33. ),
  34. padding: const EdgeInsets.only(left: 30, right: 10, top: 5, bottom: 5),
  35. child: Row(
  36. children: [
  37. Expanded(
  38. child: MyTextView(
  39. title ?? "提示".tr,
  40. fontSize: 18,
  41. marginTop: 14,
  42. marginBottom: 14,
  43. isFontMedium: true,
  44. textColor: ColorConstants.whitefe,
  45. textAlign: TextAlign.center,
  46. ),
  47. ),
  48. //Cancel
  49. InkWell(
  50. onTap: onCancel,
  51. child: MyLoadImage(
  52. Assets.baseLibDialogDeleteIcon,
  53. width: 26,
  54. height: 26,
  55. ),
  56. ),
  57. ],
  58. ),
  59. ),
  60. DecoratedBox(
  61. decoration: BoxDecoration(
  62. color: DarkThemeUtil.multiColors(Colors.white, darkColor: ColorConstants.darkBlackItemLightMost),
  63. borderRadius: const BorderRadius.only(
  64. bottomLeft: Radius.circular(5),
  65. bottomRight: Radius.circular(5),
  66. ),
  67. ),
  68. child: Column(
  69. children: [
  70. //文本的高度限制,加入滚动并去除边界波纹效果
  71. ScrollConfiguration(
  72. behavior: NoShadowScrollBehavior(),
  73. child: SingleChildScrollView(
  74. child: MyTextView(
  75. message,
  76. fontSize: 16,
  77. textColor: DarkThemeUtil.multiColors(const Color(0xff333333), darkColor: Colors.white),
  78. isFontRegular: true,
  79. textAlign: TextAlign.center,
  80. paddingLeft: 30,
  81. paddingRight: 30,
  82. paddingBottom: 25,
  83. marginTop: 25,
  84. ),
  85. )).marginSymmetric(vertical: 10).constrained(maxHeight: 400),
  86. //Buttons
  87. Row(
  88. children: [
  89. Expanded(
  90. flex: 1,
  91. child: InkWell(
  92. onTap: () {
  93. onCancel();
  94. cancelAction?.call();
  95. },
  96. child: MyTextView(
  97. cancelText ?? "Cancel".tr,
  98. marginLeft: 20,
  99. marginBottom: 35,
  100. paddingTop: 10,
  101. paddingBottom: 10,
  102. fontSize: 14,
  103. isFontRegular: true,
  104. textAlign: TextAlign.center,
  105. textColor: DarkThemeUtil.multiColors(ColorConstants.blue1578fe, darkColor: Colors.white),
  106. borderColor: DarkThemeUtil.multiColors(ColorConstants.blue1578fe, darkColor: Colors.white),
  107. cornerRadius: 3,
  108. borderWidth: 1,
  109. ),
  110. )),
  111. Expanded(
  112. flex: 1,
  113. child: InkWell(
  114. onTap: () {
  115. onCancel();
  116. confirmAction?.call();
  117. },
  118. child: MyTextView(
  119. confirmText ?? "Confirm".tr,
  120. marginLeft: 10,
  121. paddingTop: 10,
  122. paddingBottom: 10,
  123. fontSize: 14,
  124. isFontRegular: true,
  125. marginRight: 20,
  126. marginBottom: 35,
  127. textAlign: TextAlign.center,
  128. textColor: Colors.white,
  129. backgroundColor: ColorConstants.blue1578fe,
  130. cornerRadius: 3,
  131. ),
  132. )),
  133. ],
  134. ),
  135. ],
  136. ),
  137. ),
  138. ],
  139. ).constrained(width: 295);
  140. }
  141. //取消弹框
  142. void onCancel() async {
  143. SmartDialog.dismiss();
  144. }
  145. }