new_surprise_dialog.dart 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. import 'dart:ui';
  2. import 'package:flutter/Material.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  6. import 'package:get/get.dart';
  7. import 'package:keyboard/module/store/suprise/goods_surprise_controller.dart';
  8. import '../../../data/consts/constants.dart';
  9. import '../../../data/consts/event_report.dart';
  10. import '../../../handler/event_handler.dart';
  11. import '../../../resource/assets.gen.dart';
  12. import '../../../resource/colors.gen.dart';
  13. import '../../../resource/string.gen.dart';
  14. import '../../../widget/horizontal_dashed_line.dart';
  15. class NewSurpriseDialog {
  16. static const String tag = 'NewSurpriseDialog';
  17. static void show({VoidCallback? clickConfirm, VoidCallback? clickCancel}) {
  18. EventHandler.report(EventId.event_02009);
  19. if (SmartDialog.checkExist(tag: tag)) return;
  20. SmartDialog.show(
  21. tag: tag,
  22. keepSingle: true,
  23. backType: SmartBackType.block,
  24. clickMaskDismiss: false,
  25. maskColor: ColorName.black70,
  26. onDismiss: () => Get.delete<GoodsSurpriseController>(),
  27. animationType: SmartAnimationType.centerScale_otherSlide,
  28. builder: (_) {
  29. final controller = Get.find<GoodsSurpriseController>();
  30. return Column(
  31. crossAxisAlignment: CrossAxisAlignment.center,
  32. mainAxisAlignment: MainAxisAlignment.start,
  33. children: [
  34. SizedBox(height: 243.h),
  35. Stack(
  36. clipBehavior: Clip.none,
  37. children: [
  38. Positioned(
  39. top: -153.h,
  40. child: Assets.images.iconNewSurpriseDialog531.image(
  41. width: 318.w,
  42. height: 183.h,
  43. fit: BoxFit.contain,
  44. ),
  45. ),
  46. Assets.images.bgNewSurpriseDialog.image(width: 351.w),
  47. Positioned(
  48. left: 0,
  49. right: 0,
  50. child: Column(
  51. children: [
  52. Assets.images.iconNewSurpriseDialogOnly.image(
  53. width: 178.32.w,
  54. height: 69.31.h,
  55. ),
  56. SizedBox(height: 7.2.h),
  57. Container(
  58. width: 240.w,
  59. height: 108.h,
  60. decoration: BoxDecoration(
  61. image: DecorationImage(
  62. image:
  63. Assets.images.bgNewSurpriseDialogContent
  64. .provider(),
  65. fit: BoxFit.contain,
  66. ),
  67. ),
  68. child: Column(
  69. mainAxisAlignment: MainAxisAlignment.center,
  70. crossAxisAlignment: CrossAxisAlignment.center,
  71. children: [
  72. SizedBox(height: 15.h),
  73. Obx(() {
  74. return _buildPricesPartOne(controller);
  75. }),
  76. HorizontalDashedLine(
  77. width: 200.w,
  78. color: Color(0xFFFFA0AE),
  79. strokeWidth: 2.h,
  80. dashLength: 5.w,
  81. dashSpace: 3.w,
  82. ),
  83. SizedBox(height: 5.h),
  84. Obx(() {
  85. return Text(
  86. controller.firstAmount?.description ?? "",
  87. style: TextStyle(
  88. color: const Color(0xFFFFF2F4),
  89. fontSize: 10.sp,
  90. fontWeight: FontWeight.w400,
  91. height: 2,
  92. ),
  93. );
  94. }),
  95. ],
  96. ),
  97. ),
  98. SizedBox(height: 7.86.h),
  99. GestureDetector(
  100. onTap: () {
  101. EventHandler.report(EventId.event_02010);
  102. clickConfirm?.call();
  103. SmartDialog.dismiss(tag: tag);
  104. },
  105. child: SizedBox(
  106. width: 240.w,
  107. height: 60.h,
  108. child: SizedBox(
  109. child: Assets.images.iconNewSurpriseDialogButton
  110. .image(width: 240.w, height: 60.h),
  111. ),
  112. ),
  113. ),
  114. ],
  115. ),
  116. ),
  117. Positioned(
  118. right: 20.w,
  119. bottom: -5.h,
  120. child: IgnorePointer(
  121. child: Assets.images.iconNewSurpriseDialogHand.image(
  122. width: 78.w,
  123. height: 79.h,
  124. ),
  125. ),
  126. ),
  127. ],
  128. ),
  129. SizedBox(height: 26.h),
  130. GestureDetector(
  131. onTap: () {
  132. EventHandler.report(EventId.event_02011);
  133. SmartDialog.dismiss(tag: tag);
  134. clickCancel?.call();
  135. },
  136. child: Assets.images.iconNewSurpriseDialogClose.image(
  137. width: 40.r,
  138. height: 40.r,
  139. ),
  140. ),
  141. ],
  142. );
  143. },
  144. );
  145. }
  146. static Widget _buildPricesPartOne(GoodsSurpriseController controller) {
  147. return Stack(
  148. children: [
  149. Row(
  150. mainAxisAlignment: MainAxisAlignment.center,
  151. crossAxisAlignment: CrossAxisAlignment.center,
  152. children: [
  153. Text(
  154. controller.firstAmount?.priceDescNumber ?? "",
  155. style: TextStyle(
  156. color: Colors.white,
  157. fontSize: 42.sp,
  158. fontWeight: FontWeight.w900,
  159. height: 0,
  160. ),
  161. ),
  162. Column(
  163. children: [
  164. Container(
  165. width: 30.w,
  166. height: 18.h,
  167. decoration: BoxDecoration(
  168. image: DecorationImage(
  169. image: Assets.images.iconSurpriseDialogOnly.provider(),
  170. fit: BoxFit.cover,
  171. ),
  172. ),
  173. child: Center(
  174. child: Text(
  175. StringName.surpriseDialogOnly,
  176. style: TextStyle(
  177. color: const Color(0xFFFF451D),
  178. fontSize: 11.sp,
  179. fontWeight: FontWeight.w500,
  180. ),
  181. ),
  182. ),
  183. ),
  184. Text(
  185. controller.firstAmount?.priceDescUnit ?? '',
  186. style: TextStyle(
  187. color: Colors.white,
  188. fontSize: 14.sp,
  189. fontWeight: FontWeight.w700,
  190. ),
  191. ),
  192. ],
  193. ),
  194. ],
  195. ),
  196. Positioned(
  197. top: 5.r,
  198. left: 47.30.w,
  199. child: Container(
  200. padding: EdgeInsets.symmetric(horizontal: 2.w),
  201. transform:
  202. Matrix4.identity()
  203. ..translate(0.0, 0.0)
  204. ..rotateZ(-0.41),
  205. decoration: ShapeDecoration(
  206. color: const Color(0xFFD8FF1E),
  207. shape: RoundedRectangleBorder(
  208. borderRadius: BorderRadius.circular(3.r),
  209. ),
  210. ),
  211. child: Text(
  212. controller.firstAmount?.name ?? "",
  213. textAlign: TextAlign.center,
  214. style: TextStyle(
  215. color: const Color(0xFF231815),
  216. fontSize: 12.sp,
  217. fontWeight: FontWeight.w700,
  218. letterSpacing: -0.36,
  219. ),
  220. ),
  221. ),
  222. ),
  223. ],
  224. );
  225. }
  226. }