surprise_dialog.dart 11 KB

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