surprise_dialog.dart 12 KB

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