import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:trackoffical_app/model/m_control_point.dart'; import 'package:trackoffical_app/styles/theme.dart'; const horizontalEdge = 20.0; const cardHeight = 225.4; double _getCardTop(BuildContext context) { return (context.height - cardHeight) / 2.7; } class DialogChecked2 extends StatelessWidget { final VoidCallback? onConfirm; final MControlPoint currentPoint; final MControlPoint? nextPoint; final mainColor = const Color(0xffff8000); const DialogChecked2({ super.key, this.onConfirm, required this.currentPoint, this.nextPoint, }); @override Widget build(BuildContext context) { final backColor = currentPoint.isSuccess ? const Color(0xff0aad81) : const Color(0xffff8000); final bordColor = currentPoint.isSuccess ? const Color(0xff64cbb0) : const Color(0xffffd6d6); var text = ''; Widget bean = const SizedBox(); final cardTop = _getCardTop(context); if (currentPoint.isSuccess) { if (currentPoint.sn == MControlPoint.snStart) { text = '游戏开始'; } else if (currentPoint.sn == MControlPoint.snFinish) { text = '恭喜完赛'; } else { text = '打卡成功'; bean = Positioned( top: cardHeight + 40, child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisSize: MainAxisSize.min, children: [ Image.asset('assets/images/ic_bean.png', height: 52, fit: BoxFit.fitHeight), Text(' X 1', style: context.textTheme.titleLarge ?.copyWith(color: Colors.white, fontSize: 24)) ], ), const SizedBox(height: 17), Text('获得百味豆1个哦', style: context.textTheme.titleLarge?.copyWith( color: const Color(0xff9d9d9d), fontSize: 15)) ], )); } } else { text = '顺序错误'; } return Padding( padding: EdgeInsets.fromLTRB(horizontalEdge, cardTop, horizontalEdge, 80), child: GestureDetector( onTap: () => Get.back(), child: SizedBox( width: double.infinity, height: double.infinity, child: Stack( alignment: Alignment.topCenter, children: [ CustomPaint( painter: _BackGround(color: backColor), child: Container( margin: const EdgeInsets.all(10), width: 276.5, height: cardHeight, decoration: BoxDecoration( border: Border.all(color: bordColor, width: 2), borderRadius: BorderRadius.circular(7.62)), child: Column( children: [ Expanded( child: Row( children: [ Expanded(child: Center(child: _getSn(context))), VerticalDivider(width: 2, color: bordColor), Expanded( child: Column( mainAxisSize: MainAxisSize.min, children: [ Text('检查点', style: context.textTheme.bodyLarge ?.copyWith( color: Colors.white, fontSize: 33.76)), Container( height: 48, width: 102.36, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(3.27)), child: Text(currentPoint.areaId, style: context.textTheme.bodyLarge ?.copyWith( height: 0.77, color: backColor, fontSize: 49, fontWeight: FontWeight.w600)), ) ], )), ], )), Divider(height: 2, color: bordColor), Expanded( child: Center( child: Text(text, style: context.textTheme.titleLarge ?.copyWith( color: Colors.white, fontSize: 49, fontWeight: FontWeight.w700)))) ], ), ), ), bean // Positioned(top: 20, left: 0, child: _okMsg(context)), // Positioned(top: 120, left: 0, child: _topCard(context)), // Positioned(top: 320, left: 0, child: _memo(context)), // Positioned(top: 400, left: 0, child: _closeBtn(context)), ], )))); } Widget _getSn(BuildContext context) { var src = ''; if (currentPoint.isSuccess) { if (currentPoint.sn == MControlPoint.snStart) { src = 'ic_checked_start.png'; } else if (currentPoint.sn == MControlPoint.snFinish) { src = 'ic_checked_finish.png'; } else { return Text("${currentPoint.sn}号", style: context.textTheme.titleLarge?.copyWith( color: Colors.white, fontSize: 54.44, fontWeight: FontWeight.w500)); } } else { src = 'ic_checked_fail.png'; } return Image.asset('assets/images/$src', height: 60, fit: BoxFit.fitHeight); } } class _BackGround extends CustomPainter { final Color color; _BackGround({required this.color}); @override void paint(Canvas canvas, Size size) { var paint = Paint() ..color = color ..maskFilter = const MaskFilter.blur(BlurStyle.solid, 12); canvas.drawRRect( RRect.fromRectAndRadius(Rect.fromLTWH(0, 0, size.width, size.height), const Radius.circular(12)), paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) { return this != oldDelegate; } } class DialogGiveUp extends StatelessWidget { final VoidCallback onConfirm; final VoidCallback onCancel; const DialogGiveUp( {super.key, required this.onConfirm, required this.onCancel}); @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.fromLTRB( horizontalEdge, _getCardTop(context), horizontalEdge, 80), child: Stack( alignment: Alignment.topCenter, children: [ CustomPaint( painter: _BackGround(color: const Color(0xffff0000)), child: Container( margin: const EdgeInsets.all(10), width: 276.5, height: cardHeight, alignment: Alignment.center, decoration: BoxDecoration( border: Border.all( color: const Color(0xffffd6d6), width: 2), borderRadius: BorderRadius.circular(7.62)), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text('退出比赛', style: context.textTheme.titleLarge?.copyWith( color: Colors.white, fontSize: 35.93, fontWeight: FontWeight.w700)), const SizedBox(height: 19), Text( '是否强制结束?', style: context.textTheme.titleLarge ?.copyWith(color: Colors.white, fontSize: 19.6), ), const SizedBox(height: 35), Row( mainAxisSize: MainAxisSize.min, children: [ SizedBox( width: 100, height: 41, child: OutlinedButton( onPressed: onCancel, style: OutlinedButton.styleFrom(side: BorderSide(width: 1, color: Colors.white)), child: const Text( '否', style: TextStyle(height: 0.1, color: Colors.white, fontSize: 26), ))), const SizedBox(width: 23), SizedBox( width: 100, height: 41, child: FilledButton( onPressed: onConfirm, style: FilledButton.styleFrom(backgroundColor: Colors.white), child: const Text('是', style: TextStyle( height: 0.1, color: Color(0xffff0000), fontSize: 26)))) ], ) ], ))) ], )); } } class _Empty extends StatelessWidget { @override Widget build(BuildContext context) { _showDialog(); return const Scaffold(); } } Future _showDialog() async { await Future.delayed(2.seconds); if (Get.isOverlaysOpen) { Get.back(); } Get.dialog(DialogChecked2( onConfirm: () {}, currentPoint: MControlPoint( // sn: ControlPointText.snFinish, sn: "12", areaId: 'A51', isSuccess: true), nextPoint: MControlPoint( sn: MControlPoint.snFinish, areaId: 'A52', isSuccess: true), )); } void main() async { runApp(GetMaterialApp(theme: appThemeData(), home: _Empty())); }