tips_dialog.dart 5.7 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. builder: (_) {
  25. return Scaffold(
  26. backgroundColor: Colors.transparent,
  27. body: Column(
  28. crossAxisAlignment: CrossAxisAlignment.center,
  29. mainAxisAlignment: MainAxisAlignment.center,
  30. children: [
  31. Container(
  32. width: double.infinity,
  33. margin: EdgeInsets.symmetric(horizontal: 31.w),
  34. decoration: ShapeDecoration(
  35. color: Colors.white,
  36. shape: RoundedRectangleBorder(
  37. borderRadius: BorderRadius.circular(20.r),
  38. ),
  39. ),
  40. child: Stack(
  41. children: [
  42. Container(
  43. padding: EdgeInsets.symmetric(
  44. horizontal: 16.w,
  45. vertical: 24.h,
  46. ),
  47. child: Column(
  48. mainAxisSize: MainAxisSize.min,
  49. crossAxisAlignment: CrossAxisAlignment.center,
  50. mainAxisAlignment: MainAxisAlignment.center,
  51. children: [
  52. Text(
  53. title ?? "",
  54. style: Styles.getTextStyleBlack204W500(16.sp),
  55. ),
  56. SizedBox(height: 16.h),
  57. Text(
  58. desc ?? "",
  59. style: Styles.getTextStyleBlack204W400(14.sp),
  60. ),
  61. SizedBox(height: 20.h),
  62. Row(
  63. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  64. children: [
  65. Expanded(
  66. child: GestureDetector(
  67. onTap: () {
  68. if (btnCancel != null) {
  69. btnCancel();
  70. }
  71. SmartDialog.dismiss();
  72. },
  73. child: Container(
  74. height: 48.h,
  75. alignment: Alignment.center,
  76. decoration: ShapeDecoration(
  77. color: const Color(0xFFF5F4F9),
  78. shape: RoundedRectangleBorder(
  79. borderRadius: BorderRadius.circular(
  80. 31.r,
  81. ),
  82. ),
  83. ),
  84. child: Text(
  85. btnCancelText ?? "",
  86. style: Styles.getTextStyleBlack204W500(
  87. 16.sp,
  88. ),
  89. ),
  90. ),
  91. ),
  92. ),
  93. SizedBox(width: 16.w),
  94. Expanded(
  95. child: GestureDetector(
  96. onTap: () {
  97. if (btnConfirm != null) {
  98. btnConfirm();
  99. }
  100. SmartDialog.dismiss(tag: tag);
  101. },
  102. child: Container(
  103. height: 48.h,
  104. alignment: Alignment.center,
  105. decoration:
  106. Styles.getActivateButtonDecoration(
  107. 31.r,
  108. ),
  109. child: Text(
  110. btnConfirmText ?? "",
  111. style: Styles.getTextStyleWhiteW500(
  112. 16.sp,
  113. ),
  114. ),
  115. ),
  116. ),
  117. ),
  118. ],
  119. ),
  120. ],
  121. ),
  122. ),
  123. Positioned(
  124. right: 14.w,
  125. top: 14.h,
  126. child: GestureDetector(
  127. onTap: () {
  128. SmartDialog.dismiss();
  129. },
  130. child: Assets.images.iconCustomDialogClose.image(
  131. width: 24.w,
  132. height: 24.h,
  133. ),
  134. ),
  135. ),
  136. ],
  137. ),
  138. ),
  139. ],
  140. ),
  141. );
  142. },
  143. );
  144. }
  145. }