discount_ticket_dialog.dart 14 KB

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