share feature
This commit is contained in:
parent
cd51b3704b
commit
61895cd88a
|
|
@ -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<DrawAnimationPage>
|
|||
],
|
||||
),
|
||||
),
|
||||
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<DrawAnimationPage>
|
|||
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<DrawAnimationPage>
|
|||
);
|
||||
}
|
||||
|
||||
void _shareViaWhatsApp(Map<String, dynamic> 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<void> _saveDrawResult(String winnerId, double bidAmount) async {
|
||||
final chitGroupService = Get.find<ChitGroupService>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue