discount_ticket_dialog.dart 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. ),
  119. ),
  120. TextSpan(
  121. text:
  122. controller
  123. .secondAmount
  124. ?.amountText,
  125. style: TextStyle(
  126. color: const Color(
  127. 0xFFF55208,
  128. ),
  129. fontSize: 36.sp,
  130. fontWeight:
  131. FontWeight.w700,
  132. ),
  133. ),
  134. ],
  135. ),
  136. );
  137. }),
  138. ],
  139. ),
  140. ),
  141. Container(
  142. margin: EdgeInsets.only(right: 25.h),
  143. width: 317.w,
  144. height: 16.h,
  145. decoration: BoxDecoration(
  146. image: DecorationImage(
  147. image:
  148. Assets
  149. .images
  150. .bgTicketDialogPrices2
  151. .provider(),
  152. fit: BoxFit.cover,
  153. ),
  154. ),
  155. ),
  156. SizedBox(height: 9.h),
  157. GestureDetector(
  158. onTap: () {
  159. clickConfirm?.call();
  160. SmartDialog.dismiss(tag: tag);
  161. },
  162. child: Container(
  163. margin: EdgeInsets.only(right: 20.h),
  164. width: 200.w,
  165. height: 54.h,
  166. child: Assets
  167. .images
  168. .iconTicketDialogButton
  169. .image(width: 200.w, height: 54.h),
  170. ),
  171. ),
  172. ],
  173. ),
  174. // 倒计时
  175. Positioned(
  176. right: 40.w,
  177. child: Container(
  178. height: 24.h,
  179. width: 107.w,
  180. alignment: Alignment.center,
  181. decoration: ShapeDecoration(
  182. gradient: LinearGradient(
  183. begin: Alignment.centerLeft,
  184. end: Alignment.centerRight,
  185. colors: [
  186. const Color(0xFFFF68F4),
  187. const Color(0xFFF96432),
  188. ],
  189. ),
  190. shape: RoundedRectangleBorder(
  191. side: BorderSide(
  192. width: 1,
  193. color: Colors.white,
  194. ),
  195. borderRadius: BorderRadius.only(
  196. topLeft: Radius.circular(15.r),
  197. topRight: Radius.circular(16.r),
  198. bottomRight: Radius.circular(16.r),
  199. ),
  200. ),
  201. ),
  202. margin: EdgeInsets.only(top: 140.h),
  203. child: Obx(() {
  204. int totalMilliseconds =
  205. controller.timeLeft.value;
  206. int minutes = (totalMilliseconds ~/ 6000);
  207. int seconds =
  208. (totalMilliseconds ~/ 100) % 60;
  209. int milliseconds =
  210. (totalMilliseconds % 100); // 毫秒
  211. return Text(
  212. "${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}:${milliseconds.toString().padLeft(2, '0')} 后过期",
  213. style: TextStyle(
  214. color: Colors.white,
  215. fontSize: 12.sp,
  216. fontWeight: FontWeight.w500,
  217. ),
  218. );
  219. }),
  220. ),
  221. ),
  222. ],
  223. ),
  224. ),
  225. ],
  226. ),
  227. ],
  228. ),
  229. Container(
  230. margin: EdgeInsets.only(top: 24.h),
  231. child: GestureDetector(
  232. onTap: () {
  233. SmartDialog.dismiss(tag: tag);
  234. },
  235. child: Assets.images.iconCharacterDialogClose.image(
  236. width: 40.r,
  237. height: 40.r,
  238. ),
  239. ),
  240. ),
  241. ],
  242. ),
  243. ),
  244. ],
  245. );
  246. },
  247. );
  248. }
  249. }
  250. class VerticalDots extends StatelessWidget {
  251. final double dotSize;
  252. final double height;
  253. final Color? color;
  254. const VerticalDots({
  255. super.key,
  256. required this.dotSize,
  257. required this.height,
  258. this.color = Colors.white,
  259. });
  260. @override
  261. Widget build(BuildContext context) {
  262. return SizedBox(
  263. width: 2.w,
  264. height: 8.h,
  265. child: Column(
  266. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  267. children: List.generate(2, (index) {
  268. return Container(
  269. width: dotSize,
  270. height: dotSize,
  271. decoration: BoxDecoration(color: color, shape: BoxShape.circle),
  272. );
  273. }),
  274. ),
  275. );
  276. }
  277. }