import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:onufitness/screens/echoboard/controllers/delete_report_controller.dart'; import 'package:onufitness/utils/custom_sneakbar.dart'; void showDeletePostDialog({ required BuildContext context, required String postId, required Function onPostDeleted, required PostMorePressController deletePostController, }) { showDialog( barrierDismissible: false, context: context, builder: (BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16.r), ), elevation: 0, backgroundColor: Colors.transparent, child: Container( padding: EdgeInsets.all(20.r), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16.r), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ Container( width: 60.w, height: 60.h, decoration: BoxDecoration( color: Color(0xFFF8F8F8), shape: BoxShape.circle, ), child: Icon( Icons.delete_outline, size: 30.sp, color: Colors.black, ), ), SizedBox(height: 16.h), Text( 'Delete post', style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w600), ), SizedBox(height: 8.h), Text( 'Are you sure you want to delete this post? This action cannot be undone.', textAlign: TextAlign.center, style: TextStyle(fontSize: 14.sp, color: Colors.grey[600]), ), SizedBox(height: 24.h), Obx( () => deletePostController.isDeleting.value ? Center( child: CircularProgressIndicator(color: Colors.black), ) : Row( children: [ Expanded( child: TextButton( style: TextButton.styleFrom( padding: EdgeInsets.symmetric(vertical: 12.h), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.r), side: BorderSide(color: Colors.grey[300]!), ), ), onPressed: () { Navigator.of(context).pop(); }, child: Text( 'Cancel', style: TextStyle( color: Colors.grey[700], fontSize: 16.sp, fontWeight: FontWeight.w500, ), ), ), ), SizedBox(width: 12.w), Expanded( child: ElevatedButton( style: ElevatedButton.styleFrom( padding: EdgeInsets.symmetric(vertical: 12.h), backgroundColor: Colors.red[600], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.r), ), ), onPressed: () async { final success = await deletePostController .deletePost(postId); if (success) { Navigator.of(context).pop(); onPostDeleted(); } else { // Show error customSnackbar( title: 'Error', message: 'Failed to delete post. Please try again.', duration: 2, ); } }, child: Text( 'Delete', style: TextStyle( color: Colors.white, fontSize: 16.sp, fontWeight: FontWeight.w500, ), ), ), ), ], ), ), ], ), ), ); }, ); }