surprise_dialog.dart 11 KB

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