import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:gobang/themes/app_colors.dart'; class TipsDialog { static Future show( BuildContext context, String title, String tips, ) { return showGeneralDialog( context: context, barrierDismissible: false, barrierLabel: 'dialog', barrierColor: const Color(0xB0070D10), transitionDuration: const Duration(milliseconds: 280), pageBuilder: (ctx, a1, a2) { return const SizedBox.shrink(); }, transitionBuilder: (ctx, anim, _, __) { final curved = CurvedAnimation(parent: anim, curve: Curves.easeOutBack); return FadeTransition( opacity: anim, child: ScaleTransition( scale: Tween(begin: 0.88, end: 1.0).animate(curved), child: Center( child: Material( color: Colors.transparent, child: Container( width: MediaQuery.of(ctx).size.width * 0.82, padding: const EdgeInsets.fromLTRB(24, 28, 24, 20), decoration: BoxDecoration( color: AppColors.ivory, borderRadius: BorderRadius.circular(28), boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.28), blurRadius: 40, offset: const Offset(0, 16), ), ], ), child: Column( mainAxisSize: MainAxisSize.min, children: [ Container( width: 64, height: 64, decoration: BoxDecoration( shape: BoxShape.circle, gradient: LinearGradient( colors: title.contains('恭喜') ? const [ AppColors.pumpkinSoft, AppColors.pumpkin, ] : const [Color(0xFF4A4A4A), Color(0xFF1A1A1A)], ), ), ), const SizedBox(height: 16), Text( title, style: const TextStyle( color: AppColors.ink, fontSize: 24, fontWeight: FontWeight.w800, ), ), const SizedBox(height: 8), Text( tips, textAlign: TextAlign.center, style: const TextStyle( color: Color(0xFF5A736A), fontSize: 14, height: 1.4, ), ), const SizedBox(height: 20), SizedBox( width: double.infinity, child: FilledButton( style: FilledButton.styleFrom( backgroundColor: title.contains('恭喜') ? AppColors.ink : AppColors.pumpkin, foregroundColor: AppColors.ivory, padding: const EdgeInsets.symmetric(vertical: 14), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(14), ), ), onPressed: () => Navigator.of(ctx).pop(), child: Text( title.contains('恭喜') ? '再来一局' : '确定', style: const TextStyle(fontWeight: FontWeight.w700), ), ), ), ], ), ), ), ), ), ); }, ); } static Future showByChoose( BuildContext context, String title, String tips, String yes, String no, ) { return showGeneralDialog( context: context, barrierDismissible: false, barrierLabel: 'choose', barrierColor: const Color(0x99070D10), transitionDuration: const Duration(milliseconds: 240), pageBuilder: (ctx, a1, a2) => const SizedBox.shrink(), transitionBuilder: (ctx, anim, _, __) { return FadeTransition( opacity: anim, child: ScaleTransition( scale: Tween(begin: 0.92, end: 1.0).animate( CurvedAnimation(parent: anim, curve: Curves.easeOutCubic), ), child: Center( child: Material( color: Colors.transparent, child: Container( width: MediaQuery.of(ctx).size.width * 0.8, padding: const EdgeInsets.all(24), decoration: BoxDecoration( color: AppColors.ivory, borderRadius: BorderRadius.circular(24), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ Text( title, style: const TextStyle( color: AppColors.ink, fontSize: 20, fontWeight: FontWeight.w800, ), ), const SizedBox(height: 10), Text( tips, textAlign: TextAlign.center, style: const TextStyle( color: Color(0xFF5A736A), fontSize: 14, ), ), const SizedBox(height: 20), Row( children: [ Expanded( child: TextButton( style: TextButton.styleFrom( backgroundColor: AppColors.mist, foregroundColor: AppColors.ink, padding: const EdgeInsets.symmetric(vertical: 12), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), onPressed: () => Navigator.of(ctx).pop(false), child: Text(no), ), ), const SizedBox(width: 12), Expanded( child: FilledButton( style: FilledButton.styleFrom( backgroundColor: title.contains('投降') ? AppColors.pumpkin : AppColors.ink, foregroundColor: AppColors.ivory, padding: const EdgeInsets.symmetric(vertical: 12), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), onPressed: () => Navigator.of(ctx).pop(true), child: Text(yes), ), ), ], ), ], ), ), ), ), ), ); }, ); } static void toast(String message) { Fluttertoast.showToast(msg: message, gravity: ToastGravity.CENTER); } }