import 'dart:ui'; import 'package:flutter/Material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:keyboard/module/store/suprise/goods_surprise_controller.dart'; import '../../../data/consts/constants.dart'; import '../../../data/consts/event_report.dart'; import '../../../handler/event_handler.dart'; import '../../../resource/assets.gen.dart'; import '../../../resource/colors.gen.dart'; import '../../../resource/string.gen.dart'; import '../../../widget/horizontal_dashed_line.dart'; class NewSurpriseDialog { static const String tag = 'NewSurpriseDialog'; static void show({VoidCallback? clickConfirm, VoidCallback? clickCancel}) { EventHandler.report(EventId.event_02009); if (SmartDialog.checkExist(tag: tag)) return; SmartDialog.show( tag: tag, keepSingle: true, backType: SmartBackType.block, clickMaskDismiss: false, maskColor: ColorName.black70, onDismiss: () => Get.delete(), animationType: SmartAnimationType.centerScale_otherSlide, builder: (_) { final controller = Get.find(); return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox(height: 243.h), Stack( clipBehavior: Clip.none, children: [ Positioned( top: -153.h, child: Assets.images.iconNewSurpriseDialog531.image( width: 318.w, height: 183.h, fit: BoxFit.contain, ), ), Assets.images.bgNewSurpriseDialog.image(width: 351.w), Positioned( left: 0, right: 0, child: Column( children: [ Assets.images.iconNewSurpriseDialogOnly.image( width: 178.32.w, height: 69.31.h, ), SizedBox(height: 7.2.h), Container( width: 240.w, height: 108.h, decoration: BoxDecoration( image: DecorationImage( image: Assets.images.bgNewSurpriseDialogContent .provider(), fit: BoxFit.contain, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox(height: 15.h), Obx(() { return _buildPricesPartOne(controller); }), HorizontalDashedLine( width: 200.w, color: Color(0xFFFFA0AE), strokeWidth: 2.h, dashLength: 5.w, dashSpace: 3.w, ), SizedBox(height: 5.h), Obx(() { return Text( controller.firstAmount?.description ?? "", style: TextStyle( color: const Color(0xFFFFF2F4), fontSize: 10.sp, fontWeight: FontWeight.w400, height: 2, ), ); }), ], ), ), SizedBox(height: 7.86.h), GestureDetector( onTap: () { EventHandler.report(EventId.event_02010); clickConfirm?.call(); SmartDialog.dismiss(tag: tag); }, child: SizedBox( width: 240.w, height: 60.h, child: SizedBox( child: Assets.images.iconNewSurpriseDialogButton .image(width: 240.w, height: 60.h), ), ), ), ], ), ), Positioned( right: 20.w, bottom: -5.h, child: IgnorePointer( child: Assets.images.iconNewSurpriseDialogHand.image( width: 78.w, height: 79.h, ), ), ), ], ), SizedBox(height: 26.h), GestureDetector( onTap: () { EventHandler.report(EventId.event_02011); SmartDialog.dismiss(tag: tag); clickCancel?.call(); }, child: Assets.images.iconNewSurpriseDialogClose.image( width: 40.r, height: 40.r, ), ), ], ); }, ); } static Widget _buildPricesPartOne(GoodsSurpriseController controller) { return Stack( children: [ Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( controller.firstAmount?.priceDescNumber ?? "", style: TextStyle( color: Colors.white, fontSize: 42.sp, fontWeight: FontWeight.w900, height: 0, ), ), Column( children: [ Container( width: 30.w, height: 18.h, decoration: BoxDecoration( image: DecorationImage( image: Assets.images.iconSurpriseDialogOnly.provider(), fit: BoxFit.cover, ), ), child: Center( child: Text( StringName.surpriseDialogOnly, style: TextStyle( color: const Color(0xFFFF451D), fontSize: 11.sp, fontWeight: FontWeight.w500, ), ), ), ), Text( controller.firstAmount?.priceDescUnit ?? '', style: TextStyle( color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.w700, ), ), ], ), ], ), Positioned( top: 5.r, left: 47.30.w, child: Container( padding: EdgeInsets.symmetric(horizontal: 2.w), transform: Matrix4.identity() ..translate(0.0, 0.0) ..rotateZ(-0.41), decoration: ShapeDecoration( color: const Color(0xFFD8FF1E), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3.r), ), ), child: Text( controller.firstAmount?.name ?? "", textAlign: TextAlign.center, style: TextStyle( color: const Color(0xFF231815), fontSize: 12.sp, fontWeight: FontWeight.w700, letterSpacing: -0.36, ), ), ), ), ], ); } }