From 61895cd88aa473d9e2942992d01e0a677b853f22 Mon Sep 17 00:00:00 2001 From: Deep Koluguri Date: Fri, 7 Nov 2025 00:15:52 -0500 Subject: [PATCH] share feature --- .../manager/draw_animation_page.dart | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/luckychit/lib/interfaces/manager/draw_animation_page.dart b/luckychit/lib/interfaces/manager/draw_animation_page.dart index 3726aec..569bb21 100644 --- a/luckychit/lib/interfaces/manager/draw_animation_page.dart +++ b/luckychit/lib/interfaces/manager/draw_animation_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../core/services/chit_group_service.dart'; import '../../core/models/chit_group.dart'; import '../../shared/widgets/draw_animation_selector.dart'; +import '../../core/utils/whatsapp_util.dart'; class DrawAnimationPage extends StatefulWidget { final ChitGroup group; @@ -176,18 +177,60 @@ class _DrawAnimationPageState extends State ], ), ), + SizedBox(height: 16.h), + + // Quick Actions - Share & Screenshot + Row( + children: [ + Expanded( + child: OutlinedButton.icon( + onPressed: () => _shareViaWhatsApp(winner, bidAmount), + icon: Icon(Icons.send_rounded, size: 18.w, color: Color(0xFF25D366)), + label: Text('Share', style: TextStyle(fontSize: 13.sp, color: Color(0xFF25D366))), + style: OutlinedButton.styleFrom( + padding: EdgeInsets.symmetric(vertical: 10.h), + side: BorderSide(color: Color(0xFF25D366)), + ), + ), + ), + SizedBox(width: 8.w), + Expanded( + child: OutlinedButton.icon( + onPressed: () { + Get.snackbar( + 'Screenshot Tip', + 'Take a screenshot now to save this result!', + backgroundColor: Colors.blue, + colorText: Colors.white, + duration: Duration(seconds: 3), + ); + }, + icon: Icon(Icons.screenshot, size: 18.w, color: Colors.blue.shade600), + label: Text('Capture', style: TextStyle(fontSize: 13.sp, color: Colors.blue.shade600)), + style: OutlinedButton.styleFrom( + padding: EdgeInsets.symmetric(vertical: 10.h), + side: BorderSide(color: Colors.blue.shade600), + ), + ), + ), + ], + ), SizedBox(height: 20.h), Text( 'Do you want to save this draw result?', style: TextStyle( fontSize: 16.sp, color: Colors.grey.shade700, + fontWeight: FontWeight.w600, ), textAlign: TextAlign.center, ), ], ), + actionsAlignment: MainAxisAlignment.end, + actionsPadding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 16.h), actions: [ + // Cancel button OutlinedButton( onPressed: () => Navigator.pop(context, false), style: OutlinedButton.styleFrom( @@ -199,6 +242,8 @@ class _DrawAnimationPageState extends State style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w600), ), ), + SizedBox(width: 12.w), + // Save button ElevatedButton( onPressed: () => Navigator.pop(context, true), style: ElevatedButton.styleFrom( @@ -223,6 +268,33 @@ class _DrawAnimationPageState extends State ); } + void _shareViaWhatsApp(Map winner, double bidAmount) { + final monthNames = ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December']; + final monthName = monthNames[widget.month - 1]; + + final message = ''' +🎉 *${widget.group.name}* 🎉 + +📅 *Monthly Draw Result* +Month: $monthName ${widget.year} + +🏆 *WINNER* +${winner['name']} +${winner['mobile']} + +💰 *Prize Amount* +${_formatIndianCurrency(bidAmount)} + +✨ This draw was conducted using our provably fair system for complete transparency. + +_Congratulations to the winner!_ + '''; + + // Share to all members or specific number + WhatsAppUtil.shareText(message); + } + Future _saveDrawResult(String winnerId, double bidAmount) async { final chitGroupService = Get.find();