tips_dialog.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  4. import 'package:keyboard/resource/string.gen.dart';
  5. import '../resource/assets.gen.dart';
  6. import '../resource/colors.gen.dart';
  7. import '../utils/styles.dart';
  8. // 温馨提示弹窗
  9. class TipsDialog {
  10. static const String tag = 'TipsDialog';
  11. static void show({
  12. String? title,
  13. String? desc,
  14. String? btnCancelText,
  15. String? btnConfirmText,
  16. Function? btnCancel,
  17. Function? btnConfirm,
  18. }) {
  19. SmartDialog.show(
  20. tag: tag,
  21. backType: SmartBackType.block,
  22. clickMaskDismiss: true,
  23. maskColor: ColorName.black70,
  24. alignment: Alignment.center,
  25. builder: (_) {
  26. return Column(
  27. crossAxisAlignment: CrossAxisAlignment.center,
  28. mainAxisAlignment: MainAxisAlignment.center,
  29. children: [
  30. Container(
  31. width: double.infinity,
  32. margin: EdgeInsets.symmetric(horizontal: 31.w),
  33. decoration: ShapeDecoration(
  34. color: Colors.white,
  35. shape: RoundedRectangleBorder(
  36. borderRadius: BorderRadius.circular(20.r),
  37. ),
  38. ),
  39. child: Stack(
  40. children: [
  41. Container(
  42. padding: EdgeInsets.symmetric(
  43. horizontal: 16.w,
  44. vertical: 24.h,
  45. ),
  46. child: Column(
  47. mainAxisSize: MainAxisSize.min,
  48. crossAxisAlignment: CrossAxisAlignment.center,
  49. mainAxisAlignment: MainAxisAlignment.center,
  50. children: [
  51. Text(
  52. title ?? "",
  53. style: Styles.getTextStyleBlack204W500(16.sp),
  54. ),
  55. SizedBox(height: 16.h),
  56. Text(
  57. desc ?? "",
  58. style: Styles.getTextStyleBlack204W400(14.sp),
  59. ),
  60. SizedBox(height: 20.h),
  61. Row(
  62. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  63. children: [
  64. Expanded(
  65. child: GestureDetector(
  66. onTap: () {
  67. if (btnCancel != null) {
  68. btnCancel();
  69. }
  70. SmartDialog.dismiss();
  71. },
  72. child: Container(
  73. height: 48.h,
  74. alignment: Alignment.center,
  75. decoration: ShapeDecoration(
  76. color: const Color(0xFFF5F4F9),
  77. shape: RoundedRectangleBorder(
  78. borderRadius: BorderRadius.circular(
  79. 31.r,
  80. ),
  81. ),
  82. ),
  83. child: Text(
  84. btnCancelText ?? "",
  85. style: TextStyle(
  86. color: Color(0xFF949396),
  87. fontSize: 16.sp,
  88. fontWeight: FontWeight.w500,
  89. ),
  90. ),
  91. ),
  92. ),
  93. ),
  94. SizedBox(width: 16.w),
  95. Expanded(
  96. child: GestureDetector(
  97. onTap: () {
  98. if (btnConfirm != null) {
  99. btnConfirm();
  100. }
  101. SmartDialog.dismiss(tag: tag);
  102. },
  103. child: Container(
  104. height: 48.h,
  105. alignment: Alignment.center,
  106. decoration:
  107. Styles.getActivateButtonDecoration(
  108. 31.r,
  109. ),
  110. child: Text(
  111. btnConfirmText ?? "",
  112. style: Styles.getTextStyleWhiteW500(
  113. 16.sp,
  114. ),
  115. ),
  116. ),
  117. ),
  118. ),
  119. ],
  120. ),
  121. ],
  122. ),
  123. ),
  124. Positioned(
  125. right: 14.w,
  126. top: 14.h,
  127. child: GestureDetector(
  128. onTap: () {
  129. SmartDialog.dismiss();
  130. },
  131. child: Assets.images.iconCustomDialogClose.image(
  132. width: 24.w,
  133. height: 24.h,
  134. ),
  135. ),
  136. ),
  137. ],
  138. ),
  139. ),
  140. ],
  141. );
  142. },
  143. );
  144. }
  145. }