discount_ticket_dialog.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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:lottie/lottie.dart';
  6. import '../../../resource/assets.gen.dart';
  7. import '../../../resource/colors.gen.dart';
  8. import '../../../utils/styles.dart';
  9. import '../suprise/goods_surprise_controller.dart';
  10. class DiscountTicketDialog {
  11. static const String tag = 'DiscountTicketDialog';
  12. static void show({VoidCallback? clickConfirm}) {
  13. SmartDialog.show(
  14. tag: tag,
  15. backType: SmartBackType.block,
  16. clickMaskDismiss: false,
  17. maskColor: ColorName.black70,
  18. builder: (_) {
  19. final controller = Get.find<GoodsSurpriseController>();
  20. return Stack(
  21. children: [
  22. Positioned(
  23. top: 0,
  24. left: 0,
  25. right: 0,
  26. bottom: 0,
  27. child: Column(
  28. crossAxisAlignment: CrossAxisAlignment.center,
  29. mainAxisAlignment: MainAxisAlignment.center,
  30. children: [
  31. Stack(
  32. clipBehavior: Clip.none,
  33. children: [
  34. Column(
  35. mainAxisAlignment: MainAxisAlignment.center,
  36. crossAxisAlignment: CrossAxisAlignment.center,
  37. children: [
  38. SizedBox(
  39. width: 360.h,
  40. height: 110.h,
  41. child: IgnorePointer(
  42. child: Lottie.asset(
  43. Assets.anim.animDiscountTicketDialogData,
  44. repeat: false,
  45. fit: BoxFit.contain,
  46. ),
  47. ),
  48. ),
  49. Container(
  50. margin: EdgeInsets.only(left: 31.h, right: 14.h),
  51. width: 317.w,
  52. height: 364.h,
  53. decoration: BoxDecoration(
  54. image: DecorationImage(
  55. image: Assets.images.bgTicketDialog.provider(),
  56. fit: BoxFit.cover,
  57. ),
  58. boxShadow: [
  59. BoxShadow(
  60. color: Colors.black.withAlpha(4), // 阴影颜色
  61. blurRadius: 10, // 模糊程度
  62. spreadRadius: 2, // 扩散程度
  63. offset: Offset(4, 4), // 偏移量 (x, y)
  64. ),
  65. ],
  66. ),
  67. child: Stack(
  68. children: [
  69. Column(
  70. mainAxisAlignment: MainAxisAlignment.start,
  71. crossAxisAlignment: CrossAxisAlignment.center,
  72. children: [
  73. SizedBox(height: 160.h),
  74. Container(
  75. margin: EdgeInsets.only(right: 16.h),
  76. decoration: BoxDecoration(
  77. image: DecorationImage(
  78. image:
  79. Assets.images.bgTicketDialogPrices
  80. .provider(),
  81. fit: BoxFit.cover,
  82. alignment: Alignment.center,
  83. ),
  84. ),
  85. width: 260.w,
  86. height: 100.h,
  87. child: Column(
  88. children: [
  89. Container(
  90. margin: EdgeInsets.only(top: 10.h),
  91. child: Obx(() {
  92. return Text(
  93. controller.secondAmount?.name ??
  94. "",
  95. style: TextStyle(
  96. color: const Color(
  97. 0xFFC39858,
  98. ),
  99. fontSize: 14.sp,
  100. fontWeight: FontWeight.w400,
  101. ),
  102. );
  103. }),
  104. ),
  105. Obx(() {
  106. return Text.rich(
  107. TextSpan(
  108. children: [
  109. TextSpan(
  110. text: '¥',
  111. style: TextStyle(
  112. color: const Color(
  113. 0xFFF55208,
  114. ),
  115. fontSize: 27.sp,
  116. fontWeight:
  117. FontWeight.w700,
  118. height: 0,
  119. ),
  120. ),
  121. TextSpan(
  122. text:
  123. controller
  124. .secondAmount
  125. ?.amountText,
  126. style: TextStyle(
  127. color: const Color(
  128. 0xFFF55208,
  129. ),
  130. height: 0,
  131. fontSize: 36.sp,
  132. fontWeight:
  133. FontWeight.w700,
  134. ),
  135. ),
  136. ],
  137. ),
  138. );
  139. }),
  140. Obx(() {
  141. return Text(
  142. controller
  143. .secondAmount
  144. ?.description ??
  145. "",
  146. style: TextStyle(
  147. color: Colors.black.withAlpha(
  148. 66,
  149. ),
  150. fontSize: 10.sp,
  151. fontWeight: FontWeight.w400,
  152. ),
  153. );
  154. }),
  155. ],
  156. ),
  157. ),
  158. Container(
  159. margin: EdgeInsets.only(right: 25.h),
  160. width: 317.w,
  161. height: 16.h,
  162. decoration: BoxDecoration(
  163. image: DecorationImage(
  164. image:
  165. Assets
  166. .images
  167. .bgTicketDialogPrices2
  168. .provider(),
  169. fit: BoxFit.cover,
  170. ),
  171. ),
  172. ),
  173. SizedBox(height: 9.h),
  174. GestureDetector(
  175. onTap: () {
  176. clickConfirm?.call();
  177. SmartDialog.dismiss(tag: tag);
  178. },
  179. child: Container(
  180. margin: EdgeInsets.only(right: 20.h),
  181. width: 200.w,
  182. height: 54.h,
  183. child: Assets
  184. .images
  185. .iconTicketDialogButton
  186. .image(width: 200.w, height: 54.h),
  187. ),
  188. ),
  189. ],
  190. ),
  191. // 倒计时
  192. Positioned(
  193. right: 40.w,
  194. child: Container(
  195. height: 24.h,
  196. width: 107.w,
  197. alignment: Alignment.center,
  198. decoration: ShapeDecoration(
  199. gradient: LinearGradient(
  200. begin: Alignment.centerLeft,
  201. end: Alignment.centerRight,
  202. colors: [
  203. const Color(0xFFFF68F4),
  204. const Color(0xFFF96432),
  205. ],
  206. ),
  207. shape: RoundedRectangleBorder(
  208. side: BorderSide(
  209. width: 1,
  210. color: Colors.white,
  211. ),
  212. borderRadius: BorderRadius.only(
  213. topLeft: Radius.circular(15.r),
  214. topRight: Radius.circular(16.r),
  215. bottomRight: Radius.circular(16.r),
  216. ),
  217. ),
  218. ),
  219. margin: EdgeInsets.only(top: 140.h),
  220. child: Obx(() {
  221. int totalMilliseconds =
  222. controller.timeLeft.value;
  223. int minutes = (totalMilliseconds ~/ 6000);
  224. int seconds =
  225. (totalMilliseconds ~/ 100) % 60;
  226. int milliseconds =
  227. (totalMilliseconds % 100); // 毫秒
  228. return Text(
  229. "${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}:${milliseconds.toString().padLeft(2, '0')} 后过期",
  230. style: TextStyle(
  231. color: Colors.white,
  232. fontSize: 12.sp,
  233. fontWeight: FontWeight.w500,
  234. ),
  235. );
  236. }),
  237. ),
  238. ),
  239. ],
  240. ),
  241. ),
  242. ],
  243. ),
  244. ],
  245. ),
  246. Container(
  247. margin: EdgeInsets.only(top: 24.h),
  248. child: GestureDetector(
  249. onTap: () {
  250. SmartDialog.dismiss(tag: tag);
  251. },
  252. child: Assets.images.iconCharacterDialogClose.image(
  253. width: 40.r,
  254. height: 40.r,
  255. ),
  256. ),
  257. ),
  258. ],
  259. ),
  260. ),
  261. ],
  262. );
  263. },
  264. );
  265. }
  266. }
  267. class VerticalDots extends StatelessWidget {
  268. final double dotSize;
  269. final double height;
  270. final Color? color;
  271. const VerticalDots({
  272. super.key,
  273. required this.dotSize,
  274. required this.height,
  275. this.color = Colors.white,
  276. });
  277. @override
  278. Widget build(BuildContext context) {
  279. return SizedBox(
  280. width: 2.w,
  281. height: 8.h,
  282. child: Column(
  283. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  284. children: List.generate(2, (index) {
  285. return Container(
  286. width: dotSize,
  287. height: dotSize,
  288. decoration: BoxDecoration(color: color, shape: BoxShape.circle),
  289. );
  290. }),
  291. ),
  292. );
  293. }
  294. }