import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import '../../core/utils/whatsapp_util.dart'; import 'whatsapp_share_button.dart'; /// Payment success dialog with WhatsApp sharing class PaymentSuccessDialog extends StatelessWidget { final String paymentId; final double amount; final String groupName; final String transactionId; final DateTime paymentDate; final String paymentMethod; const PaymentSuccessDialog({ super.key, required this.paymentId, required this.amount, required this.groupName, required this.transactionId, required this.paymentDate, required this.paymentMethod, }); static Future show( BuildContext context, { required String paymentId, required double amount, required String groupName, required String transactionId, required DateTime paymentDate, required String paymentMethod, }) { return showDialog( context: context, barrierDismissible: false, builder: (context) => PaymentSuccessDialog( paymentId: paymentId, amount: amount, groupName: groupName, transactionId: transactionId, paymentDate: paymentDate, paymentMethod: paymentMethod, ), ); } @override Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(24.r), ), child: Container( padding: EdgeInsets.all(24.w), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Success icon with animation TweenAnimationBuilder( tween: Tween(begin: 0.0, end: 1.0), duration: const Duration(milliseconds: 600), curve: Curves.elasticOut, builder: (context, value, child) { return Transform.scale( scale: value, child: child, ); }, child: Container( width: 80.w, height: 80.h, decoration: BoxDecoration( color: Colors.green.shade50, shape: BoxShape.circle, ), child: Icon( Icons.check_circle_rounded, size: 50.w, color: Colors.green.shade600, ), ), ), SizedBox(height: 20.h), // Title Text( 'Payment Successful!', style: TextStyle( fontSize: 22.sp, fontWeight: FontWeight.bold, color: Colors.green.shade700, ), textAlign: TextAlign.center, ), SizedBox(height: 8.h), // Amount Text( '₹${amount.toStringAsFixed(2)}', style: TextStyle( fontSize: 32.sp, fontWeight: FontWeight.bold, color: Colors.grey.shade800, ), ), SizedBox(height: 20.h), // Payment details Container( padding: EdgeInsets.all(16.w), decoration: BoxDecoration( color: Colors.grey.shade50, borderRadius: BorderRadius.circular(12.r), ), child: Column( children: [ _buildDetailRow('Group', groupName), SizedBox(height: 8.h), _buildDetailRow('Transaction ID', transactionId), SizedBox(height: 8.h), _buildDetailRow( 'Date', '${paymentDate.day}/${paymentDate.month}/${paymentDate.year}', ), SizedBox(height: 8.h), _buildDetailRow('Method', paymentMethod.toUpperCase()), ], ), ), SizedBox(height: 24.h), // WhatsApp share button WhatsAppShareButton( label: 'Share Receipt on WhatsApp', onPressed: () async { final success = await WhatsAppUtil.sharePaymentReceipt(paymentId); if (success) { Get.back(); // Close dialog } }, ), SizedBox(height: 12.h), // Close button SizedBox( width: double.infinity, child: OutlinedButton( onPressed: () => Get.back(), style: OutlinedButton.styleFrom( padding: EdgeInsets.symmetric(vertical: 14.h), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.r), ), ), child: Text( 'Close', style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.w600, ), ), ), ), ], ), ), ); } Widget _buildDetailRow(String label, String value) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( label, style: TextStyle( fontSize: 14.sp, color: Colors.grey.shade600, ), ), Text( value, style: TextStyle( fontSize: 14.sp, fontWeight: FontWeight.w600, color: Colors.grey.shade800, ), ), ], ); } }