discount_ticket_dialog.dart 14 KB

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