surprise_dialog.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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:get/get.dart';
  5. import 'package:keyboard/resource/string.gen.dart';
  6. import 'package:lottie/lottie.dart';
  7. import '../../../data/consts/constants.dart';
  8. import '../../../data/consts/event_report.dart';
  9. import '../../../handler/event_handler.dart';
  10. import '../../../resource/assets.gen.dart';
  11. import '../../../resource/colors.gen.dart';
  12. import '../../../utils/styles.dart';
  13. import '../../../widget/horizontal_dashed_line.dart';
  14. import '../../../widget/vertical_dots.dart';
  15. import 'goods_surprise_controller.dart';
  16. // 限时活动 惊喜买断价弹窗
  17. class SurpriseDialog {
  18. static const String tag = 'SurpriseDialog';
  19. static void show({VoidCallback? clickConfirm,VoidCallback? clickCancel}) {
  20. EventHandler.report(EventId.event_02009);
  21. SmartDialog.show(
  22. tag: tag,
  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 Stack(
  31. children: [
  32. Positioned(
  33. top: 0,
  34. left: 0,
  35. right: 0,
  36. bottom: 0,
  37. child: Column(
  38. crossAxisAlignment: CrossAxisAlignment.center,
  39. mainAxisAlignment: MainAxisAlignment.center,
  40. children: [
  41. Stack(
  42. clipBehavior: Clip.none,
  43. children: [
  44. Container(
  45. width: 328.w,
  46. height: 290.h,
  47. decoration: BoxDecoration(
  48. image: DecorationImage(
  49. image: Assets.images.bgSurpriseDialog.provider(),
  50. fit: BoxFit.cover,
  51. ),
  52. ),
  53. child: Column(
  54. mainAxisAlignment: MainAxisAlignment.center,
  55. crossAxisAlignment: CrossAxisAlignment.center,
  56. children: [
  57. SizedBox(height: 23.h),
  58. Container(
  59. width: 240.w,
  60. height: 108.h,
  61. decoration: BoxDecoration(
  62. image: DecorationImage(
  63. image:
  64. Assets.images.bgSurpriseDialogPrices
  65. .provider(),
  66. fit: BoxFit.cover,
  67. ),
  68. ),
  69. child: Column(
  70. mainAxisAlignment: MainAxisAlignment.center,
  71. crossAxisAlignment: CrossAxisAlignment.center,
  72. children: [
  73. Obx(() {
  74. return _buildPricesPartOne(controller);
  75. }),
  76. HorizontalDashedLine(
  77. width: 200.w,
  78. color: Color(0xFFFF9451),
  79. strokeWidth: 2.h,
  80. dashLength: 5.w,
  81. dashSpace: 3.w,
  82. ),
  83. Obx(() {
  84. return Text(
  85. controller.firstAmount?.description ?? "",
  86. style: TextStyle(
  87. color: const Color(0xFFFFC172),
  88. fontSize: 10.sp,
  89. fontWeight: FontWeight.w400,
  90. height: 2,
  91. ),
  92. );
  93. }),
  94. ],
  95. ),
  96. ),
  97. SizedBox(height: 16.h),
  98. GestureDetector(
  99. onTap: () {
  100. EventHandler.report(EventId.event_02010);
  101. clickConfirm?.call();
  102. SmartDialog.dismiss(tag: tag);
  103. },
  104. child: Container(
  105. width: 240.w,
  106. height: 60.h,
  107. decoration: BoxDecoration(
  108. image: DecorationImage(
  109. image:
  110. Assets.images.bgSurpriseDialogButton
  111. .provider(),
  112. fit: BoxFit.cover,
  113. ),
  114. ),
  115. child: Column(
  116. mainAxisAlignment: MainAxisAlignment.center,
  117. crossAxisAlignment: CrossAxisAlignment.center,
  118. children: [
  119. SizedBox(
  120. child: Assets
  121. .images
  122. .iconSurpriseDialogButton
  123. .image(width: 120.w, height: 20.h),
  124. ),
  125. Visibility(
  126. visible: isNotHWChannel(),
  127. child: Obx(() {
  128. int totalMilliseconds =
  129. controller.timeLeft.value;
  130. int minutes = (totalMilliseconds ~/ 6000);
  131. int seconds =
  132. (totalMilliseconds ~/ 100) % 60;
  133. int milliseconds =
  134. (totalMilliseconds % 100); // 毫秒
  135. return Row(
  136. mainAxisAlignment:
  137. MainAxisAlignment.center,
  138. crossAxisAlignment:
  139. CrossAxisAlignment.center,
  140. children: [
  141. _buildTimeBox(
  142. minutes.toString().padLeft(2, '0'),
  143. ),
  144. VerticalDots(
  145. height: 8.h,
  146. dotSize: 2.w,
  147. ),
  148. _buildTimeBox(
  149. seconds.toString().padLeft(2, '0'),
  150. ),
  151. VerticalDots(
  152. height: 8.h,
  153. dotSize: 2.w,
  154. ),
  155. _buildTimeBox(
  156. milliseconds.toString().padLeft(
  157. 2,
  158. '0',
  159. ),
  160. ),
  161. Text(
  162. StringName.surpriseDialogEndDesc,
  163. style: Styles.getTextStyleWhiteW400(
  164. 10.sp,
  165. ),
  166. ),
  167. ],
  168. );
  169. }),)
  170. ],
  171. ),
  172. ),
  173. ),
  174. ],
  175. ),
  176. ),
  177. Positioned(
  178. top: -50,
  179. right: 0,
  180. left: 0,
  181. child: Assets.images.iconSurpriseDialogTitle.image(
  182. width: 264.w,
  183. height: 95.h,
  184. ),
  185. ),
  186. ],
  187. ),
  188. Container(
  189. margin: EdgeInsets.only(top: 24.h),
  190. child: GestureDetector(
  191. onTap: () {
  192. EventHandler.report(EventId.event_02011);
  193. SmartDialog.dismiss(tag: tag);
  194. clickCancel?.call();
  195. },
  196. child: Assets.images.iconCharacterDialogClose.image(
  197. width: 40.r,
  198. height: 40.r,
  199. ),
  200. ),
  201. ),
  202. ],
  203. ),
  204. ),
  205. IgnorePointer(
  206. child: Lottie.asset(
  207. Assets.anim.animSurpriseDialogData,
  208. repeat: false,
  209. width: 360.w,
  210. ),
  211. ),
  212. ],
  213. );
  214. },
  215. );
  216. }
  217. static Widget _buildPricesPartOne(GoodsSurpriseController controller) {
  218. return Row(
  219. mainAxisAlignment: MainAxisAlignment.center,
  220. crossAxisAlignment: CrossAxisAlignment.center,
  221. children: [
  222. Text(
  223. controller.firstAmount?.priceDescNumber ?? "",
  224. style: TextStyle(
  225. color: Colors.white,
  226. fontSize: 48.sp,
  227. fontWeight: FontWeight.w700,
  228. ),
  229. ),
  230. Column(
  231. children: [
  232. Container(
  233. width: 30.w,
  234. height: 18.h,
  235. decoration: BoxDecoration(
  236. image: DecorationImage(
  237. image: Assets.images.iconSurpriseDialogOnly.provider(),
  238. fit: BoxFit.cover,
  239. ),
  240. ),
  241. child: Center(
  242. child: Text(
  243. StringName.surpriseDialogOnly,
  244. style: TextStyle(
  245. color: const Color(0xFFFF451D),
  246. fontSize: 11.sp,
  247. fontWeight: FontWeight.w500,
  248. ),
  249. ),
  250. ),
  251. ),
  252. Text(
  253. controller.firstAmount?.priceDescUnit ?? '',
  254. style: TextStyle(
  255. color: Colors.white,
  256. fontSize: 14.sp,
  257. fontWeight: FontWeight.w700,
  258. ),
  259. ),
  260. ],
  261. ),
  262. ],
  263. );
  264. }
  265. static Widget _buildTimeBox(String value) {
  266. return Container(
  267. width: 18.w,
  268. height: 15.h,
  269. decoration: ShapeDecoration(
  270. color: Colors.white,
  271. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.r)),
  272. ),
  273. child: Center(
  274. child: Text(value, style: Styles.getTextStyleBlack204W500(10.sp)),
  275. ),
  276. );
  277. }
  278. }