new_discount_ticket_dialog.dart 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import 'dart:ui';
  2. import 'package:flutter/Material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:get/get.dart';
  6. import '../../../data/consts/event_report.dart';
  7. import '../../../handler/event_handler.dart';
  8. import '../../../resource/assets.gen.dart';
  9. import '../../../resource/colors.gen.dart';
  10. import '../suprise/goods_surprise_controller.dart';
  11. class NewDiscountTicketDialog {
  12. static const String tag = 'NewDiscountTicketDialog';
  13. static void show({VoidCallback? clickConfirm, VoidCallback? clickCancel}) {
  14. EventHandler.report(EventId.event_02006);
  15. if (SmartDialog.checkExist(tag: tag)) return;
  16. SmartDialog.show(
  17. tag: tag,
  18. keepSingle: true,
  19. backType: SmartBackType.block,
  20. clickMaskDismiss: false,
  21. maskColor: ColorName.black70,
  22. onDismiss: () => Get.delete<GoodsSurpriseController>(),
  23. animationType: SmartAnimationType.centerScale_otherSlide,
  24. builder: (_) {
  25. final controller = Get.find<GoodsSurpriseController>();
  26. return Column(
  27. crossAxisAlignment: CrossAxisAlignment.center,
  28. mainAxisAlignment: MainAxisAlignment.start,
  29. children: [
  30. SizedBox(height: 50.h),
  31. Stack(
  32. clipBehavior: Clip.none,
  33. children: [
  34. Container(
  35. width: 360.w,
  36. height: 567.h,
  37. decoration: BoxDecoration(
  38. image: DecorationImage(
  39. image: Assets.images.bgNewDiscountTicket.provider(),
  40. fit: BoxFit.contain,
  41. ),
  42. ),
  43. child: Column(
  44. children: [
  45. SizedBox(height: 305.h),
  46. Container(
  47. width: 240.w,
  48. height: 119.h,
  49. decoration: BoxDecoration(
  50. image: DecorationImage(
  51. image:
  52. Assets.images.bgNewDiscountTicketContent
  53. .provider(),
  54. fit: BoxFit.contain,
  55. ),
  56. ),
  57. child: Column(
  58. mainAxisAlignment: MainAxisAlignment.start,
  59. crossAxisAlignment: CrossAxisAlignment.center,
  60. children: [
  61. SizedBox(height: 3.h),
  62. Obx(() {
  63. return Container(
  64. padding: EdgeInsets.symmetric(
  65. horizontal: 10.w,
  66. vertical: 2.h,
  67. ),
  68. decoration: BoxDecoration(
  69. color: Color(0xFFFFE1D9),
  70. borderRadius: BorderRadius.only(
  71. bottomLeft: Radius.circular(10.r),
  72. bottomRight: Radius.circular(10.r),
  73. ),
  74. ),
  75. child: Text(
  76. controller.secondAmount?.name ?? '',
  77. style: TextStyle(
  78. color: const Color(0xFFFF2F79),
  79. fontSize: 13.sp,
  80. fontWeight: FontWeight.w500,
  81. ),
  82. ),
  83. );
  84. }),
  85. SizedBox(height: 10.h,),
  86. Row(
  87. mainAxisAlignment: MainAxisAlignment.center,
  88. crossAxisAlignment: CrossAxisAlignment.end,
  89. children: [
  90. Stack(
  91. clipBehavior: Clip.none,
  92. children: [
  93. Obx(() {
  94. var amountText = controller.secondAmount?.amountText;
  95. if (controller.storeRepository.isDiscount.value) {
  96. amountText = controller.secondAmount?.firstAmountText;
  97. }
  98. return Text(
  99. amountText,
  100. style: TextStyle(
  101. color: const Color(0xFFFF005A),
  102. fontSize: 42.sp,
  103. fontWeight: FontWeight.w900,
  104. height: 0,
  105. ),
  106. );
  107. }),
  108. Positioned(
  109. bottom: 5.h,
  110. right: -12.w,
  111. child: _unit(),
  112. ),
  113. ],
  114. ),
  115. ],
  116. ),
  117. Obx(() {
  118. return Text(
  119. controller.secondAmount?.description ?? "",
  120. style: TextStyle(
  121. color: const Color(0xFFEA8AAC),
  122. fontSize: 12.sp,
  123. fontWeight: FontWeight.w400,
  124. ),
  125. );
  126. }),
  127. ],
  128. ),
  129. ),
  130. SizedBox(height: 18.h),
  131. GestureDetector(
  132. onTap: () {
  133. EventHandler.report(EventId.event_02010);
  134. clickConfirm?.call();
  135. SmartDialog.dismiss(tag: tag);
  136. },
  137. child: SizedBox(
  138. width: 240.w,
  139. height: 60.h,
  140. child: SizedBox(
  141. child: Assets.images.iconNewDiscountTicketButton
  142. .image(
  143. width: 260.w,
  144. height: 50.h,
  145. fit: BoxFit.contain,
  146. ),
  147. ),
  148. ),
  149. ),
  150. ],
  151. ),
  152. ),
  153. Positioned(
  154. right: 25.w,
  155. bottom: 20.h,
  156. child: IgnorePointer(
  157. child: Assets.images.iconNewSurpriseDialogHand.image(
  158. width: 78.w,
  159. height: 79.h,
  160. ),
  161. ),
  162. ),
  163. ],
  164. ),
  165. Transform.translate(
  166. offset: Offset(0, -20.h),
  167. child: GestureDetector(
  168. onTap: () {
  169. EventHandler.report(EventId.event_02011);
  170. SmartDialog.dismiss(tag: tag);
  171. clickCancel?.call();
  172. },
  173. child: Assets.images.iconNewSurpriseDialogClose.image(
  174. width: 40.r,
  175. height: 40.r,
  176. ),
  177. ),
  178. ),
  179. ],
  180. );
  181. },
  182. );
  183. }
  184. static Widget _unit() {
  185. return Container(
  186. width: 20.w,
  187. height: 20.w,
  188. decoration: ShapeDecoration(
  189. color: const Color(0xFFFF005A),
  190. shape: OvalBorder(
  191. side: BorderSide(
  192. width: 2.w,
  193. strokeAlign: BorderSide.strokeAlignCenter,
  194. color: Colors.white,
  195. ),
  196. ),
  197. ),
  198. child: Center(
  199. child: Text(
  200. '元',
  201. style: TextStyle(
  202. color: Colors.white,
  203. fontSize: 12.sp,
  204. fontWeight: FontWeight.w700,
  205. height: 1.67,
  206. ),
  207. ),
  208. ),
  209. );
  210. }
  211. }