import 'package:flutter/material.dart';

/// Utilitaires pour afficher des dialogues de confirmation
class DialogUtils {
  /// Affiche un dialogue de confirmation de suppression
  static Future<bool> showDeleteConfirmation({
    required BuildContext context,
    required String title,
    required String message,
    String confirmButtonText = 'Supprimer',
    String cancelButtonText = 'Annuler',
  }) async {
    final result = await showDialog<bool>(
      context: context,
      builder: (context) => AlertDialog(
        title: Text(title),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context, false),
            child: Text(cancelButtonText),
          ),
          ElevatedButton(
            onPressed: () => Navigator.pop(context, true),
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.red,
              foregroundColor: Colors.white,
            ),
            child: Text(confirmButtonText),
          ),
        ],
      ),
    );
    return result ?? false;
  }

  /// Affiche un dialogue de confirmation générique
  static Future<bool> showConfirmation({
    required BuildContext context,
    required String title,
    required String message,
    String confirmButtonText = 'Confirmer',
    String cancelButtonText = 'Annuler',
    Color? confirmButtonColor,
  }) async {
    final result = await showDialog<bool>(
      context: context,
      builder: (context) => AlertDialog(
        title: Text(title),
        content: Text(message),
        actions: [
          TextButton(
            onPressed: () => Navigator.pop(context, false),
            child: Text(cancelButtonText),
          ),
          ElevatedButton(
            onPressed: () => Navigator.pop(context, true),
            style: confirmButtonColor != null
                ? ElevatedButton.styleFrom(
                    backgroundColor: confirmButtonColor,
                    foregroundColor: Colors.white,
                  )
                : null,
            child: Text(confirmButtonText),
          ),
        ],
      ),
    );
    return result ?? false;
  }
}

