import 'package:flutter/material.dart';

/// 사용 예시:
///   final bool? result = await showYesNoDialog(
///     context: context,
///     title: '확인',
///     message: '정말 진행하시겠습니까?',
///   );
///
///   if (result == true) {
///     // YES
///   } else {
///     // NO or 닫힘
///   }
Future<bool?> showYesNoDialog({
  required BuildContext context,
  required String title,
  required String message,
  bool yesNo = true,
}) {
  return showDialog<bool>(
    context: context,
    barrierDismissible: false, // dialog 밖 터치로 닫기 방지
    builder: (BuildContext ctx) {
      return AlertDialog(
        backgroundColor: Colors.white,
        title: Center(
          child: Text(
            title,
            style: const TextStyle(
              fontSize: 20,
              fontWeight: FontWeight.bold,
              color: Colors.black,
            ),
          ),
        ),
        content: Text(
          message,
          style: const TextStyle(
            fontSize: 16,
            color: Colors.black,
          ),
        ),
        actions: <Widget>[
          TextButton(
            onPressed: () => Navigator.of(ctx).pop(false), // NO
            style: TextButton.styleFrom(
              backgroundColor: Colors.black12,
              foregroundColor: Colors.black,
              padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
            ),
            child: const Text('No'),
          ),
          TextButton(
            onPressed: () => Navigator.of(ctx).pop(true), // YES
            style: TextButton.styleFrom(
              backgroundColor: Colors.black,
              foregroundColor: Colors.white,
              padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
            ),
            child: const Text('Yes'),
          ),
        ],
      );
    },
  );
}
