import 'package:flutter/material.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/features/report/transaction/presentation/widgets/cancel_option.dart';
import 'package:sizer/sizer.dart';

class CancelConfirmation extends StatelessWidget {
  final String title;
  final String subtitle;
  final VoidCallback? onCancelWithOutUpdateStock;
  final VoidCallback? onCancelWithUpdateStock;
  const CancelConfirmation({
    super.key,
    required this.title,
    required this.subtitle,
    required this.onCancelWithOutUpdateStock,
    required this.onCancelWithUpdateStock
  });

  @override
  Widget build(BuildContext context) {
    final bool isTablet = 100.w >= 600;
    final double maxWidth = 100.w >= 1280
        ? 1200
        : isTablet
        ? 800
        : 400;
    return Dialog(
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.5.w)),
      elevation: 0,
      backgroundColor: Colors.transparent,
      child: Container(
        padding: EdgeInsets.all(6.w),
        width: double.infinity,
        constraints: BoxConstraints(maxWidth: maxWidth),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(4.5.w),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              padding: EdgeInsets.all(4.w),
              decoration: BoxDecoration(
                color: Colors.red[50],
                shape: BoxShape.circle,
              ),
              child: Icon(Icons.cancel_outlined, color: Colors.red, size: 10.w),
            ),
            SizedBox(height: 2.h),

            Text(
              title,
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: AppFontSize.medium.sp,
                fontWeight: FontWeight.bold,
                color: Colors.black87,
              ),
            ),
            SizedBox(height: 1.h),
            Text(
              subtitle,
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: isTablet
                    ? (AppFontSize.medium - 1.25).sp
                    : (AppFontSize.small - 1.25).sp,
                color: Colors.grey.shade800,
              ),
            ),
            SizedBox(height: 3.h),

            CancelOption(
              title: "Batalkan Tanpa Perbarui Stok",
              subtitle: "Status batal, namun jumlah stok barang tetap.",
              icon: Icons.inventory,
              color: Colors.orange,
              onTap: onCancelWithOutUpdateStock,
            ),

            SizedBox(height: 1.5.h),

            CancelOption(
              title: "Batalkan & Perbarui Stok",
              subtitle: "Status batal dan stok barang akan dikembalikan.",
              icon: Icons.settings_backup_restore_rounded,
              color: AppColor.primaryColor,
              onTap: onCancelWithUpdateStock,
            ),

            SizedBox(height: 3.h),

            SizedBox(
              width: double.infinity,
              child: OutlinedButton(
                onPressed: () => Navigator.pop(context),
                style: OutlinedButton.styleFrom(
                  padding: EdgeInsets.symmetric(vertical: 1.5.h),
                  side: BorderSide(color: Colors.grey[300]!),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(2.5.w),
                  ),
                ),
                child: Text(
                  "Kembali",
                  style: TextStyle(
                    color: Colors.grey[700],
                    fontWeight: FontWeight.bold,
                    fontSize: AppFontSize.medium.sp,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
