showDeleteContentDialog static method

Future<void> showDeleteContentDialog(
  1. BuildContext context, {
  2. required String contentName,
  3. required Future<bool> onConfirm(),
})

Shows delete confirmation dialog. Calls onConfirm if user confirms the permanent deletion.

Implementation

static Future<void> showDeleteContentDialog(
  BuildContext context, {
  required String contentName,
  required Future<bool> Function() onConfirm,
}) async {
  showDialog(
    context: context,
    builder: (ctx) => AlertDialog(
      backgroundColor: AppColor.scaffold,
      title: Text(CommonTranslationConstants.confirmDelete.tr,
        style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
      ),
      content: Text(
        '${CommonTranslationConstants.deleteContentMsg.tr}\n\n"$contentName"',
        style: const TextStyle(color: Colors.white70),
      ),
      actions: [
        TextButton(
          onPressed: () => Navigator.pop(ctx),
          child: Text(AppTranslationConstants.cancel.tr),
        ),
        TextButton(
          onPressed: () async {
            Navigator.pop(ctx);
            final success = await onConfirm();
            if (success) {
              AppUtilities.showSnackBar(
                message: CommonTranslationConstants.contentDeleted,
              );
            }
          },
          child: Text(CommonTranslationConstants.deleteContent.tr,
            style: const TextStyle(color: Colors.redAccent),
          ),
        ),
      ],
    ),
  );
}